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

Properly break long HTML lines when converting from Markdown to PDF #6069

Closed
Noki opened this issue Jan 15, 2020 · 2 comments
Closed

Properly break long HTML lines when converting from Markdown to PDF #6069

Noki opened this issue Jan 15, 2020 · 2 comments

Comments

@Noki
Copy link

Noki commented Jan 15, 2020

If you have very long words in an markdown codeblock and try to convert it to an PDF, the breaklines and breakanywhere directives do not work as expected.

Output:

image

Expected Output:

The long URL should be broken in between, and have an indicator showing that it's the same line. The line break should respect the page margin.

Pandoc Version:

pandoc 2.9.1.1
Compiled with pandoc-types 1.20, texmath 0.12, skylighting 0.8.3
Default user data directory: C:\Users\Tobias Schwarz\AppData\Roaming\pandoc
Copyright (C) 2006-2019 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

Steps to reproduce:

Use the attached pandoc.txt with the following commandline:

pandoc -f markdown -o pandoc-test.pdf pandoc-test.txt

pandoc-test.txt

Best regards
Tobias

@jgm
Copy link
Owner

jgm commented Jan 15, 2020

This minimal case shows that the issue is that the \StringTok macro is overriding the breaking behavior. Compile with pdflatex. You'll see the first line broken (without StringTok), the second not. I don't think there's anything pandoc can do about this. It's really a limitation of fvextra. (Indeed, if you replace \StringTok with anything else, say \textbf, it also prevents breaking.)

\documentclass{article}
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

\usepackage{fvextra}
\RecustomVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,commandchars=\\\{\}}

\author{}
\date{}

\begin{document}

\begin{Shaded}
\begin{Highlighting}[]
"https://www.example.com/dgjlb4r7cu0elacgpbdgjlb4r7cu0elacgpb/nwl4858soq59jkq5ijl5sdgjlb4r7cu0elacgpbv56uegqp500gijn7vo1s1jcsnn86an7.jpg"

\StringTok{"https://www.example.com/dgjlb4r7cu0elacgpbdgjlb4r7cu0elacgpb/nwl4858soq59jkq5ijl5sdgjlb4r7cu0elacgpbv56uegqp500gijn7vo1s1jcsnn86an7.jpg"}
\end{Highlighting}
\end{Shaded}


\end{document}

@Noki
Copy link
Author

Noki commented Jan 15, 2020

@jgm Thank you for pointing out that it is an fvextra issue. I opened an issue over there (gpoore/fvextra#11) and will close this issue now.

@Noki Noki closed this as completed Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants