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 around multiline code blocks? #207

Open
kevinoid opened this issue Nov 8, 2018 · 2 comments · May be fixed by #208
Open

Line breaks around multiline code blocks? #207

kevinoid opened this issue Nov 8, 2018 · 2 comments · May be fixed by #208

Comments

@kevinoid
Copy link
Contributor

kevinoid commented Nov 8, 2018

Thanks for the support in #206! One other issue I noticed while working on that:

In the Discord web interface, multiline code blocks are rendered as <pre><code>text</code></pre>. Since <pre> is a block-level element, the text is always displayed on its own line(s). This plugin currently renders multiline code blocks as <br/><span>text</span> which behaves differently in a few cases:

  • The line break before the text causes an extra blank line in messages containing only code. This might be intentional, since it starts the code on a line not preceded by the sender username in Pidgin.
  • If there is text after the multiline code block, they will run together. So the message 1```2```3 appears as
    1
    2
    3
    in the Discord web client and
    1
    23
    in libpurple-based clients.

I experimented with changing the code to use <pre><code> as the Discord web client does, but it didn't behave correctly in Pidgin. Adding display: block to style also did not behave correctly. It would be possible to add <br/> to the beginning/end only when additional text is present (including or excluding whitespace).

What do you guys think?

@alyssarosenzweig
Copy link
Contributor

alyssarosenzweig commented Nov 8, 2018 via email

kevinoid added a commit to kevinoid/purple-discord that referenced this issue 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.

Fixes: EionRobb#207

Signed-off-by: Kevin Locke <[email protected]>
@kevinoid kevinoid linked a pull request Nov 9, 2018 that will close this issue
@kevinoid
Copy link
Contributor Author

kevinoid commented Nov 9, 2018

I submitted pull request #208 which adds <br/> to the end as necessary, but I just realized that there are several additional differences with the web-based Discord client (including one that I introduced in #206 for how single-word info strings are handled). How would you feel about a pull request with refactoring to support unit testing?

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