You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
markdown: Only add \n\n on multiple paragraphs
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
This commit is contained in:
@@ -78,11 +78,23 @@ export default class Markdown {
|
||||
}
|
||||
} else {
|
||||
renderer.paragraph = function(node, entering) {
|
||||
if (entering) {
|
||||
// If there is only one top level node, just return the
|
||||
// bare text: it's a single line of text and so should be
|
||||
// 'inline', rather than unnecessarily wrapped in its own
|
||||
// p tag. If, however, we have multiple nodes, each gets
|
||||
// its own p tag to keep them as separate paragraphs.
|
||||
var par = node;
|
||||
while (par.parent) {
|
||||
node = par;
|
||||
par = par.parent;
|
||||
}
|
||||
if (node != par.lastChild) {
|
||||
if (!entering) {
|
||||
this.lit('\n\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var parsed = parser.parse(this.input);
|
||||
return renderer.render(parsed);
|
||||
|
||||
Reference in New Issue
Block a user