lib/asciidoctor/latex/node_processors.rb in asciidoctor-latex-1.5.0.4.dev vs lib/asciidoctor/latex/node_processors.rb in asciidoctor-latex-1.5.0.5.dev

- old
+ new

@@ -64,12 +64,22 @@ else '' end end + # normalize the name because it is an id + # and so frequently contains underscores def self.hypertarget(name, text) - "\\hypertarget\{#{name}\}\{#{text}\}" + if text + # text = text.rstrip.chomp + end + if name + "\\hypertarget\{#{name.tex_normalize}\}\{#{text}\}" + else + "\\hypertarget\{'NO-ID'\}\{#{text}\}" + # FIXME: why do we need this branch? + end end end @@ -677,11 +687,11 @@ def sidebar_process title = self.title attr = self.attributes id = attr['id'] if id - content = "\\hypertarget\{#{id}\}\{#{self.content}\}" + content = "\\hypertarget\{#{id}\}\{#{self.content.rstrip}\}" else content = self.content end if title title = $tex.env 'bf', title @@ -717,21 +727,21 @@ "" end end def inline_quoted_process - warn "THIS IS: inline_quoted_process: #{self.type}" if $VERBOSE + # warn "THIS IS: inline_quoted_process: #{self.type}" if $VERBOSE case self.type when :strong "\\textbf\{#{self.text}\}" when :emphasis "\\emph\{#{self.text}\}" when :asciimath output = Asciidoctor.convert( self.text, backend: 'html') output when :monospaced - "\\textt\{#{self.text}\}" + "\\texttt\{#{self.text}\}" when :superscript "$\{\}^{#{self.text}}$" when :subscript "$\{\}_{#{self.text}}$" when :mark @@ -751,12 +761,16 @@ elsif role == "blue" "\\roleblue\{ #{self.text}\}" else # warn "This is inline_quoted_process. I don't understand role = #{role}" if $VERBOSE end + when :literal + "\\texttt\{#{self.text}\}" + when :verse + "\\texttt\{#{self.text}\}" else - "\\unknown\\{#{self.text}\\}" + "\\unknown:#{self.type}\\{#{self.text}\\}" end end def inline_anchor_process @@ -778,11 +792,11 @@ when :link $tex.macro 'href', self.target, self.text when :ref $tex.macro 'label', self.text.gsub(/\[(.*?)\]/, "\\1") when :xref - $tex.macro 'hyperlink', refid, reftext + $tex.macro 'hyperlink', refid.tex_normalize, reftext else # warn "!!".magenta if $VERBOSE end end @@ -829,10 +843,10 @@ end module LaTeX # TeXPostProcess cleans up undesired transformations - # inside the TeX enveronment. Strings + # inside the TeX environment. Strings # &ampp;, &gt;, &lt; are mapped back to # &, >, < and \\ is conserved. module TeXPostProcess def self.match_inline str