mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-15 10:19:27 +00:00
Fix MediaWiki highlighter partly failing on quoted attributes
In T270880 an example with a slash in <ref name="a/b"> is described. The same issue happens with several other characters including the closing bracket, e.g. <ref name="a>b">. This patch fixes all of this by accepting _all_ characters between double and single quotes. Bug: T270880 Change-Id: I03a1e1a25af692dc703b44a57b2d23d6fc15c8c9
This commit is contained in:
parent
6e6356ccc0
commit
032bed3c61
|
@ -422,7 +422,7 @@
|
|||
|
||||
function eatHtmlTagAttribute( name ) {
|
||||
return function ( stream, state ) {
|
||||
if ( stream.match( /^[^>/<{&~]+/ ) ) {
|
||||
if ( stream.match( /^(?:"[^"]*"|'[^']*'|[^>/<{&~])+/ ) ) {
|
||||
return makeLocalStyle( 'mw-htmltag-attribute', state );
|
||||
}
|
||||
if ( stream.eat( '>' ) ) {
|
||||
|
@ -442,7 +442,7 @@
|
|||
|
||||
function eatExtTagAttribute( name ) {
|
||||
return function ( stream, state ) {
|
||||
if ( stream.match( /^[^>/<{&~]+/ ) ) {
|
||||
if ( stream.match( /^(?:"[^"]*"|'[^']*'|[^>/<{&~])+/ ) ) {
|
||||
return makeLocalStyle( 'mw-exttag-attribute mw-ext-' + name, state );
|
||||
}
|
||||
if ( stream.eat( '>' ) ) {
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
input: 'this is <p><div>content</p></p>',
|
||||
output: '<pre class=" CodeMirror-line " role="presentation"><span role="presentation">this is <span class="cm-mw-htmltag-bracket"><</span><span class="cm-mw-htmltag-name">p</span><span class="cm-mw-htmltag-bracket">><</span><span class="cm-mw-htmltag-name">div</span><span class="cm-mw-htmltag-bracket">></span>content<span class="cm-error"></p</span>><span class="cm-mw-htmltag-bracket"></</span><span class="cm-mw-htmltag-name">p</span><span class="cm-mw-htmltag-bracket">></span></span></pre>'
|
||||
},
|
||||
{
|
||||
title: 'HTML and ref tag attributes',
|
||||
input: '<span title="a>b"><ref name="a>b"/></span>',
|
||||
output: '<pre class=" CodeMirror-line " role="presentation"><span role="presentation"><span class="cm-mw-htmltag-bracket"><</span><span class="cm-mw-htmltag-name">span </span><span class="cm-mw-htmltag-attribute">title="a>b"</span><span class="cm-mw-htmltag-bracket">></span><span class="cm-mw-exttag-bracket cm-mw-ext-ref"><</span><span class="cm-mw-exttag-name cm-mw-ext-ref">ref </span><span class="cm-mw-exttag-attribute cm-mw-ext-ref">name="a>b"</span><span class="cm-mw-exttag-bracket cm-mw-ext-ref">/></span><span class="cm-mw-htmltag-bracket"></</span><span class="cm-mw-htmltag-name">span</span><span class="cm-mw-htmltag-bracket">></span></span></pre>'
|
||||
},
|
||||
{
|
||||
title: 'indented table with caption and inline headings',
|
||||
input: ' ::{| class="wikitable"\n |+ Caption\n |-\n ! Uno !! Dos\n |-\n | Foo || Bar\n |}',
|
||||
|
|
Loading…
Reference in a new issue