class Asciidoctor::Standoc::ToCInlineMacro

Public Instance Methods

process(parent, _target, attrs) click to toggle source
# File lib/asciidoctor/standoc/macros.rb, line 222
def process(parent, _target, attrs)
  out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
  content = CSV.parse_line(out).map do |x|
    x.sub!(/^(["'])(.+)\1/, "\\2")
    m = /^(.*?)(:\d+)?$/.match(x)
    %{<toc-xpath depth='#{m[2]&.sub(/:/, '') || 1}'>#{m[1]}</toc-xpath>}
  end.join
  "<toc>#{content}</toc>"
end