improve treatment of lists at start of line

In the parser, '*', '#', ';' and ':' can actually become nested lists (<ul>, <ol>, <dt> and <dd>) in any possible combinations. This patch does not yet support the `; dt : dd` syntax.

This patch also fixes the 'Unknown highlighting tag undefined' warning.

Bug: T184272
Bug: T170042
Change-Id: I13cc55fadbc9b03fd7c70eab123f7e378d52898d
This commit is contained in:
bhsd 2024-01-18 23:39:31 +08:00
parent 1a038072b4
commit b4e762bd99
4 changed files with 11 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -513,7 +513,7 @@ class CodeMirrorModeMediaWiki {
}
// eat &
stream.next();
return this.eatHtmlEntity( stream );
return this.eatHtmlEntity( stream, '' );
};
}
@ -782,8 +782,9 @@ class CodeMirrorModeMediaWiki {
break;
case '*':
case '#':
case ';':
// Just consume all nested list and indention syntax when there is more
stream.match( /^[*#]*:*/ );
stream.match( /^[*#;:]*/ );
return modeConfig.tags.list;
case ':':
// Highlight indented tables :{|, bug T108454
@ -792,7 +793,7 @@ class CodeMirrorModeMediaWiki {
state.tokenize = this.eatStartTable.bind( this );
}
// Just consume all nested list and indention syntax when there is more
stream.match( /^:*[*#]*/ );
stream.match( /^[*#;:]*/ );
return modeConfig.tags.indenting;
case ' ':
// Leading spaces is valid syntax for tables, bug T108454

View file

@ -88,6 +88,11 @@ const testCases = [
input: '* bullet A\n* bullet B\n# one\n # two',
output: '<div class="cm-line"><span class="cm-mw-list">*</span> bullet A</div><div class="cm-line"><span class="cm-mw-list">*</span> bullet B</div><div class="cm-line"><span class="cm-mw-list">#</span> one</div><div class="cm-line"><span class="cm-mw-skipformatting"> </span># two</div>'
},
{
title: 'nested ordered, unordered and definition lists',
input: '*#;: item A\n#;:* item B\n;:*# item C\n:*#; item D',
output: '<div class="cm-line"><span class="cm-mw-list">*#;:</span> item A</div><div class="cm-line"><span class="cm-mw-list">#;:*</span> item B</div><div class="cm-line"><span class="cm-mw-list">;:*#</span> item C</div><div class="cm-line"><span class="cm-mw-indenting">:*#;</span> item D</div>'
},
{
title: 'link with bold text',
input: '[[Link title|\'\'\'bold link\'\'\']]',