PLT-1121: One element, non-ordered lists and one element, ordered, nested lists aren't rendered correctly
Этот коммит содержится в:
@@ -361,78 +361,78 @@ class MattermostLexer extends marked.Lexer {
|
|||||||
// list
|
// list
|
||||||
cap = this.rules.list.exec(src);
|
cap = this.rules.list.exec(src);
|
||||||
if (cap) {
|
if (cap) {
|
||||||
|
src = src.substring(cap[0].length);
|
||||||
const bull = cap[2];
|
const bull = cap[2];
|
||||||
let l = cap[0].length;
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'list_start',
|
||||||
|
ordered: bull.length > 1
|
||||||
|
});
|
||||||
|
|
||||||
// Get each top-level item.
|
// Get each top-level item.
|
||||||
cap = cap[0].match(this.rules.item);
|
cap = cap[0].match(this.rules.item);
|
||||||
|
|
||||||
if (cap.length > 1) {
|
let next = false;
|
||||||
src = src.substring(l);
|
const l = cap.length;
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
this.tokens.push({
|
for (; i < l; i++) {
|
||||||
type: 'list_start',
|
let item = cap[i];
|
||||||
ordered: bull.length > 1
|
|
||||||
});
|
|
||||||
|
|
||||||
let next = false;
|
// Remove the list item's bullet
|
||||||
l = cap.length;
|
// so it is seen as the next token.
|
||||||
|
let space = item.length;
|
||||||
|
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
||||||
|
|
||||||
for (let i = 0; i < l; i++) {
|
// Outdent whatever the
|
||||||
let item = cap[i];
|
// list item contains. Hacky.
|
||||||
|
if (~item.indexOf('\n ')) {
|
||||||
|
space -= item.length;
|
||||||
|
item = this.options.pedantic ?
|
||||||
|
item.replace(/^ {1,4}/gm, '') :
|
||||||
|
item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '');
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the list item's bullet
|
// Determine whether the next list item belongs here.
|
||||||
// so it is seen as the next token.
|
// Backpedal if it does not belong in this list.
|
||||||
let space = item.length;
|
if (this.options.smartLists && i !== l - 1) {
|
||||||
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
const b = this.rules.bullet.exec(cap[i + 1])[0];
|
||||||
|
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
||||||
// Outdent whatever the
|
src = cap.slice(i + 1).join('\n') + src;
|
||||||
// list item contains. Hacky.
|
i = l - 1;
|
||||||
if (~item.indexOf('\n ')) {
|
|
||||||
space -= item.length;
|
|
||||||
item = this.options.pedantic ? item.replace(/^ {1,4}/gm, '') : item.replace(new RegExp('^ \{1,' + space + '\}', 'gm'), '');
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Determine whether the next list item belongs here.
|
// Determine whether item is loose or not.
|
||||||
// Backpedal if it does not belong in this list.
|
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
||||||
if (this.options.smartLists && i !== l - 1) {
|
// for discount behavior.
|
||||||
const bullet = /(?:[*+-]|\d+\.)/;
|
let loose = next || (/\n\n(?!\s*$)/).test(item);
|
||||||
const b = bullet.exec(cap[i + 1])[0];
|
if (i !== l - 1) {
|
||||||
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
next = item.charAt(item.length - 1) === '\n';
|
||||||
src = cap.slice(i + 1).join('\n') + src;
|
if (!loose) {
|
||||||
i = l - 1;
|
loose = next;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether item is loose or not.
|
|
||||||
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
|
||||||
// for discount behavior.
|
|
||||||
let loose = next || (/\n\n(?!\s*$)/).test(item);
|
|
||||||
if (i !== l - 1) {
|
|
||||||
next = item.charAt(item.length - 1) === '\n';
|
|
||||||
if (!loose) {
|
|
||||||
loose = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tokens.push({
|
|
||||||
type: loose ? 'loose_item_start' : 'list_item_start'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Recurse.
|
|
||||||
this.token(item, false, bq);
|
|
||||||
|
|
||||||
this.tokens.push({
|
|
||||||
type: 'list_item_end'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tokens.push({
|
this.tokens.push({
|
||||||
type: 'list_end'
|
type: loose ?
|
||||||
|
'loose_item_start' :
|
||||||
|
'list_item_start'
|
||||||
});
|
});
|
||||||
|
|
||||||
continue;
|
// Recurse.
|
||||||
|
this.token(item, false, bq);
|
||||||
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'list_item_end'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.tokens.push({
|
||||||
|
type: 'list_end'
|
||||||
|
});
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// html
|
// html
|
||||||
|
|||||||
@@ -374,9 +374,9 @@ body.ios {
|
|||||||
ul {
|
ul {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0 0 1em;
|
margin: 0 0 1em;
|
||||||
line-height: 1.6em;
|
line-height: 1.6em;
|
||||||
@@ -603,6 +603,11 @@ body.ios {
|
|||||||
padding: 5px 0 0 20px;
|
padding: 5px 0 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul, ol {
|
||||||
|
li ul, li ol {
|
||||||
|
padding: 0 0 0 20px
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post__link {
|
.post__link {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user