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

Markdown: problem when rendering source with prepending whitespace #697

Open
thet opened this issue Jan 22, 2020 · 3 comments · May be fixed by #698
Open

Markdown: problem when rendering source with prepending whitespace #697

thet opened this issue Jan 22, 2020 · 3 comments · May be fixed by #698

Comments

@thet
Copy link
Member

thet commented Jan 22, 2020

In a template like this:

<pre class="pat-markdown">
    ${context/text}
</pre>

Where ${context/text} outputs this:

    *This is markdown*

The rendered markdown is:

<pre class="pat-syntax-highlight" tabindex="0"><code data-inner="1">*This is markdown*</code></pre>

Instead of:

<p><em>This is markdown</em></p>
@thet
Copy link
Member Author

thet commented Jan 22, 2020

I just realized that this is actually expected behavior. Prepending text with whitespace starts a code secion in markdown.

Solutions to the problem above is changing the template to:

<pre class="pat-markdown">${context/text/raw}</pre>

or

<pre class="pat-markdown"
    >${context/text/raw}
</pre>

or

<pre class="pat-markdown">
 ${context/text/raw}
</pre>

However, this can easily been overlooked and lead into unnecessary bug hunting.
Not sure how to handle this except by documentation.

thet added a commit that referenced this issue Jan 22, 2020
Fixed an issue with pat-markdown where rendering was not like expected when source has prepending whitespace (#697)
Fixes #697
@thet
Copy link
Member Author

thet commented Jan 22, 2020

@pilz @cornae would like to get your opinions here.

@thet thet changed the title Markdown: fix rendering when source has pre- end appending whitespace Markdown: problem when rendering source with prepending whitespace Jan 22, 2020
@pysailor
Copy link
Contributor

My 2 cents: In OiRA we also use pat-markdown. There we have learned to never prepend whitespace in any <pre> tag, like you show in your solutions 1 and 2 above.

I think it is the very nature of the <pre> tag to render everything literally, including spaces. So I think the problem described here is independent of pat-markdown. The <pre> tag simply needs to be used correctly.

And yes,

a block of text with 4 prepended spaces is rendered as code in markdown.

Even here :)
It seems that you stumbled over a problem that was caused by an unfortunate combination of 2 different effects.

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

Successfully merging a pull request may close this issue.

2 participants