lib/md2man/roff.rb in md2man-1.3.1 vs lib/md2man/roff.rb in md2man-1.3.2

- old
+ new

@@ -40,11 +40,12 @@ def normal_paragraph text "\n.PP\n#{text}\n" end def block_code code, language - block_quote "\n.nf\n#{super.chomp}\n.fi\n" + code = escape_backslashes(super) + block_quote "\n.nf\n#{code.chomp}\n.fi\n" end def block_quote quote "\n.PP\n.RS\n#{remove_leading_pp(quote).chomp}\n.RE\n" end @@ -152,13 +153,14 @@ def superscript text warn "md2man/roff: superscript not implemented: #{text.inspect}" end def codespan code + code = escape_backslashes(super) # NOTE: this double font sequence gives us the best of both worlds: # man(1) shows it in bold and `groff -Thtml` shows it in monospace - "\\fB\\fC#{super}\\fR" + "\\fB\\fC#{code}\\fR" end def link link, title, content content + if link =~ /^mailto:/ @@ -199,9 +201,13 @@ warn "md2man/roff: entity not implemented: #{text.inspect}" end end private + + def escape_backslashes text + text.gsub(/\\/, '\&\&') + end def remove_leading_pp text text.sub(/\A\n\.PP\n/, '') end