Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Add support for nested <code> tag in <pre> elements #92

Open
bbannier opened this issue Mar 9, 2017 · 4 comments
Open

Add support for nested <code> tag in <pre> elements #92

bbannier opened this issue Mar 9, 2017 · 4 comments
Assignees

Comments

@bbannier
Copy link

bbannier commented Mar 9, 2017

The style for .code uses white-space: nowrap; which causes all line breaks in e.g., preformated code blocks to be ignored. It seems almost any other value than nowrap would have made sense. This makes this style unusable for code blocks.

In below example the code block is displayed on a single line.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <link rel="stylesheet" href="dist/canvas.css" type="text/css" />
</head>
<body>
<pre><code>#include &lt;cstdio&gt;

int main() {
    printf(&quot;Hello, world!\n&quot;);
}</code></pre>
</body>
</html>
@ashenden
Copy link
Contributor

ashenden commented Mar 9, 2017

@bbannier valid. However, in CNVS the expectation is code blocks (not inline code fragments) live inside a <pre>...</pre> element only -- not <pre><code>...</code></pre>.

You can see this in practice here -- http://mesosphere.github.io/cnvs/content/code/

If you have an argument for why you feel it should be <pre><code>...</code></pre>, throw it out there for consideration/discussion. For example, on Github, they follow the <pre><code>...</code></pre> structure, but elsewhere on the web, you'll find just <pre>...</pre> (e.g. http://mediatemple.net/blog/tips/randomizing-svg-shapes/).

@jfurrow @orlandohohmeier opinions?

@bbannier
Copy link
Author

bbannier commented Mar 10, 2017

@ashenden I arrived at above output via pandoc's HTML writer, so it certainly isn't just github using this pattern. Stackoverflow uses the same pattern, https://stackoverflow.com/questions/1642028/what-is-the-operator-in-c.

I cannot make a strong argument for HTML best practices myself, but it seems a style wrapping at all anything in<pre>s would break that tag's intent, https://www.w3.org/TR/html5/grouping-content.html#the-pre-element (see also https://www.w3.org/TR/2011/WD-html5-author-20110809/the-code-element.html which again seems to suggest that wrapping code blocks in <pre><code> is not that weird).

@ashenden
Copy link
Contributor

Sounds good. We'll work in support for both <pre></pre> and <pre><code></code></pre>.

@ashenden ashenden added enhancement and removed bug labels Mar 10, 2017
@ashenden ashenden changed the title Line breaks in code blocks are ignored Add support for nested <code> tag in <pre> elements Mar 10, 2017
@jfurrow
Copy link
Contributor

jfurrow commented Mar 10, 2017

Sorry for the delay, but after reviewing the provided resources, I agree with the consensus here. I think using the white-space: nowrap property assumes too much about the usage of code tags.

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

No branches or pull requests

3 participants