Module: Markbridge::Renderers::Discourse::HtmlBlockSafety
- Defined in:
- lib/markbridge/renderers/discourse/html_block_safety.rb
Overview
Decides whether a rendered fragment is safe to splice into a
CommonMark HTML block (spec §4.6). Inside such a block the
content passes through as raw HTML; Markdown is only parsed
again across blank lines. Safe output is therefore: a raw HTML
or plain-text fragment without Markdown sigils, or a
\n\n…\n\n wrap — a deliberate Markdown island.
Used by the html_mode contract check that ships in
markbridge/rspec and by this repo's own contract spec.
Class Method Summary collapse
Class Method Details
.safe?(output) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/markbridge/renderers/discourse/html_block_safety.rb', line 23 def self.safe?(output) return true if output.start_with?("\n\n") && output.end_with?("\n\n") !output.match?(MARKDOWN_SIGILS) end |