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

Latex: Bold inside tt fails, tt inside bold works #7525

Closed
johnwhitington opened this issue Aug 24, 2021 · 3 comments · Fixed by #8129
Closed

Latex: Bold inside tt fails, tt inside bold works #7525

johnwhitington opened this issue Aug 24, 2021 · 3 comments · Fixed by #8129

Comments

@johnwhitington
Copy link

Explain the problem.

The following file:

\usepackage{beramono}
\documentclass[]{book}
\begin{document}
\texttt{\textbf{bold1}}
\textbf{\texttt{bold2}}
\end{document}

generates the following HTML:

<p><code>bold1</code> <strong><code>bold2</code></strong></p>

This is wrong, because both words should be bold. The standard tex tt font has no bold variant, which is probably why this bug was not noticed.

Pandoc version?

orge:mwe john$ pandoc --version
pandoc 2.14.0.1
Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.10.5.1,
citeproc 0.4, ipynb 0.1.0.1

Command line:

pandoc mwe.tex -o mwe.html
@jgm
Copy link
Owner

jgm commented Aug 24, 2021

Well, the issue is that pandoc's internal document model for Code inlines (which we use for texttt) doesn't allow any formatting inside. This affects other formats as well, e.g.

% pandoc -f html -t native
<code><b>hi</b></code>
^D
[Plain [Code ("",[],[]) "hi"]]

@jgm
Copy link
Owner

jgm commented Aug 24, 2021

The best we could do would be to parse

\texttt{\textbf{bold1}}

as Strong [Code "bold1"], pushing the inner formatting out to the outside (this might also require breaking into several Code elements with different formatting, in some cases).

@johnwhitington
Copy link
Author

Thanks for the explanation. I have been following such an algorithm manually, converting for example:

\texttt{\textbf{if} x = 1 \textbf{then} 0 \textbf{else} x / 2}

to

\textbf{\texttt{if}}\texttt{ x = 1 }\textbf{\texttt{then}}\texttt{ 0 }\textbf{\texttt{else}}\texttt{ x / 2}

and it certainly takes a lot of typing! So, if this could be added to the feature request pile, that would be great.

@jgm jgm closed this as completed in #8129 Jun 20, 2022
ebobrow added a commit to ebobrow/pandoc that referenced this issue Jul 5, 2022
move formatting from inside inline code elements to the outside in order
to retain formatting
ebobrow added a commit to ebobrow/pandoc that referenced this issue Jul 6, 2022
move formatting from inside inline code elements to the outside in order
to retain formatting
jgm pushed a commit that referenced this issue Jul 6, 2022
Move formatting from inside inline code elements to the outside in order
to retain formatting.
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.

2 participants