Class: Banzai::Filter::DollarMathPreFilter
- Inherits:
-
HTML::Pipeline::TextFilter
- Object
- HTML::Pipeline::TextFilter
- Banzai::Filter::DollarMathPreFilter
- Defined in:
- lib/banzai/filter/dollar_math_pre_filter.rb
Overview
HTML filter that implements our dollar math syntax, one of three filters: DollarMathPreFilter, DollarMathPostFilter, and MathFilter
Constant Summary collapse
- REGEX =
Display math block: $$ latex math $$
"#{::Gitlab::Regex.markdown_code_or_html_blocks_or_html_comments_untrusted}" \ '|' \ '^\$\$\ *\n' \ '(?P<display_math>' \ '(?:\n|.)*?' \ ')' \ '\n\$\$\ *$' \ .freeze
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/banzai/filter/dollar_math_pre_filter.rb', line 33 def call regex = Gitlab::UntrustedRegexp.new(REGEX, multiline: true) return @text unless regex.match?(@text) regex.replace_gsub(@text) do |match| # change from $$ to ```math if match[:display_math] "```math\n#{match[:display_math]}\n```" else match.to_s end end end |