lib/asciidoctor/iso/inline.rb in asciidoctor-iso-0.7.0 vs lib/asciidoctor/iso/inline.rb in asciidoctor-iso-0.7.1

- old
+ new

@@ -1,6 +1,7 @@ require "asciidoctor/extensions" +require "HTMLEntities" module Asciidoctor module ISO module Inline def refid?(x) @@ -63,11 +64,10 @@ def inline_footnote(node) noko do |xml| @fn_number += 1 xml.fn **{ reference: @fn_number } do |fn| fn.p { |p| p << node.text } - footnote_style(node, node.text) end end.join("\n") end def inline_break(node) @@ -83,20 +83,32 @@ def thematic_break(_node) noko { |xml| xml.hr }.join("\n") end + def stem_parse(text, xml) + if /&lt;([^:>&]+:)?math(\s+[^>&]+)?&gt; | + <([^:>&]+:)?math(\s+[^>&]+)?>/x.match? text + math = HTMLEntities.new.encode(text, :basic, :hexadecimal). + gsub(/&amp;gt;/, ">").gsub(/\&amp;lt;/, "<").gsub(/&amp;amp;/, "&"). + gsub(/&gt;/, ">").gsub(/&lt;/, "<").gsub(/&amp;/, "&") + xml.stem math, **{ type: "MathML" } + else + xml.stem text, **{ type: "AsciiMath" } + end + end + def inline_quoted(node) noko do |xml| case node.type when :emphasis then xml.em node.text when :strong then xml.strong node.text when :monospaced then xml.tt node.text when :double then xml << "\"#{node.text}\"" when :single then xml << "'#{node.text}'" when :superscript then xml.sup node.text when :subscript then xml.sub node.text - when :asciimath then xml.stem node.text, **{ type: "AsciiMath" } + when :asciimath then stem_parse(node.text, xml) else case node.role # the following three are legacy, they are now handled by macros when "alt" then xml.admitted { |a| a << node.text } when "deprecated" then xml.deprecates { |a| a << node.text }