@@ -198,6 +198,20 @@ def post_exclude(content)
198198 content
199199 end
200200
201+ def get_exclusion ( id )
202+ result = nil
203+ match_data = id . match /<!JEKYLL@(.+)@(.+)>/
204+ unless match_data . nil?
205+ id = match_data [ 2 ] . to_i
206+ result = {
207+ :id => id ,
208+ :marker => match_data [ 0 ] ,
209+ :content => @exclusion_store [ id ]
210+ }
211+ end
212+ result
213+ end
214+
201215 def self . escape_html ( content )
202216 # escape link
203217 content . scan ( /((https?:)?\/ \/ \S +\? [a-zA-Z0-9%\- _=\. &;]+)/ ) do |result |
@@ -241,5 +255,31 @@ def self.make_img_tag(data)
241255 "<img class=\" #{ css_class } \" src=\" #{ body } \" >"
242256 end
243257 end
258+
259+ def self . handle_bang_link (
260+ content ,
261+ url = '(https?:)?\\/\\/.*' ,
262+ title = '("(.*)".*){0,1}' ,
263+ &block
264+ )
265+ # pre-handle reference-style links
266+ regex = /(\[ (.*)\] :\s *(#{ url } \s *#{ title } ))/
267+ content . scan regex do |match_data |
268+ match = match_data [ 0 ]
269+ ref_name = match_data [ 1 ]
270+ ref_value = match_data [ 2 ]
271+ content = content . gsub ( match , '' )
272+ . gsub ( /\! \[ (.*)\] \s *\[ #{ ref_name } \] / ,
273+ "" )
274+ end
275+
276+ # handle inline-style links
277+ regex = /(\! \[ (.*)\] \( .*#{ url } \s *#{ title } \) )/
278+ content . scan regex do |match_data |
279+ url = match_data [ 2 ]
280+ title = match_data [ 6 ]
281+ block . call ( url , title )
282+ end
283+ end
244284 end
245285end
0 commit comments