Search code examples
manpageasciidocasciidoctor

How to escape double backslashes so I can get "\\" in man page?


For example, my foo.adoc file looks like this:

= foo(1)

== NAME

foo - hello world

== SYNOPSIS

foo ...

== DESCRIPTION

\\ | \\\ | \\\\ | {backslash}{backslash}

But after asciidoctor -b manpage foo.adoc and man ./foo.1 would produce:

FOO(1)                                                    FOO(1)

NAME
       foo - hello world

SYNOPSIS
       foo ...

DESCRIPTION
       \ | \\(rs | \\(rs | \

                           2019-07-03                     FOO(1)

So how should I escaple to get double backslashes (\\) in man page?


Solution

  • It's actually a bug in Asciidoctor:

    The regular expression that is used to preserve literal backslashes is malfunctioning. The backslash in the content is somehow getting mixed up with the backslash in the replacement. And we're also missing a test.

    -- @mojavelinux

    https://github.com/asciidoctor/asciidoctor/issues/3456

    It should be fixed in the next release (2.0.11) of Asciidoctor.