1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Desktop: Fixes #8430: Make HTML <br/> tags convert to markdown compatible with the softbreaks setting (#8469)

This commit is contained in:
Henry Heino 2023-07-18 06:48:26 -07:00 committed by GitHub
parent c70afe3478
commit ac66332a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,10 @@
<h1>Linebreaks</h1>
<div>&lt;br&gt;-style linebreaks should be replaced with two spaces followed by a
newline.<br/>This allows the generated mark<br/>down to render to equivalent HTML
even if the <code>markdown.plugin.softbreaks</code> setting is enabled.</div>
<pre class="some-code" style="font-family:monospace;">&lt;br&gt;s shouldn't<br/>lead<br/>to trailing spaces in
code
however.
</pre>
<p>Because it isn't</p>
<div>necessary.<br/><br/><br/><br/>...</div>

View File

@ -0,0 +1,21 @@
# Linebreaks
&lt;br&gt;-style linebreaks should be replaced with two spaces followed by a newline.
This allows the generated mark
down to render to equivalent HTML even if the `markdown.plugin.softbreaks` setting is enabled.
```
<br>s shouldn't
lead
to trailing spaces in
code
however.
```
Because it isn't
necessary.
...

View File

@ -23,7 +23,12 @@ export default class HtmlToMd {
bulletListMarker: '-',
emDelimiter: '*',
strongDelimiter: '**',
br: '',
// If soft-breaks are enabled, lines need to end with two or more spaces for
// trailing <br/>s to render. See
// https://github.com/laurent22/joplin/issues/8430
br: ' ',
disableEscapeContent: 'disableEscapeContent' in options ? options.disableEscapeContent : false,
};
if (options.convertEmbeddedPdfsToLinks) {

View File

@ -33,7 +33,10 @@ rules.lineBreak = {
filter: 'br',
replacement: function (content, node, options) {
return options.br + '\n'
// Code blocks may include <br/>s -- replacing them should not be necessary
// in code blocks.
const brReplacement = node.isCode ? '' : options.br;
return brReplacement + '\n'
}
}