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

Conditionally add break after multiline code block #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kevinoid
Copy link
Contributor

@kevinoid kevinoid commented Nov 9, 2018

In the Discord web client (and presumably others) multiline code blocks are rendered using <pre><code>text</code></pre>. Since <pre> is a block-level element, the text is always displayed on its own line(s). Mimic this behavior by adding a line break when text following the block would appear on the same line. Ignore collapsible white space, as a browser would.

This PR includes a small fix for duplicate markup at the start of multiline code blocks. I can split that into a separate PR if you'd prefer.

Thanks,
Kevin

Fixes: #207

Previously, i was only incremented once for the multiline code block
start marker, which would cause the three it to be interpreted as
multiline-start, inline-start, inline-close.  For example, the message

    ```hello```

would be rendered as

    <br/><span style='font-family: monospace; white-space: pre'><span style='font-family: monospace; white-space: pre'></span>hello</span>

This commit fixes the issue by incrementing i to the end of the start
marker.

Signed-off-by: Kevin Locke <[email protected]>
In the Discord web client (and presumably others) multiline code blocks
are rendered using `<pre><code>text</code></pre>`.  Since `<pre>` is a
block-level element, the text is always displayed on its own line(s).
Mimic this behavior by adding a line break when text following the block
would appear on the same line.  Ignore collapsible white space, as a
browser would.

Fixes: EionRobb#207

Signed-off-by: Kevin Locke <[email protected]>
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 this pull request may close these issues.

Line breaks around multiline code blocks?
1 participant