diff --git a/_posts/2014-07-30-travel-hampi-bengaluru-allepy-part-1.markdown b/_posts/2014-07-30-travel-hampi-bengaluru-allepy-part-1.markdown index 48b81c9..158d81a 100644 --- a/_posts/2014-07-30-travel-hampi-bengaluru-allepy-part-1.markdown +++ b/_posts/2014-07-30-travel-hampi-bengaluru-allepy-part-1.markdown @@ -22,7 +22,7 @@ rickshaw took us to Hampi. The first thing one notices while riding into Hampi [gopuram](http://en.wikipedia.org/wiki/Gopuram) of the [Virupaksha Temple](http://en.wikipedia.org/wiki/Virupaksha_Temple). This is also one of the few temples in Hampi that is still actively used in worship. -![/assets/images/hampi-bengaluru-allepy/virupaksha.JPG]('The Virupaksha Temple'%} +![The Virupaksha temple](/assets/images/hampi-bengaluru-allepy/virupaksha.JPG) We checked into a hotel which was a 5 minute walk from the Virupaksha temple, which charged us Rs. 800 per night. Since Hampi is a favorite for foreign tourists, one can find many cafes and restaurants here @@ -32,16 +32,16 @@ planned for the day's sightseeing. We started out toward the Vitthal temple, taking the huge road that was once the Hampi Bazaar. Along the way, we saw the monolithic Nandi statue on the left, and [Matanga hill](http://hampi.in/matunga-hill) on the right. -![/assets/images/hampi-bengaluru-allepy/nandi.JPG]('The Nandi Statue') -![/assets/images/hampi-bengaluru-allepy/entrance.JPG]('Entrance At The Far End Of Hapmi Bazaar.') +![The Nandi Statue](/assets/images/hampi-bengaluru-allepy/nandi.JPG +![Entrance At The Far End Of Hapmi Bazaar.](/assets/images/hampi-bengaluru-allepy/entrance.JPG A flight of steps lead to a grand entrance which opens at the Achyutraya Temple. This temple was build by the successor of King Krishnadevaraya, Achyuta Deva Raya, and is a temple to Lord Venkateshwara, but its ruins are popularly reffered to by the name of its patron. -![/assets//images/hampi-bengaluru-allepy/achyutraya_temple.JPG][Achyutraya Temple] +![Achyutraya Temple](/assets/images/hampi-bengaluru-allepy/achyutraya_temple.JPG) After walking over some huge rocks by the river, we reached the King's Balance, a stone weighing scale where the King would be weighed against gold, which would then be given away to the priests. We then (finally) reached the Vitthal Temple. -![/assets//images/hampi-bengaluru-allepy/vitthal_front.JPG][The Sun Chariot With The Vitthal Temple In The Background] +![The Sun Chariot With The Vitthal Temple In The Background](/assets/images/hampi-bengaluru-allepy/vitthal_front.JPG) The Vithhal Temple is probably one of the grandest in Hampi and possibly in all of India. It is housed inside a massive complex with ornately carved walls, entrances and pillars. The complex houses five mantapas, 4 in @@ -54,7 +54,7 @@ so the sound is fairly diminished now. The central mantap houses an inner temple, where the actual idols were kept and worshipped. The original idols of Vitthal and Rukumai were taken to Pandharpur in Maharashtra during the invasion of Vijaynagar. One unique feature of the Vitthal temple is that the place where one performs ['pradakshina'](http://en.wikipedia.org/wiki/Parikrama) is underground. -![/assets//images/hampi-bengaluru-allepy/underground_parikrama.JPG][The Underground Pradakshina Path] +![The Underground Pradakshina Path](/assets/images/hampi-bengaluru-allepy/underground_parikrama.JPG) There are tiny inlets for light in the roof, which reflects off a stream of water on the floor, which in turn provides illumination for the entire chamber. diff --git a/_posts/2014-09-21-code-generalized-linear-models-introduction-and-implementation-in-ruby.markdown b/_posts/2014-09-21-code-generalized-linear-models-introduction-and-implementation-in-ruby.markdown index f18d9ee..6ccf940 100644 --- a/_posts/2014-09-21-code-generalized-linear-models-introduction-and-implementation-in-ruby.markdown +++ b/_posts/2014-09-21-code-generalized-linear-models-introduction-and-implementation-in-ruby.markdown @@ -46,7 +46,7 @@ One thing that puzzled me when I started off with regression was the purpose of The logistic graph generally looks like this: -![/assets//images/glm/logistic.gif][Generic Graph of Logistic Regression.] +![Generic Graph of Logistic Regression](/assets/images/glm/logistic.gif) #### Normal Regression @@ -56,7 +56,7 @@ Normally distributed data is symmetric about the center and its mean is equal to A normal regression graph generally looks like this: -![/assets//images/glm/normal.png][Generic Graph of Normal Regression] +![Generic Graph of Normal Regression](/assets/images/glm/normal.png) #### Poisson Regression @@ -68,7 +68,7 @@ The meaning of the co-efficient in the case of poisson is "for increase 1 of _x_ A poisson graph looks something like this: -![/assets//images/glm/poisson.png][Graph of Poisson Regression] +![Graph of Poisson Regression](/assets/images/glm/poisson.png) #### Probit Regression @@ -82,7 +82,7 @@ The coefficient of _x_ is interpreted as "one unit change in _x_ leads to a chan Looking at the graph of probit, one can see the similarities between logit and probit: -![/assets//images/glm/probit.png][label] +![label](/assets/images/glm/probit.png) ## Finding the coefficients of a GLM diff --git a/_posts/2014-09-28-travel-hampi-bengaluru-allepy-part-2.markdown b/_posts/2014-09-28-travel-hampi-bengaluru-allepy-part-2.markdown index d2d7792..e377ca0 100644 --- a/_posts/2014-09-28-travel-hampi-bengaluru-allepy-part-2.markdown +++ b/_posts/2014-09-28-travel-hampi-bengaluru-allepy-part-2.markdown @@ -12,42 +12,42 @@ The day started at 5 am, and we proceeded to Matanga Hill to watch the sunrise, As we started climbing the hill, a Naga Yogi waiting at the bottom of the hill asked us to register with the police station before going up the hill. We told him the station was closed, so he guided us up the hill. Along the way he told us that he had converted to a Naga Yogi after a stint at a multinational bank and now lived in a cave up the hill (wow), performing his sadhu duties in the temple town (which blew us away). The climb turned out to be pretty trecherous, with steep cliffs and a very narrow path leading uphill. He guided us to the rooftop of the Veerbhadra Temple present at the top of Matanga Hill, where the sunrise can be experienced best, and set off on his own after inviting us to his cave for tea once we we were done seeing the sunrise. -![/assets//images/hampi-bengaluru-allepy/matanga_sunrise.JPG][Sunrise from Matanga Hill] +![Sunrise from Matanga Hill](/assets/images/hampi-bengaluru-allepy/matanga_sunrise.JPG) -![/assets//images/hampi-bengaluru-allepy/matanga_view.JPG][View of Achutarya Temple from Matanga Hill] +![View of Achutarya Temple from Matanga Hill](/assets/images/hampi-bengaluru-allepy/matanga_view.JPG) After seeing the sunrise and having some great black tea in our guide's cave, we started our descent, which took around 40 mins, mainly because of the jagged structure of the rocks. A fantastic breakfast of idli and tea awaited us at the bottom. Breakfast food carts are spread thorughout Hampi and serve cheap, tasty and filling food. We then proceeded to our cycle tour, which would take us through the outer parts of Hampi; first stopping at the [Kadalekalu Ganesha](http://hampi.in/kadalekalu-ganesha) (Kadalekalu because the statue's belly resembles a Bengal Gram) temple, which houses a massive statue of Ganpati, the Hindu god of wisdom. The statue is now in ruins, after being destroyed by the Deccan Muslim rulers, who thought there was a hidden treasure inside the stomach of the statue, because of its size. -![/assets//images/hampi-bengaluru-allepy/ganpati_kk.JPG][Kadalekalu Ganesha statue] +![Kadalekalu Ganesha statue](/assets/images/hampi-bengaluru-allepy/ganpati_kk.JPG) Then we proceeded to the statue of Narsimha and Laxmi. This was a huge monolith of a statue once upon a time, but it was destroyed by the invading army. A lot of it has been restored but it appears nowhere near its former glory. Right next to this is the partially submerged Shivalinga, which happens to be the 2nd largest in the country. -![/assets//images/hampi-bengaluru-allepy/narsimha.JPG][The partially restored statue of Narsimha and Laxmi] +![The partially restored statue of Narsimha and Laxmi](/assets/images/hampi-bengaluru-allepy/narsimha.JPG) We then cycled towards the underground Shiva temple, which was pretty mind-blowing. The temple's roof is on ground level and the rest of the structure underground, the inner mantapas are kept full of water. Then cycling towards the Lotus Palace we came across the Mohammedan Watch Tower, which was a structure made for the Muslim troops in King Krishnadevaraya's army. This structure sports typical Persian architecture, the only structure of its kind in Hampi. The Lotus Palace is where the two Queens of King Krishnadevaraya stayed. The main palace has a state-of-the-art water cooling system, with pipes of water circulating around the entire palace to keep the occupants cool during the summer. -![/assets//images/hampi-bengaluru-allepy/lotus_mahal.JPG][The Lotus Mahal!!] +![The Lotus Mahal!!!](/assets/images/hampi-bengaluru-allepy/lotus_mahal.JPG) Behind this was a massive stable for the royal elephants, which housed all 11 of them. The Lotus Mahal (palace) consisted of two palaces, called Water Palace and the Queen's Palace, both of which are now in ruins. -![/assets//images/hampi-bengaluru-allepy/elephant_house.JPG][Elephant Stable] +![Elephant Stable](/assets/images/hampi-bengaluru-allepy/elephant_house.JPG) We cycled to the King's enclosure, which had a whole lot of podiums and open spaces for conducting festivities. Dusshera was celebrated with great pomp here. There was an especially large podium for the King to be seated on so that he could watch all the proceedings from a vantage point. -![/assets//images/hampi-bengaluru-allepy/enclosure.JPG][The King's Enclosure and his podium] +![s Enclosure and his podium](/assets/images/hampi-bengaluru-allepy/enclosure.JPG) -![/assets//images/hampi-bengaluru-allepy/bath.JPG][The Queens Bath] +![The Queens Bath](/assets/images/hampi-bengaluru-allepy/bath.JPG) The Queen's bath was just a few minutes cycle ride from here and that is where we went next. This was a huge tank for the Queen to take a bath in, made in Indo-Arabic architecture. The cycle ride back to the center of Hampi (and our hotel) was long but extremely plesant. The route was lush green with many streams and small waterfalls. -![/assets//images/hampi-bengaluru-allepy/cycle_ride.JPG][The cycle ride back to Hampi] +![The cycle ride back to Hampi](/assets/images/hampi-bengaluru-allepy/cycle_ride.JPG) Upon returning we had some late lunch at a South Indian restaurant (Venkateshwara Restaurant), and left for Hospet to catch our bus to Bangalore, which left from there at night. diff --git a/_posts/2014-11-25-data-analysis-in-ruby-basic-data-manipulation-and-plotting.markdown b/_posts/2014-11-25-data-analysis-in-ruby-basic-data-manipulation-and-plotting.markdown index 0162200..24408a3 100644 --- a/_posts/2014-11-25-data-analysis-in-ruby-basic-data-manipulation-and-plotting.markdown +++ b/_posts/2014-11-25-data-analysis-in-ruby-basic-data-manipulation-and-plotting.markdown @@ -162,7 +162,7 @@ df = Daru::DataFrame.from_csv 'music_data.tsv', col_sep: "\t" ``` -![/assets//images/daru1/create_music_df.png][Create a DataFrame from a TSV file.] +![Create a DataFrame from a TSV file.](/assets/images/daru1/create_music_df.png) As you can see the *timestamp* field is in a somewhat non-Ruby format which is pretty difficult for the default Time class to understand, so we destructively map time zone information (IST in this case) and then change every *timestamp* string field into a Ruby _Time_ object, so that operations on time can be easily performed. @@ -173,7 +173,7 @@ Notice the syntax for referencing a particular vector. Use 'row' for referencing df.timestamp.recode! { |ts| ts += "+5:30"} ``` -![/assets//images/daru1/dmap_vector.png][Destructively map a given vector.] +![Destructively map a given vector.](/assets/images/daru1/dmap_vector.png) ``` ruby @@ -185,7 +185,7 @@ end ``` -![/assets//images/daru1/df_row_map.png][Map all rows of a DataFrame.] +![Map all rows of a DataFrame.](/assets/images/daru1/df_row_map.png) #### Basic Querying @@ -193,7 +193,7 @@ A bunch of rows can be selected by specifying a range: `df.row[900..923]` -![/assets//images/daru1/range_row_access.png][Accessing rows with a range] +![Accessing rows with a range](/assets/images/daru1/range_row_access.png) #### Data Analysis @@ -205,13 +205,13 @@ Lets dive deeper by actually trying to extract something useful from the data th artists = df.group_by(:artname).size ``` -![/assets//images/daru1/get_max_artists.png][Create a vector of artist names vs number of times they appear.] +![Create a vector of artist names vs number of times they appear.](/assets/images/daru1/get_max_artists.png) To get the maximum value out of these, use `#max_index`. This will return a Vector which has the max: `count.max_index` -![/assets//images/daru1/artists_max.png][Obtain the most heard artist.] +![Obtain the most heard artist.](/assets/images/daru1/artists_max.png) #### Plotting @@ -230,7 +230,7 @@ top_ten.plot type: :bar do |plt| end ``` -![/assets//images/daru1/plot_top_ten.png][Top ten artists plotted.] +![Top ten artists plotted.](/assets/images/daru1/plot_top_ten.png) More examples can be found in [the notebooks section of the daru README](https://github.com/v0dro/daru#notebooks). diff --git a/_posts/2015-02-24-data-analysis-in-ruby-part-2.markdown b/_posts/2015-02-24-data-analysis-in-ruby-part-2.markdown index f382c62..cf85a84 100644 --- a/_posts/2015-02-24-data-analysis-in-ruby-part-2.markdown +++ b/_posts/2015-02-24-data-analysis-in-ruby-part-2.markdown @@ -122,7 +122,7 @@ df.sort([:a,:d], ) ``` -![/assets//images/daru2/sorted_df.png][Hierarchically sorted DataFrame] +![Hierarchically sorted DataFrame](/assets/images/daru2/sorted_df.png) Vector objects also have a similar sorting method implemented. Check the docs for more details. Indexing is preserved while sorting of both DataFrame and Vector. @@ -141,7 +141,7 @@ df.plot type: :line, x: :a, y: :b do |p,d| d.color "green" end ``` -![/assets//images/daru2/line_graph.png][Line Graph From DataFrame] +![Line Graph From DataFrame](/assets/images/daru2/line_graph.png) As you can see, the `#plot` function exposes the `Nyaplot::Plot` and `Nyaplot::Diagram` objects to user after populating them with the relevant data. So the new interface lets experienced users utilize the full power of nyaplot but keeps basic plotting very simple to use for new users or for quick and dirty visualization needs. Unfortunately for now, until a viable solution to interfacing with nyaplot is found, you will need to use the nyaplot API directly. @@ -172,7 +172,7 @@ To calculate the mean of numeric vectors: df.mean ``` -![/assets//images/daru2/df_mean.png][Calculate Mean of Numeric Vectors] +![Calculate Mean of Numeric Vectors](/assets/images/daru2/df_mean.png) Apart from that you can use the `#describe` method to calculate many statistical features of numeric Vectors in one shot and see a summary of statistics for numerical vectors in the DataFrame that is returned. For example, @@ -181,7 +181,7 @@ Apart from that you can use the `#describe` method to calculate many statistical df.describe ``` -![/assets//images/daru2/df_describe.png][Describe Multiple Statistics in One Shot] +![Describe Multiple Statistics in One Shot](/assets/images/daru2/df_describe.png) The covariance and correlation coeffiecients between the numeric vectors can also be found with `#cov` and `#corr` @@ -237,7 +237,7 @@ df_mi = Daru::DataFrame.new([ vector_arry2], order: order_mi, index: multi_index) ``` -![/assets//images/daru2/multi_index_table.png][DataFrame with hierarchical indexing] +![DataFrame with hierarchical indexing](/assets/images/daru2/multi_index_table.png) Selecting a top level index from the hierarchy will select all the rows under that name, and return a new DataFrame with just that much data and indexes. @@ -246,7 +246,7 @@ Selecting a top level index from the hierarchy will select all the rows under th df_mi.row[:a] ``` -![/assets//images/daru2/multi_index_partial.png][Partial Selection Of Multi Indexed DataFrame] +![Partial Selection Of Multi Indexed DataFrame](/assets/images/daru2/multi_index_partial.png) Alternatively passing the entire tuple will return just that row as a `Daru::Vector`, indexed according to the column index. @@ -254,7 +254,7 @@ Alternatively passing the entire tuple will return just that row as a `Daru::Vec df_mi.row[:a, :one,:bar] ``` -![/assets//images/daru2/multi_index_exact.png][Selecting A Single Row From A Multi Indexed DataFrame] +![Selecting A Single Row From A Multi Indexed DataFrame](/assets/images/daru2/multi_index_exact.png) Hierachical indexing is especially useful when aggregating or splitting data, or generating data summaries as we'll see in the following examples. @@ -340,7 +340,7 @@ The `Daru::Core::GroupBy` object contains a bunch of methods for creating summar grouped.mean ``` -![/assets//images/daru2/group_by_mean.png][Aggregating by Mean After Grouping] +![Aggregating by Mean After Grouping](/assets/images/daru2/group_by_mean.png) A hierarchichally indexed DataFrame is returned. Check the `GroupBy` docs for more aggregation methods. @@ -350,7 +350,7 @@ You can generate an excel-style pivot table with the `#pivot_table` function. Th To demonstrate with an example, consider [this CSV file on sales data](https://github.com/v0dro/daru/blob/master/spec/fixtures/sales-funnel.csv). -![/assets//images/daru2/pivot_table_data.png][Data For Pivot Table Demo] +![Data For Pivot Table Demo](/assets/images/daru2/pivot_table_data.png) To look at the data from the point of view of the manager and rep: @@ -359,7 +359,7 @@ To look at the data from the point of view of the manager and rep: sales.pivot_table index: [:manager, :rep] ``` -![/assets//images/daru2/pivot_table_index.png][Data Pivoted on Index Only.] +![Data Pivoted on Index Only.](/assets/images/daru2/pivot_table_index.png) You can see that the pivot table has summarized the data and grouped it according to the manager and representative. @@ -370,7 +370,7 @@ To see the sales broken down by the products: sales.pivot_table(index: [:manager,:rep], values: :price, vectors: [:product], agg: :sum) ``` -![/assets//images/daru2/pivoted_data.png][Data Pivoted to Reflect Sales] +![Data Pivoted to Reflect Sales](/assets/images/daru2/pivoted_data.png) ## Compatibility with statsample diff --git a/_posts/2015-07-31-analysis-of-time-series-in-daru.markdown b/_posts/2015-07-31-analysis-of-time-series-in-daru.markdown index 70d8bad..fc58ced 100644 --- a/_posts/2015-07-31-analysis-of-time-series-in-daru.markdown +++ b/_posts/2015-07-31-analysis-of-time-series-in-daru.markdown @@ -25,7 +25,7 @@ rng = Distribution::Normal.rng index = Daru::DateTimeIndex.date_range(:start => '2012-4-2', :periods => 1000, :freq => 'D') vector = Daru::Vector.new(1000.times.map {rng.call}, index: index) ``` -![/assets//images/daru_time_series/simple_vector.png][A Simple Vector indexed on DateTimeIndex] +![A Simple Vector indexed on DateTimeIndex](/assets/images/daru_time_series/simple_vector.png) In the above code, the `DateTimeIndex.date_range` function is creating a `DateTimeIndex` starting from a particular date and spanning for 1000 periods, with a frequency of 1 day between period. For a complete coverage of DateTimeIndex see [this]() notebook. For an introduction to the date offsets used by daru see [this blog post](http://v0dro.github.io/blog/2015/07/27/date-offsets-in-daru/). @@ -72,7 +72,7 @@ rolling = vector.rolling_mean 60 rolling.tail ``` -![/assets//images/daru_time_series/rolling_mean.png][Rolling Mean Tail] +![Rolling Mean Tail](/assets/images/daru_time_series/rolling_mean.png) This time series can be very easily plotted with its rolling mean by using the [GnuplotRB](https://github.com/dilcom/gnuplotrb) gem: @@ -86,7 +86,7 @@ GnuplotRB::Plot.new( [rolling, with: 'lines', title: 'Rolling Mean']) ``` -![/assets//images/daru_time_series/cumsum_rolling_line_graph.png][Line Graph of Rolling mean and cumsum] +![Line Graph of Rolling mean and cumsum](/assets/images/daru_time_series/cumsum_rolling_line_graph.png) These methods are also available on DataFrame, which results in calling them on each of numeric vectors: @@ -103,7 +103,7 @@ df = Daru::DataFrame.new({ c: 1000.times.map { rng.call } }, index: index) ``` -![/assets//images/daru_time_series/dataframe.png][DateTime indexed DataFrame] +![DateTime indexed DataFrame](/assets/images/daru_time_series/dataframe.png) In a manner similar to that done with Vectors above, we can easily plot each Vector of the DataFrame with GNU plot: @@ -124,7 +124,7 @@ r_sum.each_vector_with_index do |vec,n| end GnuplotRB::Multiplot.new(*plots, layout: [3,1], title: 'Rolling sums') ``` -![/assets//images/daru_time_series/dataframe_plot.png][Plotting the DataFrame] +![Plotting the DataFrame](/assets/images/daru_time_series/dataframe_plot.png) ## Usage with statsample-timeseries diff --git a/_posts/2016-07-13-my-tryst-with-python.markdown b/_posts/2016-07-13-my-tryst-with-python.markdown index d6ad718..ac531b4 100644 --- a/_posts/2016-07-13-my-tryst-with-python.markdown +++ b/_posts/2016-07-13-my-tryst-with-python.markdown @@ -74,7 +74,7 @@ while all_elements_have_not_been_checked ``` This GIF from [Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort) explains it pretty well: -![/assets//images/tryst_with_python/insertion_sort.gif][Insertion sort] +![Insertion sort](/assets/images/tryst_with_python/insertion_sort.gif) Here's my python script. Python experts are welcome to suggest edits to make it faster/smaller. ``` python diff --git a/_posts/2016-11-24-gsoc-2016-wrap-up-for-sciruby.markdown b/_posts/2016-11-24-gsoc-2016-wrap-up-for-sciruby.markdown index 3ff23ab..d0dde6b 100644 --- a/_posts/2016-11-24-gsoc-2016-wrap-up-for-sciruby.markdown +++ b/_posts/2016-11-24-gsoc-2016-wrap-up-for-sciruby.markdown @@ -30,12 +30,12 @@ The GSOC 2016 mentor's summit was fantastic. It was great meeting all the contri Here are some photos that I took at the summit: -![/assets//images/gsoc_summit/1.JPG][ID card] +![ID card](/assets/images/gsoc_summit/1.JPG) -![/assets//images/gsoc_summit/2.JPG][A visit to the Computer History Museum] +![A visit to the Computer History Museum](/assets/images/gsoc_summit/2.JPG) -![/assets//images/gsoc_summit/3.JPG][The (now discontinued) self driving car] +![ self driving car](/assets/images/gsoc_summit/3.JPG) -![/assets//images/gsoc_summit/4.JPG][Chocolate table at the GSOC summit] +![Chocolate table at the GSOC summit](/assets/images/gsoc_summit/4.JPG) -![/assets//images/gsoc_summit/5.JPG][Attendees from India] +![Attendees from India](/assets/images/gsoc_summit/5.JPG) diff --git a/_posts/migrate.rb b/_posts/migrate.rb index 9c844b1..aeb1665 100644 --- a/_posts/migrate.rb +++ b/_posts/migrate.rb @@ -7,32 +7,32 @@ new_file = "" string.each_line do |line| - if line.match(/{% img/) || line.match(/{%img/) + if line.match(/{% img/) || line.match(/{%img/) || line.match(/!\[.*\][\[\(][^\/]/) if line.match(/(\/.*\.JPG)/) img_fname = line.match(/(\/.*\.JPG)/)[1] - img_label = line.match(/['"](.*)['"]/)[1] + img_label = line.match(/[\w\s']+[.'!%}\]\)]+$/) puts "fname: #{img_fname} label: #{img_label}." new_file << "![/assets/#{img_fname}][#{img_label}]\n" elsif line.match(/(\/.*\.gif)/) img_fname = line.match(/(\/.*\.gif)/)[1] puts line - img_label = line.match(/['"](.*)['"]/)[1] + img_label = line.match(/[\w\s']+[.'!%}\]\)]+$/) puts "fname: #{img_fname} label: #{img_label}." - new_file << "![/assets/#{img_fname}][#{img_label}]\n" + new_file << "![#{img_label}](/assets/#{img_fname})\n" elsif line.match(/(\/.*\.png)/) img_fname = line.match(/(\/.*\.png)/)[1] puts line - img_label = line.match(/['"](.*)['"]/) + img_label = line.match(/[\w\s']+[.'!%}\]\)]+$/) if img_label - img_label = line.match(/['"](.*)['"]/)[1] + img_label = line.match(/[\w\s']+[.'!%}\]\)]+$/)[1] else img_label = "label" end puts "fname: #{img_fname} label: #{img_label}." - new_file << "![/assets/#{img_fname}][#{img_label}]\n" + new_file << "![#{img_label}](/assets/#{img_fname})\n" end else new_file << line