Module: Serif::Filters
- Defined in:
- lib/serif/site.rb
Instance Method Summary collapse
- #encode_uri_component(string) ⇒ Object
- #markdown(body) ⇒ Object
- #smarty(text) ⇒ Object
- #strip(input) ⇒ Object
- #xmlschema(input) ⇒ Object
Instance Method Details
#encode_uri_component(string) ⇒ Object
18 19 20 21 |
# File 'lib/serif/site.rb', line 18 def encode_uri_component(string) return "" unless string CGI.escape(string) end |
#markdown(body) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/serif/site.rb', line 28 def markdown(body) renderer = Redcarpet::Markdown.new(Serif::MarkupRenderer, fenced_code_blocks: true) html = renderer.render(body).strip # make sure we aren't overriding unless we need to. # causes the workaround to automatically turn off. if !(renderer.render("a 'quoted' word").include?("’")) # fix the broken single curly quotes by putting them back # as unescaped characters and then re-running the renderer. html.gsub!("'", "'") html = renderer.render(html) end html end |
#smarty(text) ⇒ Object
23 24 25 26 |
# File 'lib/serif/site.rb', line 23 def smarty(text) text.gsub!('`', '\\\\`') Redcarpet::Render::SmartyPants.render(text) end |
#strip(input) ⇒ Object
14 15 16 |
# File 'lib/serif/site.rb', line 14 def strip(input) input.strip end |
#xmlschema(input) ⇒ Object
44 45 46 |
# File 'lib/serif/site.rb', line 44 def xmlschema(input) input.xmlschema end |