PY-22350 reStructuredText :class: and :name: options break IDE code-block highlighting

This commit is contained in:
Ekaterina Tuzova
2017-07-13 12:56:28 +03:00
parent e07a1dd6c8
commit 02bfe1680f
3 changed files with 1581 additions and 1511 deletions
@@ -155,6 +155,7 @@ public class RestLexerTest extends TestCase {
"[ :term:`user`, LINE]"
);
}
public void testLinks() throws IOException {
doTest("link_/\n" +
"link_!\n" +
@@ -181,6 +182,30 @@ public class RestLexerTest extends TestCase {
);
}
public void testFieldInCodeBlock() throws IOException {
doTest(".. code-block:: python\n" +
" :class: extra-css-class\n" +
"\n" +
" def thing(x): # comment\n" +
" print(\"{x} is a thing\".format(x=x))",
"[.. , EXPLISIT_MARKUP_START]",
"[code-block::, CUSTOM_DIRECTIVE]",
"[ , WHITESPACE]",
"[python\n, LINE]",
"[ , WHITESPACE]",
"[ , WHITESPACE]",
"[:class:, FIELD]",
"[ extra-css-class, LINE]",
"[\n, WHITESPACE]",
"[\n, WHITESPACE]",
"[ , PYTHON_LINE]",
"[def thing(x): # comment, PYTHON_LINE]",
"[\n, PYTHON_LINE]",
"[ , PYTHON_LINE]",
"[print(\"{x} is a thing\".format(x=x)), PYTHON_LINE]"
);
}
public void testInterpreted() throws IOException {
doTest(":kbd:`1`\n" +
"\n" +
File diff suppressed because it is too large Load Diff
@@ -41,6 +41,8 @@ LINK = [0-9A-Za-z][0-9A-Za-z\-:+_]*"_""_"?
%state IN_VALUE
%state IN_FOOTNOTE
%state IN_LINEBEGIN
%state FIELD_IN_INLINE
%state FIELD_LINE
%state INIT
%{
@@ -123,12 +125,23 @@ LINK = [0-9A-Za-z][0-9A-Za-z\-:+_]*"_""_"?
//Two posibilities -- quoted-block, indented block
{CRLF} { return WHITESPACE;}
{SPACE}+":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] { yypushback(yylength()-1); yybegin(FIELD_IN_INLINE); return WHITESPACE;}
{SPACE}+ { yybegin(PRE_INDENTED); myIndent = yylength(); return chooseType();}
{ADORNMENT_SYMBOL} { yybegin(PRE_QUOTED); return SPEC_SYMBOL;}
//{CRLF}{2}~{CRLF}{2} { yybegin(INIT); return LINE;}
}
<FIELD_IN_INLINE> {
{SPACE}+ { return WHITESPACE;}
":"[^:\n\r ]([^:\n\r] | "\\:")*[^:\n\r ]":"[ `\n] {yypushback(1); yybegin(FIELD_LINE); return FIELD;}
}
<FIELD_LINE> {
.* {yybegin(IN_INLINE); return LINE;}
}
<PRE_QUOTED> {
.+ { return chooseType();}
{CRLF} { yybegin(QUOTED); return chooseType();}
@@ -180,7 +193,7 @@ LINK = [0-9A-Za-z][0-9A-Za-z\-:+_]*"_""_"?
<IN_HIGHLIGHT> {
{SPACE}+ { return WHITESPACE;}
{CRLF} { yybegin(INIT); return WHITESPACE; }
[A-Za-z+]+{CRLF}{CRLF} { String value = yytext().toString().trim();
[A-Za-z+]+{CRLF} { String value = yytext().toString().trim();
if ("python".equalsIgnoreCase(value)) {
myState = 1;
yybegin(IN_INLINE);