Class: Jekyll::AutoRelative
- Inherits:
-
Object
- Object
- Jekyll::AutoRelative
- Defined in:
- lib/jekyll-auto-relative.rb
Constant Summary collapse
- INLINE_LINK_REGEX =
/\[((?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?)\]\(\s*(?:<\s*(\/(?:\\.|[^\n<>\\])+)>|(\/[^\s\x00-\x1f]*))(?:\s+("(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)))?\s*\)/- INLINE_REFLINK_REGEX =
/^\s*\[((?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?)\]:\s*(?:<\s*(\/(?:\\.|[^\n<>\\])+)>|(\/[^\s\x00-\x1f]*))(?:\s+("(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)))?\s*$/
Class Method Summary collapse
Class Method Details
.convert(doc) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/jekyll-auto-relative.rb', line 13 def convert (doc) text = doc.content text.gsub!(INLINE_LINK_REGEX, '[\1]({{ "\2\3" | relative_url }} \4)') text.gsub!(INLINE_REFLINK_REGEX, '[\1]: {{ "\2\3" | relative_url }} \4') # puts text end |
.needconvert?(doc) ⇒ Boolean
20 21 22 23 24 25 26 27 |
# File 'lib/jekyll-auto-relative.rb', line 20 def needconvert? (doc) site_config = doc.site.config extname_list ||= site_config["markdown_ext"].split(",").map! { |e| ".#{e.downcase}" } extname_list.include?(doc.extname.downcase) && site_config["auto-relative"] != false && doc.data["auto-relative"] != false && (site_config["auto-relative"] == true || doc.data["auto-relative"] == true) end |