Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Ampersand in Code Blocks in ms Output #6505

Closed
tkurtbond opened this issue Jul 5, 2020 · 2 comments · Fixed by #6513
Closed

Missing Ampersand in Code Blocks in ms Output #6505

tkurtbond opened this issue Jul 5, 2020 · 2 comments · Fixed by #6513

Comments

@tkurtbond
Copy link

Missing Ampersand in Code Blocks in ms Output

Using pandoc version

pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2

Here's some ReStructuredText (file ma.rst) input that has a code block
in it:

Missing Ampersand in Code Block -ms output
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Here's a code block containing ReStructuredText:

.. code::

   .. container:: for-format ms

      .. figure:: davesmapper-2017-04-10-caves-4-numbered.eps
         :alt: Map of Bandit's Cave

      Map of Bandit's Cave

   .. container:: for-format html latex context epub

      .. figure:: davesmapper-2017-04-10-caves-4-numbered.png
         :alt: Map of Bandit's Cave

         Map of Bandit's Cave

How's that look?

Using the command line pandoc -r rst -w ms -o ma-rst.ms ma.rst, here's
the ms output from it:

.SH 1
Missing Ampersand in Code Block -ms output
.pdfhref O 1 "Missing Ampersand in Code Block -ms output"
.pdfhref M "missing-ampersand-in-code-block--ms-output"
.LP
Here\[aq]s a code block containing ReStructuredText:
.IP
.nf
\f[C]
.. container:: for-format ms

   .. figure:: davesmapper-2017-04-10-caves-4-numbered.eps
      :alt: Map of Bandit\[aq]s Cave

   Map of Bandit\[aq]s Cave

\&.. container:: for-format html latex context epub

   .. figure:: davesmapper-2017-04-10-caves-4-numbered.png
      :alt: Map of Bandit\[aq]s Cave

      Map of Bandit\[aq]s Cave
\f[]
.fi
.LP
How\[aq]s that look?

See the first line that starts with .. container::? That line should
start with \& so it isn't interpreted as an roff command. As it
is, when you build the PDF output from output that line disappears
entirely with no warning to the user. (The default for roff
processors like groff is to ignore unknown commands.)

See the second line that starts with .. container::? That line
does start with \&. It makes it through fine. The other lines
whose first non-whitespace character is . make it through fine because
to make it a roff command the first character on the line has to be
a period.

Oddly enough, it doesn't happen with man output. Using the command
pandoc -r rst -w man -o ma-rst.man ma.rst here's the man output from
it:

.SH Missing Ampersand in Code Block -ms output
.PP
Here\[aq]s a code block containing ReStructuredText:
.IP
.nf
\f[C]
\&.. container:: for-format ms

   .. figure:: davesmapper-2017-04-10-caves-4-numbered.eps
      :alt: Map of Bandit\[aq]s Cave

   Map of Bandit\[aq]s Cave

\&.. container:: for-format html latex context epub

   .. figure:: davesmapper-2017-04-10-caves-4-numbered.png
      :alt: Map of Bandit\[aq]s Cave

      Map of Bandit\[aq]s Cave
\f[R]
.fi
.PP
How\[aq]s that look?

The first line that starts with .. container:: has a \& at the
beginning.

@jgm
Copy link
Owner

jgm commented Jul 6, 2020

The man writer contains this code

  ((case T.uncons str of
    Just ('.',_) -> literal "\\&"
    _            -> mempty) <>

in the handler for CodeBlock. We need something like that in the ms writer.

@brisad
Copy link
Contributor

brisad commented Jul 8, 2020

Hi! I'd be happy to try to fix this one.

brisad added a commit to brisad/pandoc that referenced this issue Jul 8, 2020
If a line of ms code block output starts with a period (.), it should
be prepended by '\&' so that it is not interpreted as a roff command.

Fixes jgm#6505
brisad added a commit to brisad/pandoc that referenced this issue Jul 8, 2020
If a line of ms code block output starts with a period (.), it should
be prepended by '\&' so that it is not interpreted as a roff command.

Fixes jgm#6505
@jgm jgm closed this as completed in #6513 Jul 13, 2020
jgm pushed a commit that referenced this issue Jul 18, 2020
If a line of ms code block output starts with a period (.), it should
be prepended by '\&' so that it is not interpreted as a roff command.

Fixes #6505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants