debian-mirror-gitlab/lib/gitlab/asciidoc/html5_converter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
858 B
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
require 'asciidoctor'
module Gitlab
module Asciidoc
2019-09-30 21:07:59 +05:30
class Html5Converter < (Asciidoctor::Converter.for 'html5')
2019-09-04 21:01:54 +05:30
register_for 'gitlab_html5'
2019-09-30 21:07:59 +05:30
def convert_stem(node)
2019-09-04 21:01:54 +05:30
return super unless node.style.to_sym == :latexmath
%(<pre#{id_attribute(node)} data-math-style="display"><code>#{node.content}</code></pre>)
end
2019-09-30 21:07:59 +05:30
def convert_inline_quoted(node)
2019-09-04 21:01:54 +05:30
return super unless node.type.to_sym == :latexmath
%(<code#{id_attribute(node)} data-math-style="inline">#{node.text}</code>)
end
2021-02-22 17:27:13 +05:30
def convert_inline_anchor(node)
node.id = "user-content-#{node.id}" if node.id && !node.id.start_with?('user-content-')
super(node)
end
2019-09-04 21:01:54 +05:30
private
def id_attribute(node)
node.id ? %( id="#{node.id}") : nil
end
end
end
end