summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-10-30 18:38:08 -0600
committerDan Allen <dan.j.allen@gmail.com>2020-10-30 18:38:08 -0600
commitb765ec86a6367d871d8ac4e223ecb4dced18d975 (patch)
treede5c7059fff23a29f232448e98f71d1e2ddb86a3
parented32e90ae640ed5a1de7c290142a6537e5c7dc09 (diff)
use positive instead of negative match to escape literal backslash in manpage output
-rw-r--r--lib/asciidoctor/converter/manpage.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/asciidoctor/converter/manpage.rb b/lib/asciidoctor/converter/manpage.rb
index 4a25790b..e0c063f2 100644
--- a/lib/asciidoctor/converter/manpage.rb
+++ b/lib/asciidoctor/converter/manpage.rb
@@ -15,7 +15,7 @@ class Converter::ManPageConverter < Converter::Base
ESC_BS = %(#{ESC}\\) # escaped backslash (indicates troff formatting sequence)
ESC_FS = %(#{ESC}.) # escaped full stop (indicates troff macro)
- LiteralBackslashRx = /(\A|[^#{ESC}\\])(\\+)/
+ LiteralBackslashRx = /\A\\|(#{ESC})?\\/
LeadingPeriodRx = /^\./
EscapedMacroRx = /^(?:#{ESC}\\c\n)?#{ESC}\.((?:URL|MTO) "#{CC_ANY}*?" "#{CC_ANY}*?" )( |[^\s]*)(#{CC_ANY}*?)(?: *#{ESC}\\c)?$/
MockBoundaryRx = /<\/?BOUNDARY>/
@@ -700,7 +700,7 @@ allbox tab(:);'
str = str.tr_s WHITESPACE, ' '
end
str = str.
- gsub(LiteralBackslashRx) { %[#{$1}#{'\\(rs' * $2.length}] }. # literal backslash (not a troff escape sequence)
+ gsub(LiteralBackslashRx) { $1 ? $& : '\\(rs' }. # literal backslash (not a troff escape sequence)
gsub(EllipsisCharRefRx, '...'). # horizontal ellipsis
gsub(LeadingPeriodRx, '\\\&.'). # leading . is used in troff for macro call or other formatting; replace with \&.
# drop orphaned \c escape lines, unescape troff macro, quote adjacent character, isolate macro line