mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-23 18:53:36 +02:00
Desktop: Fixes #8530: Rich text editor: Use fewer
s in markdown while still preserving initial paragraph indentation (#8529)
This commit is contained in:
parent
1c1d20f82c
commit
e47985c101
@ -1 +1 @@
|
|||||||
**A test...** Test
|
**A test...** Test
|
@ -1,4 +1,4 @@
|
|||||||
import { repeat, isCodeBlockSpecialCase1, isCodeBlockSpecialCase2, isCodeBlock, getStyleProp } from './utilities'
|
import { repeat, isCodeBlockSpecialCase1, isCodeBlockSpecialCase2, isCodeBlock, getStyleProp, htmlEscapeLeadingNonbreakingSpace } from './utilities'
|
||||||
const Entities = require('html-entities').AllHtmlEntities;
|
const Entities = require('html-entities').AllHtmlEntities;
|
||||||
const htmlentities = (new Entities()).encode;
|
const htmlentities = (new Entities()).encode;
|
||||||
|
|
||||||
@ -25,6 +25,13 @@ rules.paragraph = {
|
|||||||
filter: 'p',
|
filter: 'p',
|
||||||
|
|
||||||
replacement: function (content) {
|
replacement: function (content) {
|
||||||
|
// If the line starts with a nonbreaking space, replace it. By default, the
|
||||||
|
// markdown renderer removes leading non-HTML-escaped nonbreaking spaces. However,
|
||||||
|
// because the space is nonbreaking, we want to keep it.
|
||||||
|
// \u00A0 is a nonbreaking space.
|
||||||
|
const leadingNonbreakingSpace = /^\u{00A0}/ug;
|
||||||
|
content = content.replace(leadingNonbreakingSpace, ' ');
|
||||||
|
|
||||||
return '\n\n' + content + '\n\n'
|
return '\n\n' + content + '\n\n'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ export default function TurndownService (options) {
|
|||||||
linkReferenceStyle: 'full',
|
linkReferenceStyle: 'full',
|
||||||
anchorNames: [],
|
anchorNames: [],
|
||||||
br: ' ',
|
br: ' ',
|
||||||
nonbreakingSpace: ' ',
|
|
||||||
disableEscapeContent: false,
|
disableEscapeContent: false,
|
||||||
preformattedCode: false,
|
preformattedCode: false,
|
||||||
blankReplacement: function (content, node) {
|
blankReplacement: function (content, node) {
|
||||||
@ -216,15 +215,10 @@ function replacementForNode (node) {
|
|||||||
var whitespace = node.flankingWhitespace
|
var whitespace = node.flankingWhitespace
|
||||||
if (whitespace.leading || whitespace.trailing) content = content.trim()
|
if (whitespace.leading || whitespace.trailing) content = content.trim()
|
||||||
|
|
||||||
const replaceNonbreakingSpaces = space => {
|
|
||||||
// \u{00A0} is a nonbreaking space
|
|
||||||
return space.replace(/\u{00A0}/ug, this.options.nonbreakingSpace);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
replaceNonbreakingSpaces(whitespace.leading) +
|
whitespace.leading +
|
||||||
replaceNonbreakingSpaces(rule.replacement(content, node, this.options)) +
|
rule.replacement(content, node, this.options) +
|
||||||
replaceNonbreakingSpaces(whitespace.trailing)
|
whitespace.trailing
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user