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

Syntax Highlighting Without Listings Cannot Wrap #2

Closed
tshu-w opened this issue May 17, 2017 · 11 comments
Closed

Syntax Highlighting Without Listings Cannot Wrap #2

tshu-w opened this issue May 17, 2017 · 11 comments

Comments

@tshu-w
Copy link

tshu-w commented May 17, 2017

If I use syntax highlighting without listings. The code cannot wrap just like listings.

test

@Wandmalfarbe
Copy link
Owner

Unfortunately this is a general problem with the verbatim environment and it exists in the default pandoc template as well (see jgm/pandoc#277). It seems that there is currently no way for me to fix this.

  1. You could insert a manual line break.
  2. You could use the listings package for code highlighting with the option --listings. Unfortunately the syntax highlighting will be inferior to the one pandoc generates with the verbatim environment.
  3. You could replace the \begin{verbatim} and \end{verbatim} commands with \begin{spverbatim} and \end{spverbatim}. The package spverbatim seems to handle breaks in verbatim output. You could open a new issue in the pandoc issue tracker suggesting the use of spverbatim.

@tshu-w
Copy link
Author

tshu-w commented May 18, 2017

@Wandmalfarbe Fine, It seems that it's an upstream issue. BTW, thx you advice.

@tshu-w tshu-w closed this as completed May 18, 2017
@tshu-w
Copy link
Author

tshu-w commented May 30, 2017

@Wandmalfarbe yeah, package spverbatim worked fine for handling breaks in verbatim output.
But wonder how to replace verbatim with spverbatim by using some command in latex template?

@Wandmalfarbe
Copy link
Owner

I'm no expert at redefining or modifying LaTeX commands but googled a bit around and found this post https://tex.stackexchange.com/a/309073.

I also think it would be possible to use a custom pandoc filter for replacing \begin{verbatim} with \begin{spverbatim}. You could ask at the pandoc issue tracker for such a filter or suggest the use of spverbatim as the default verbatim environment.

@noraj
Copy link
Contributor

noraj commented Jun 30, 2019

@Wandmalfarbe
Copy link
Owner

@Wandmalfarbe You could use fvextra, see https://stackoverflow.com/questions/20788464/pandoc-doesnt-text-wrap-code-blocks-when-converting-to-pdf#answer-48507868

Yes, I actually saw that comment (jgm/pandoc#4302 (comment)) in the pandoc issue tracker but forgot to implement it. Thank you for reminding me 😄.

Or see this manual way to do with xcolor https://tex.stackexchange.com/questions/323329/pandoc-code-blocks-in-markdown-with-very-long-lines-get-cut-off-when-outputting

This example doesn't actually use xcolor to break long lines in code blocks. It uses listings with the options

breaklines=true,
breakatwhitespace=true,
breakautoindent=true,

to break long lines. This only applies when compiling your pandoc document with the option --listings and has been implemented in Eisvogel since day zero.

@Wandmalfarbe Wandmalfarbe reopened this Jul 1, 2019
@noraj
Copy link
Contributor

noraj commented Jul 1, 2019

Yes, I actually saw that comment (jgm/pandoc#4302 (comment)) in the pandoc issue tracker but forgot to implement it. Thank you for reminding me smile.

You're welcome.

This example doesn't actually use xcolor to break long lines in code blocks. It uses listings with the options

breaklines=true,
breakatwhitespace=true,
breakautoindent=true,

to break long lines. This only applies when compiling your pandoc document with the option --listings and has been implemented in Eisvogel since day zero.

My bad I didn't read the code :(

@noraj
Copy link
Contributor

noraj commented Jul 1, 2019

That was quick, I need to test that :)

@noraj
Copy link
Contributor

noraj commented Jul 1, 2019

@Wandmalfarbe I was able to use a better syntax highlight (noraj/OSCP-Exam-Report-Template-Markdown@486237e) thanks to you :)
I use your LaTeX template for rendering my OSCP markdown template see https://github.com/noraj/OSCP-Exam-Report-Template-Markdown, where I credited your work (if your need to build a gallery section or just because that make you happy to hear that people use your great template).

@noraj
Copy link
Contributor

noraj commented Jul 1, 2019

@Wandmalfarbe Still a small issue: When the wrapped line is the last line of a page:

image

I goes out of the box.

@Wandmalfarbe
Copy link
Owner

@Wandmalfarbe I was able to use a better syntax highlight (noraj/OSCP-Exam-Report-Template-Markdown@486237e) thanks to you :)

It always makes me happy to hear about people using my work and appreciating what I make! That readme looks great!

Still a small issue: When the wrapped line is the last line of a page:

Please open a new issue so we don't spam this one.

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

No branches or pull requests

3 participants