mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-11 19:39:02 +00:00
fix(markup): keep list items on separate lines in quote replies (#40329)
Keep each list item on its own line when quoting a comment. Items containing bold text or links could run together in the reply editor, breaking the quoted list.
This commit is contained in:
1 parent
03fc2bdcc8
commit
a61ef7aa14
2 files changed
+4
No files matched your search
@@ -21,4 +21,5 @@ test('convertHtmlToMarkdown', () => {
|
||||
|
||||
expect(convertHtmlToMarkdown(h(`<ol><li>a<ul><li>b</li></ul></li></ol>`))).toBe('1. a\n * b\n\n');
|
||||
expect(convertHtmlToMarkdown(h(`<ol><li><input checked>a</li></ol>`))).toBe('1. [x] a\n');
|
||||
expect(convertHtmlToMarkdown(h(`<ul><li><strong>a</strong></li><li><a href="link">b</a></li><li>c</li></ul>`))).toBe('* **a**\n* [b](link)\n* c\n');
|
||||
});
|
||||
@@ -82,6 +82,7 @@ function processElement(ctx :ProcessorContext, processors: Processors, el: HTMLE
|
||||
return processElement(ctx, processors, el.firstElementChild as HTMLElement);
|
||||
}
|
||||
|
||||
const {elementIsFirst, elementIsLast} = ctx; // processing the children below overwrites them
|
||||
const isListContainer = el.tagName === 'OL' || el.tagName === 'UL';
|
||||
if (isListContainer) ctx.listNestingLevel++;
|
||||
for (let i = 0; i < el.children.length; i++) {
|
||||
@@ -91,6 +92,8 @@ function processElement(ctx :ProcessorContext, processors: Processors, el: HTMLE
|
||||
}
|
||||
if (isListContainer) ctx.listNestingLevel--;
|
||||
|
||||
ctx.elementIsFirst = elementIsFirst;
|
||||
ctx.elementIsLast = elementIsLast;
|
||||
if (processors[el.tagName]) {
|
||||
const ret = processors[el.tagName](el);
|
||||
if (ret && ret !== el) {
|
||||
|
||||
Reference in new issue
Block a user