-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
trailing CR in </pre> in: Renderer.prototype.code() #449
Comments
In my experience, a single newline at the end of the |
I wrote some tests to back-track my code and determine exactly where this problem was introduced. It is partially the result of my doing something "weird". Within the "highlight" callback function to pre-process code blocks.. I was conditionally passing the code to highlight.js ..which rewrites the HTML text.. adding spans and classes and such. However, the one issue I found was that all of the color schemes (css themes) assume that the parent container (ie: the So, it's my own fault for adding a block element.. which causes the trailing CR to occur on a new line.. creating the visible space I was seeing. I suppose this is an edge case.. up to you if it's worth considering. I'm fairly new to github, so I'm not sure if I can attach an .html file containing some test code that very clearly illustrates the issue I'm seeing; I don't seem to be able to do so.. shame. I apologize if this was a nuisance post. I do appreciate the fast response. I've tried to copy the contents of the test file into this message; the only edit I made was to "escape" the code blocks in the embedded markdown.
|
I believe the newline is there for mere sake of readability of the generated html code. Let's hear if @chjj would like to give up a bit of readability in favor of better compatibility. |
My example below is incorrect. The newline marked adds does not add space in the browser. I'm leaving my mistaken example and comment here only for history.
|
<html>
<style>pre { background-color: #eee; border: 1px solid blue; }</style>
<body>
<pre><code>Hello
</code></pre> <==== THIS
<pre><code>Hello</code></pre>
</body>
</html> That's not just a trailing newline. That's a newline plus 4 blanks. |
So sorry, my mistake. I had generated the HTML by hand and forgot to remove the indenting. It turns out the real issue is with a separate documentation tool we are using which changes the HTML that marked generates. The tool is adding a newline between the closing Thanks for the fast feedback. |
No problem! |
minor fix/suggestion:
dev (
lib/marked.js
):search = '\n</code></pre>
replace = '</code></pre>
prod (
marked.min.js
):search = "\n</code></pre>
replace = "</code></pre>
notes:
<pre>
, so it adds visible white-space.The text was updated successfully, but these errors were encountered: