Module: Quby::Compiler::Services::TextTransformation
- Included in:
- MarkdownParser
- Defined in:
- lib/quby/compiler/services/text_transformation.rb
Constant Summary collapse
- LINK_URL_REGEX =
Modal pop up window link: ~~url~~link_body~~
/\~\~(?<url>.+?)\~\~(?<link_content>.+?)\~\~/
- TEXT_VAR_REGEX =
Textvars: Replace {var_name} with <span class=‘textvar’ textvar=‘var_name’></span>
/\{\{(?<text_var>.+?)\}\}/
Instance Method Summary collapse
- #link_html(url, link_content) ⇒ Object
- #textvar_html(var_name) ⇒ Object
-
#transform_special_text(text) ⇒ Object
to eventually replace maruku_extensions.rb this helper transforms ~~ links and vars} into html.
Instance Method Details
#link_html(url, link_content) ⇒ Object
20 21 22 |
# File 'lib/quby/compiler/services/text_transformation.rb', line 20 def link_html(url, link_content) "<a href='#' onclick='modalFrame(\"#{url}\");'>#{link_content}</a>" end |
#textvar_html(var_name) ⇒ Object
24 25 26 |
# File 'lib/quby/compiler/services/text_transformation.rb', line 24 def textvar_html(var_name) "<span class='textvar' textvar='#{var_name}'>{{#{var_name}}}</span>" end |
#transform_special_text(text) ⇒ Object
to eventually replace maruku_extensions.rb this helper transforms ~~ links and vars} into html
15 16 17 18 |
# File 'lib/quby/compiler/services/text_transformation.rb', line 15 def transform_special_text(text) text.gsub(LINK_URL_REGEX) { link_html($~[:url], $~[:link_content]) } .gsub(TEXT_VAR_REGEX) { textvar_html($~[:text_var]) } end |