File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ Jekyll ::Hooks . register :pages , :pre_render do |page , payload |
2+ INLINE_LINK_REGEX = %r!(\[ (?:[^\[ \] \\ ]|\\ .|\g <1>)*\] )\( \s *(/[^)\s ]*)([^)]*?)\) ! . freeze
3+ REFERENCE_LINK_REGEX = %r!^\s *(\[ (?:[^\[ \] \\ ]*|\\ .)+\] :) (/\S +)(.*)$! . freeze
4+ LINK_REGEX = %r!#{ INLINE_LINK_REGEX } |#{ REFERENCE_LINK_REGEX } ! . freeze
5+
6+ site = payload [ "site" ]
7+ baseurl = site . baseurl
8+ page . content = page . content . gsub ( LINK_REGEX ) do |original |
9+ matches = Regexp . last_match
10+ inline_text = matches [ 1 ] # [foo]
11+ inline_url = matches [ 2 ] # /bar
12+ inline_title = matches [ 3 ] # "baz"
13+ ref_tag = matches [ 4 ] # [f]:
14+ ref_url = matches [ 5 ] # /bar
15+ ref_title = matches [ 6 ] # "baz"
16+
17+ if inline_text
18+ "#{ inline_text } (/#{ baseurl } #{ inline_url } #{ inline_title } )"
19+ else
20+ "#{ ref_tag } /#{ baseurl } #{ ref_url } #{ ref_title } "
21+ end
22+ end
23+ end
You can’t perform that action at this time.
0 commit comments