question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WYSIWYG error on line breaks in raw HTML

See original GitHub issue

Description

When a hard line break is inserted using raw HTML ( <br> or <br/> tag ), the line break is rendered, but the <br> tag is always displayed, even when the line is not anymore edited!

This is particularly annoying in Markdown table cells where the only way to add explicit line breaks is to use raw HTML.

  • [] Can you reproduce the issue? [x]

Example

Line 1<br>Line 2

Expected behavior:

Line 1 Line 2

Actual behavior:

Line 1<br> Line 2

Versions

  • Mark Text: 1.5.1
  • Operating system: Ubuntu 18.04.3

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
laurent-simoncommented, Feb 16, 2020

The <br> is the “technical” artifact used to express the content. It is not the content! Outside of editing actions, it shall not be displayed.

The <br> is only required when editing. Like any Markdown syntax or any other hardcoded HTML tag, It is not the content to be rendered. The content to be rendered is a line break. More generally, an HTML tag is an artifact used to express content, but not the content itself (especially in a WYSIWIG environment)

By example, why a <b>bold</b> text is (correctly) rendered as “a bold text” (and not as “a <b>bold</b> text”) ? <b> and </b> tags describes a content, exactly like the <br> tag for, same reasons. Saying that <b> is content, and that <br> is not, is not consistent at all.

I don’t understand how you can say that <br> is content and <b> is not. They serve the same purpose. They are the syntax sugar used to describe the content. They are not the content by itself. Displaying them outside of editing actions does not make any sense, and is just annoying when you expect a WYSIWIG rendering.

0reactions
laurent-simoncommented, Feb 23, 2020

For me, the <br> tag meaning and rendering is equivalent to a hard line break. So I don’t understand why you compare it to a soft line break in your last comment. In the source code, you can add a soft break if you want for convenience (except in tables), but there is no required line break at all (no soft or hard break).

In your example, it should be rendered as:

  • An HTML <br> tag: when it is edited, or viewed in source code mode.
  • A-line break: when it is in WYSIWYG mode.

To understand the problem of <br> rendering, keep in mind that there is a place where you can only use <br> tags: inside tables. Without this case, the problem of the <br> is not important because a <br> tag can always be replaced by a hard line break. But inside tables, you cannot use a hard line break, but only the <br> tag. Seeing it rendred as <br> brokes everything and there is no workaround. It is a nightmare. The WYSIWYG aspect of the tool is totally broken in this case.

Try to render this in Mark Text to see the problem created by the <br> tags:

| Simple cell   | Multi lines cell                                                                            |
| ------------- | ------------------------------------------------------------------------------------------ |
| A single line | First line<br>Second line<br>etc.<br>__`<br>`tags are not expected to be displayed__<br>They are technical artifacts, not the content to be displayed! |

More generally, any HTML tag supported by CommonMark must be displayed only when the line is edited, or permanently in source code mode. It should be rendered as expected (HTML rendering) when it is displayed in the WYSIWYG mode. Exactly like any other Markdown syntax element, no more no less. It is a strong and simple rule that is easy to understand and defend. My opinion is that changing the rules for some cases (like <br>) for obscure reasons has no sense and just brings confusion and troubles.

<br> should be rendered as a line break in WYSIWIG view mode for only one reason: it is a CommonMark supported HTML tag, so it should be rendered like any other supported element. Soft line break or hard-line breaks considerations can’t change anything to this. It does not matter compared to this strong fact.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Item2174: WysiwygPlugin removes line breaks - Foswiki
WysiwygPlugin (I presume) removes line breaks from the middle of paragraphs. Being OCD, I like to put in line breaks at sentence (and...
Read more >
Preserve white space line breaks in tinymce wysiwyg editor
But, when I edit the same data with tinymce editor, the tinymce editor puts all the data in one line. The original text...
Read more >
Suggestion for "Convert line breaks into HTML" and text editor ...
So, should I: use wysiwyg editor and untick Convert line breaks into HTML ? or use Bueditor and tick Convert line breaks into...
Read more >
line breaks not working [#205659] | Drupal.org
Found this is a CSS issue in FCKeditor, not an input filter issue. When I changed the setting for "Editor CSS:" from theme...
Read more >
Linebreaks after tables in RoboHelp HTML WYSIWYG A... - Adobe ...
Can you select the line break in the WYSIWYG and then go into the HTML. There take an image of the selected markup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found