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

Line breaks inside <code>...</code> elements with HTML autowrap enabled #7858

Closed
mtov opened this issue Jan 20, 2022 · 5 comments
Closed

Line breaks inside <code>...</code> elements with HTML autowrap enabled #7858

mtov opened this issue Jan 20, 2022 · 5 comments

Comments

@mtov
Copy link

mtov commented Jan 20, 2022

In pandoc 2.17.0.1, it seems autowrap is turned on by default for html output.

However, this generates undesirable line breaks when the wrapping occurs inside a <code> section used in the middle of a paragraph.

Therefore, I'm wondering if it might be possible to avoid automatic line breaks being inserted between <code> tags.

(context: I faced this problem in a markdown document, where in a paragraph I mention: cd directory-name. And now pandoc is inserting a line breaking after cd).

Thanks!

@mtov mtov added the bug label Jan 20, 2022
@mb21
Copy link
Collaborator

mb21 commented Jan 20, 2022

You're only talking about inline code elements, right? There is no <pre in the HTML output? If so, that's unlikely to be related to the line-break changes as whitespace is non-semantic in HTML (with the exception of inside pre elements).

But you could apply some CSS like:

p code {
  white-space: nowrap;
}

@mtov
Copy link
Author

mtov commented Jan 20, 2022

Thanks for the answer, mb21!

I applied the CSS you suggested and it worked!

(it seems the problem is somehow caused by the CSS framework I´m using: minicss).

@mb21 mb21 added status:resolved? Feedback requested: please either close the issue or describe why the solution is insufficient. and removed bug labels Jan 20, 2022
@jgm
Copy link
Owner

jgm commented Jan 20, 2022

As it turns out, we have

code{white-space: pre-wrap;}

in the default template. So you're right, we need to add some code to ensure that line breaks aren't inserted in HTML code during wrapping.

@jgm jgm added format:HTML writer and removed status:resolved? Feedback requested: please either close the issue or describe why the solution is insufficient. labels Jan 20, 2022
@jgm
Copy link
Owner

jgm commented Jan 20, 2022

relevant commits
14b8aa8
and from the old pandoc-templates repo
9601cc5

commit 9601cc502644458c7ddf71394f8e4be74c464420
Author: John MacFarlane <fiddlosopher@gmail.com>
Date:   Fri Jan 4 23:01:14 2013 -0800

    Added css to preserve space in <code> tags.
    
    Thanks to Dirk Laurie.

So it seems that this goes back to 2013, prompted by:
https://groups.google.com/g/pandoc-discuss/c/89lwtb8RcRA/m/Pa3YywlCay8J

@jgm
Copy link
Owner

jgm commented Jan 20, 2022

Demo:

 % pandoc -s -o my.html
`neuth asontue stheuosnt aeosunth asnoetuh asneotuh snatehou snatoehu sntahe ousntahoe unstaheou sntaheou aoeu sthoeu sntaoeusnth ansoetuhs atoeuh saonteu`
^D

@jgm jgm added the bug label Jan 20, 2022
@jgm jgm closed this as completed in ef8135b Jan 20, 2022
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