Class: Banzai::Filter::FrontMatterFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/front_matter_filter.rb

Instance Method Summary collapse

Instance Method Details

#callObject


6
7
8
9
10
11
12
13
14
# File 'lib/banzai/filter/front_matter_filter.rb', line 6

def call
  lang_mapping = Gitlab::FrontMatter::DELIM_LANG

  html.sub(Gitlab::FrontMatter::PATTERN) do |_match|
    lang = $~[:lang].presence || lang_mapping[$~[:delim]]

    ["```#{lang}", $~[:front_matter], "```", "\n"].join("\n")
  end
end