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

js: template: Do not strip newlines #857

Merged
merged 2 commits into from
May 5, 2022

Conversation

ix5
Copy link
Member

@ix5 ix5 commented May 3, 2022

Non-discriminatory newline stripping would wrongfully collate pre-formatted (code) blocks.

The newline stripping/trimming was introduced as a workaround because at the time, templates were written in ES6 template literals (${foo}) and left a lot of newlines in rendered HTML output, which lead to failures to convert text to DOM elements using the htmlify helper.

These templates ended up being replaced by ES5 plain string concatenation, which no longer requires the workaround.

Fixes #856

@ix5 ix5 added client (Javascript) client code and CSS bug labels May 3, 2022
@ix5 ix5 added this to the 0.13 milestone May 3, 2022
ix5 added 2 commits May 5, 2022 23:56
Non-discriminatory newline stripping would wrongfully
collate pre-formatted (code) blocks.

The newline stripping/trimming was introduced as a
workaround because at the time, templates were written in
ES6 template literals (`${foo}`) and left a lot of newlines
in rendered HTML output, which lead to failures to convert
text to DOM elements using the `htmlify` helper.

These templates ended up being replaced by ES5 plain string
concatenation, which no longer requires the workaround.

Fixes isso-comments#856
Ensures that isso-comments#856
does not occur again:

> This means that comments containing fenced code blocks -
> which are rendered server-side as
> `<pre><code>some code here\nanother new line</code></pre>` -
> have their `\n` newline characters ignored when the
> client-side JS renders, and so the whole output gets
> rendered on one line. This makes code blocks hard to read.
>
> I'd quite like to keep these newline characters when the
> comment is rendered. I tried just commenting that
> newline-stripping line of code, and everything seems to
> work. Is there a reason for this line being there?
@ix5 ix5 force-pushed the js-template-no-strip-newline branch from 3aec338 to 4abdc29 Compare May 5, 2022 22:20
@ix5 ix5 merged commit 6f42985 into isso-comments:master May 5, 2022
@ix5 ix5 deleted the js-template-no-strip-newline branch May 5, 2022 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug client (Javascript) client code and CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant