CodeMirrorModeMediaWiki: indented table

This is a follow-up of the patch 1032770, which misses one type of indented table in the test. It also specifies a unified `cm-mw-indenting` CSS class for all types of table indentation.

Bug: T108454
Change-Id: I77174cf3fa56382add6d80bf2ec7106c9b2cb642
This commit is contained in:
bhsd 2024-08-15 12:59:13 +08:00
parent 75710d6d05
commit f23f487028
2 changed files with 4 additions and 3 deletions

View file

@ -819,9 +819,10 @@ class CodeMirrorModeMediaWiki {
return this.eatList( stream, state );
case ':':
// Highlight indented tables :{|, bug T108454
if ( stream.match( /^:*[\s\u00a0]*{\|/, false ) ) {
if ( stream.match( /^:*[\s\u00a0]*(?={\|)/ ) ) {
state.stack.push( state.tokenize );
state.tokenize = this.eatStartTable.bind( this );
return mwModeConfig.tags.indenting;
}
return this.eatList( stream, state );
case ' ':

View file

@ -24,8 +24,8 @@ const testCases = [
},
{
title: 'indented table with caption and inline headings',
input: ':{|\n|}\n :: {| class="wikitable"\n |+ Caption\n |-\n ! Uno !! Dos\n |-\n | Foo || Bar\n |}',
output: '<div class="cm-line"><span class="cm-mw-list">:</span><span class="cm-mw-table-bracket">{|</span></div><div class="cm-line"><span class="cm-mw-table-bracket">|}</span></div><div class="cm-line"><span class="cm-mw-indenting"> :: </span><span class="cm-mw-table-bracket">{| </span><span class="cm-mw-table-definition">class</span><span class="cm-mw-table-definition">="wikitable"</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |+ </span><span class="cm-mw-table-caption">Caption</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |-</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> ! </span><span class="cm-mw-strong">Uno </span><span class="cm-mw-table-delimiter">!!</span><span class="cm-mw-strong"> Dos</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |-</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> | </span>Foo <span class="cm-mw-table-delimiter">||</span> Bar</div><div class="cm-line"><span class="cm-mw-table-bracket"> |}</span> </div>'
input: ':{|\n|}\n: {|\n|}\n :: {| class="wikitable"\n |+ Caption\n |-\n ! Uno !! Dos\n |-\n | Foo || Bar\n |}',
output: '<div class="cm-line"><span class="cm-mw-indenting">:</span><span class="cm-mw-table-bracket">{|</span></div><div class="cm-line"><span class="cm-mw-table-bracket">|}</span></div><div class="cm-line"><span class="cm-mw-indenting">: </span><span class="cm-mw-table-bracket">{|</span></div><div class="cm-line"><span class="cm-mw-table-bracket">|}</span></div><div class="cm-line"><span class="cm-mw-indenting"> :: </span><span class="cm-mw-table-bracket">{| </span><span class="cm-mw-table-definition">class</span><span class="cm-mw-table-definition">="wikitable"</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |+ </span><span class="cm-mw-table-caption">Caption</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |-</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> ! </span><span class="cm-mw-strong">Uno </span><span class="cm-mw-table-delimiter">!!</span><span class="cm-mw-strong"> Dos</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> |-</span></div><div class="cm-line"><span class="cm-mw-table-delimiter"> | </span>Foo <span class="cm-mw-table-delimiter">||</span> Bar</div><div class="cm-line"><span class="cm-mw-table-bracket"> |}</span> </div>'
},
{
title: 'apostrophe before italic',