Class: GovukMarkdown::Preprocessor
- Inherits:
-
Object
- Object
- GovukMarkdown::Preprocessor
- Defined in:
- lib/govuk_markdown/preprocessor.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(document) ⇒ Preprocessor
constructor
A new instance of Preprocessor.
- #inject_details ⇒ Object
- #inject_inset_text ⇒ Object
Constructor Details
#initialize(document) ⇒ Preprocessor
Returns a new instance of Preprocessor.
5 6 7 |
# File 'lib/govuk_markdown/preprocessor.rb', line 5 def initialize(document) @output = document end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
3 4 5 |
# File 'lib/govuk_markdown/preprocessor.rb', line 3 def output @output end |
Instance Method Details
#inject_details ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/govuk_markdown/preprocessor.rb', line 20 def inject_details @output = output.gsub(build_regexp("details")) do summary, details = *construct_details_from(Regexp.last_match(1)) <<~HTML <details class="govuk-details" data-module="govuk-details"> <summary class="govuk-details__summary"> <span class="govuk-details__summary-text"> #{summary} </span> </summary> <div class="govuk-details__text"> #{nested_markdown(details)} </div> </details> HTML end self end |
#inject_inset_text ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/govuk_markdown/preprocessor.rb', line 9 def inject_inset_text @output = output.gsub(build_regexp("inset-text")) do <<~HTML <div class="govuk-inset-text"> #{nested_markdown(Regexp.last_match(1))} </div> HTML end self end |