Permalink
Browse files

Fully integrate mode tests into main test harness, with extra features.

- Integrated stex and Markdown mode tests into main test harness

- Added ability to restart tests partway through

- Added verbose option, to add message to output for *every* test

- Added ability to show verbose messages and run specific tests or all tests for 1+ mode(s) via location.hash

- Added support for custom messages (either return value [pass] or throw value [fail])

- Switched away from .innerHTML, .write(), etc in most places

- Make the progress bar actually 0px wide when 0% complete (and still keep padding)

- Added link to tests from each mode's demo page
  • Loading branch information...
1 parent cccb9b6 commit 2732eb2a285601094670c6f34daa4e60a226616d @0b10011 0b10011 committed with marijnh Sep 6, 2012
Showing with 1,665 additions and 948 deletions.
  1. +2 −0 mode/markdown/index.html
  2. +0 −645 mode/markdown/test.html
  3. +1,084 −0 mode/markdown/test.js
  4. +2 −0 mode/stex/index.html
  5. +0 −231 mode/stex/test.html
  6. +343 −0 mode/stex/test.js
  7. +67 −13 test/driver.js
  8. +114 −18 test/index.html
  9. +0 −12 test/mode_test.css
  10. +47 −23 test/mode_test.js
  11. +4 −4 test/phantom_driver.js
  12. +2 −2 test/test.js
View
2 mode/markdown/index.html
@@ -336,5 +336,7 @@
<p><strong>MIME types defined:</strong> <code>text/x-markdown</code>.</p>
+ <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#markdown_*">normal</a>, <a href="../../test/index.html#verbose,markdown_*">verbose</a>.</p>
+
</body>
</html>
View
645 mode/markdown/test.html
@@ -1,645 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf-8">
- <title>CodeMirror: Markdown mode</title>
- <link rel="stylesheet" href="../../lib/codemirror.css">
- <script src="../../lib/codemirror.js"></script>
- <script src="../xml/xml.js"></script>
- <script src="markdown.js"></script>
- <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
- <link rel="stylesheet" href="../../test/mode_test.css">
- <script src="../../test/mode_test.js"></script>
- <link rel="stylesheet" href="../../doc/docs.css">
- </head>
- <body>
- <h1>Tests for the Markdown Mode</h1>
- <script language="javascript">
- // Initiate ModeTest and set defaults
- MT = ModeTest;
- MT.modeName = 'markdown';
- </script>
-
- <h2>Basics</h2>
- <script language="javascript">
- MT.test('foo',
- null, 'foo');
- </script>
-
- <h2>Code</h2>
- <script language="javascript">
-
- // Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
- MT.test(' foo',
- null, ' ',
- 'comment', 'foo');
-
- // Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
- MT.test('\tfoo',
- null, '\t',
- 'comment', 'foo');
-
- // Inline code using backticks
- MT.test('foo `bar`',
- null, 'foo ',
- 'comment', '`bar`');
-
- // Unclosed backticks
- // Instead of simply marking as CODE, it would be nice to have an
- // incomplete flag for CODE, that is styled slightly different.
- MT.test('foo `bar',
- null, 'foo ',
- 'comment', '`bar');
-
- // Per documentation: "To include a literal backtick character within a
- // code span, you can use multiple backticks as the opening and closing
- // delimiters"
- MT.test('``foo ` bar``',
- 'comment', '``foo ` bar``');
-
- // Tests based on Dingus
- // http://daringfireball.net/projects/markdown/dingus
- //
- // Multiple backticks within an inline code block
- MT.test('`foo```bar`',
- 'comment', '`foo```bar`');
- // Multiple backticks within an inline code block with a second code block
- MT.test('`foo```bar` hello `world`',
- 'comment', '`foo```bar`',
- null, ' hello ',
- 'comment', '`world`');
- // Unclosed with several different groups of backticks
- MT.test('``foo ``` bar` hello',
- 'comment', '``foo ``` bar` hello');
- // Closed with several different groups of backticks
- MT.test('``foo ``` bar` hello`` world',
- 'comment', '``foo ``` bar` hello``',
- null, ' world');
- </script>
-
- <h2>Headers</h2>
- <script language="javascript">
-
- // atx headers
- // http://daringfireball.net/projects/markdown/syntax#header
- //
- // H1
- MT.test('# foo',
- 'header', '# foo');
- // H2
- MT.test('## foo',
- 'header', '## foo');
- // H3
- MT.test('### foo',
- 'header', '### foo');
- // H4
- MT.test('#### foo',
- 'header', '#### foo');
- // H5
- MT.test('##### foo',
- 'header', '##### foo');
- // H6
- MT.test('###### foo',
- 'header', '###### foo');
- // H6 - 7x '#' should still be H6, per Dingus
- // http://daringfireball.net/projects/markdown/dingus
- MT.test('####### foo',
- 'header', '####### foo');
-
- // Setext headers - H1, H2
- // Per documentation, "Any number of underlining =’s or -’s will work."
- // http://daringfireball.net/projects/markdown/syntax#header
- // Ideally, the text would be marked as `header` as well, but this is
- // not really feasible at the moment. So, instead, we're testing against
- // what works today, to avoid any regressions.
- //
- // Check if single underlining = works
- MT.test('foo\n=',
- null, 'foo',
- 'header', '=');
- // Check if 3+ ='s work
- MT.test('foo\n===',
- null, 'foo',
- 'header', '===');
- // Check if single underlining - works
- MT.test('foo\n-',
- null, 'foo',
- 'header', '-');
- // Check if 3+ -'s work
- MT.test('foo\n---',
- null, 'foo',
- 'header', '---');
- </script>
-
- <h2>Blockquotes</h2>
- <script language="javascript">
-
- // Single-line blockquote with trailing space
- MT.test('> foo',
- 'quote', '> foo');
-
- // Single-line blockquote
- MT.test('>foo',
- 'quote', '>foo');
-
- // Single-line blockquote followed by normal paragraph
- MT.test('>foo\n\nbar',
- 'quote', '>foo',
- null, 'bar');
-
- // Multi-line blockquote (lazy mode)
- MT.test('>foo\nbar',
- 'quote', '>foo',
- 'quote', 'bar');
-
- // Multi-line blockquote followed by normal paragraph (lazy mode)
- MT.test('>foo\nbar\n\nhello',
- 'quote', '>foo',
- 'quote', 'bar',
- null, 'hello');
-
- // Multi-line blockquote (non-lazy mode)
- MT.test('>foo\n>bar',
- 'quote', '>foo',
- 'quote', '>bar');
-
- // Multi-line blockquote followed by normal paragraph (non-lazy mode)
- MT.test('>foo\n>bar\n\nhello',
- 'quote', '>foo',
- 'quote', '>bar',
- null, 'hello');
- </script>
-
- <h2>Lists</h2>
- <script language="javascript">
-
- // Check list types
- MT.test('* foo\n* bar',
- 'string', '* foo',
- 'string', '* bar');
- MT.test('+ foo\n+ bar',
- 'string', '+ foo',
- 'string', '+ bar');
- MT.test('- foo\n- bar',
- 'string', '- foo',
- 'string', '- bar');
- MT.test('1. foo\n2. bar',
- 'string', '1. foo',
- 'string', '2. bar');
-
- // Formatting in lists (*)
- MT.test('* *foo* bar\n\n* **foo** bar\n\n* ***foo*** bar\n\n* `foo` bar',
- 'string', '* ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '* ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '* ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '* ',
- 'string comment', '`foo`',
- 'string', ' bar');
- // Formatting in lists (+)
- MT.test('+ *foo* bar\n\n+ **foo** bar\n\n+ ***foo*** bar\n\n+ `foo` bar',
- 'string', '+ ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '+ ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '+ ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '+ ',
- 'string comment', '`foo`',
- 'string', ' bar');
- // Formatting in lists (-)
- MT.test('- *foo* bar\n\n- **foo** bar\n\n- ***foo*** bar\n\n- `foo` bar',
- 'string', '- ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '- ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '- ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '- ',
- 'string comment', '`foo`',
- 'string', ' bar');
- // Formatting in lists (1.)
- MT.test('1. *foo* bar\n\n2. **foo** bar\n\n3. ***foo*** bar\n\n4. `foo` bar',
- 'string', '1. ',
- 'string em', '*foo*',
- 'string', ' bar',
- 'string', '2. ',
- 'string strong', '**foo**',
- 'string', ' bar',
- 'string', '3. ',
- 'string strong', '**',
- 'string emstrong', '*foo**',
- 'string em', '*',
- 'string', ' bar',
- 'string', '4. ',
- 'string comment', '`foo`',
- 'string', ' bar');
-
- // Paragraph lists
- MT.test('* foo\n\n* bar',
- 'string', '* foo',
- 'string', '* bar');
-
- // Multi-paragraph lists
- //
- // 4 spaces
- MT.test('* foo\n\n* bar\n\n hello',
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello');
- // 4 spaces, extra blank lines (should still be list, per Dingus)
- MT.test('* foo\n\n* bar\n\n\n hello',
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello');
- // 4 spaces, plus 1 space (should still be list, per Dingus)
- MT.test('* foo\n\n* bar\n\n hello\n\n world',
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string', 'hello',
- null, ' ',
- 'string', 'world');
- // 1 tab
- MT.test('* foo\n\n* bar\n\n\thello',
- 'string', '* foo',
- 'string', '* bar',
- null, '\t',
- 'string', 'hello');
- // No indent
- MT.test('* foo\n\n* bar\n\nhello',
- 'string', '* foo',
- 'string', '* bar',
- null, 'hello');
- // Blockquote
- MT.test('* foo\n\n* bar\n\n > hello',
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'string quote', '> hello');
- // Code block
- MT.test('* foo\n\n* bar\n\n > hello\n\n world',
- 'string', '* foo',
- 'string', '* bar',
- null, ' ',
- 'comment', '> hello',
- null, ' ',
- 'string', 'world');
- // Code block followed by text
- MT.test('* foo\n\n bar\n\n hello\n\n world',
- 'string', '* foo',
- null, ' ',
- 'string', 'bar',
- null, ' ',
- 'comment', 'hello',
- null, ' ',
- 'string', 'world');
-
- // Nested list
- //
- // *
- MT.test('* foo\n\n * bar',
- 'string', '* foo',
- null, ' ',
- 'string', '* bar');
- // +
- MT.test('+ foo\n\n + bar',
- 'string', '+ foo',
- null, ' ',
- 'string', '+ bar');
- // -
- MT.test('- foo\n\n - bar',
- 'string', '- foo',
- null, ' ',
- 'string', '- bar');
- // 1.
- MT.test('1. foo\n\n 2. bar',
- 'string', '1. foo',
- null, ' ',
- 'string', '2. bar');
- // Mixed
- MT.test('* foo\n\n + bar\n\n - hello\n\n 1. world',
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'string', '- hello',
- null, ' ',
- 'string', '1. world');
- // Blockquote
- MT.test('* foo\n\n + bar\n\n > hello',
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'quote string', '> hello');
- // Code
- MT.test('* foo\n\n + bar\n\n hello',
- 'string', '* foo',
- null, ' ',
- 'string', '+ bar',
- null, ' ',
- 'comment', 'hello');
- // Code followed by text
- MT.test('* foo\n\n bar\n\nhello',
- 'string', '* foo',
- null, ' ',
- 'comment', 'bar',
- null, 'hello');
- </script>
-
- <h2>Horizontal rules</h2>
- <script language="javascript">
-
- // Following tests directly from official Markdown documentation
- // http://daringfireball.net/projects/markdown/syntax#hr
- MT.test('* * *',
- 'hr', '* * *');
-
- MT.test('***',
- 'hr', '***');
-
- MT.test('*****',
- 'hr', '*****');
-
- MT.test('- - -',
- 'hr', '- - -');
-
- MT.test('---------------------------------------',
- 'hr', '---------------------------------------');
- </script>
-
- <h2>Links</h2>
- <script language="javascript">
-
- // Inline link with title
- MT.test('[foo](http://example.com/ "bar") hello',
- 'link', '[foo]',
- 'string', '(http://example.com/ "bar")',
- null, ' hello');
-
- // Inline link without title
- MT.test('[foo](http://example.com/) bar',
- 'link', '[foo]',
- 'string', '(http://example.com/)',
- null, ' bar');
-
- // Reference-style links
- MT.test('[foo][bar] hello',
- 'link', '[foo]',
- 'string', '[bar]',
- null, ' hello');
-
- // Reference-style links with optional space separator (per docuentation)
- // "You can optionally use a space to separate the sets of brackets"
- MT.test('[foo] [bar] hello',
- 'link', '[foo]',
- null, ' ',
- 'string', '[bar]',
- null, ' hello');
- // Should only allow a single space ("...use *a* space...")
- MT.test('[foo] [bar] hello',
- null, '[foo] [bar] hello');
-
- // Reference-style links with implicit link name
- MT.test('[foo][] hello',
- 'link', '[foo]',
- 'string', '[]',
- null, ' hello');
-
- // @todo It would be nice if, at some point, the document was actually
- // checked to see if the referenced link exists
-
- // Link label, for reference-style links (taken from documentation)
- //
- // No title
- MT.test('[foo]: http://example.com/',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/');
- // Space in ID and title
- MT.test('[foo bar]: http://example.com/ "hello"',
- 'link', '[foo bar]:',
- null, ' ',
- 'string', 'http://example.com/ "hello"');
- // Double title
- MT.test('[foo bar]: http://example.com/ "hello" "world"',
- 'link', '[foo bar]:',
- null, ' ',
- 'string', 'http://example.com/ "hello"',
- null, ' "world"');
- // Double quotes around title
- MT.test('[foo]: http://example.com/ "bar"',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ "bar"');
- // Single quotes around title
- MT.test('[foo]: http://example.com/ \'bar\'',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ \'bar\'');
- // Parentheses around title
- MT.test('[foo]: http://example.com/ (bar)',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/ (bar)');
- // Invalid title
- MT.test('[foo]: http://example.com/ bar',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- null, ' bar');
- // Angle brackets around URL
- MT.test('[foo]: <http://example.com/> "bar"',
- 'link', '[foo]:',
- null, ' ',
- 'string', '<http://example.com/> "bar"');
- // Title on next line per documentation (double quotes)
- MT.test('[foo]: http://example.com/\n"bar" hello',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '"bar"',
- null, ' hello');
- // Title on next line per documentation (single quotes)
- MT.test('[foo]: http://example.com/\n\'bar\' hello',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '\'bar\'',
- null, ' hello');
- // Title on next line per documentation (parentheses)
- MT.test('[foo]: http://example.com/\n(bar) hello',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- 'string', '(bar)',
- null, ' hello');
- // Title on next line per documentation (mixed)
- MT.test('[foo]: http://example.com/\n(bar" hello',
- 'link', '[foo]:',
- null, ' ',
- 'string', 'http://example.com/',
- null, '(bar" hello');
-
- // Automatic links
- MT.test('<http://example.com/> foo',
- 'link', '<http://example.com/>',
- null, ' foo');
-
- // Automatic email links
- MT.test('<user@example.com> foo',
- 'link', '<user@example.com>',
- null, ' foo');
- </script>
-
- <h2>Emphasis</h2>
- <script language="javascript">
-
- // Single asterisk
- MT.test('*foo* bar',
- 'em', '*foo*',
- null, ' bar');
-
- // Single underscore
- MT.test('_foo_ bar',
- 'em', '_foo_',
- null, ' bar');
-
- // Emphasis characters within a word
- MT.test('foo*bar*hello',
- null, 'foo',
- 'em', '*bar*',
- null, 'hello');
- MT.test('foo_bar_hello',
- null, 'foo',
- 'em', '_bar_',
- null, 'hello');
- // Per documentation: "...surround an * or _ with spaces, it’ll be
- // treated as a literal asterisk or underscore."
- //
- // Inside EM
- MT.test('foo _bar _ hello_ world',
- null, 'foo ',
- 'em', '_bar _ hello_',
- null, ' world');
- // Outside EM
- MT.test('foo _ bar_hello_world',
- null, 'foo _ bar',
- 'em', '_hello_',
- null, 'world');
-
- // Unclosed emphasis characters
- // Instead of simply marking as EM / STRONG, it would be nice to have an
- // incomplete flag for EM and STRONG, that is styled slightly different.
- MT.test('foo *bar',
- null, 'foo ',
- 'em', '*bar');
- MT.test('foo _bar',
- null, 'foo ',
- 'em', '_bar');
-
- // Double asterisk
- MT.test('**foo** bar',
- 'strong', '**foo**',
- null, ' bar');
-
- // Double underscore
- MT.test('__foo__ bar',
- 'strong', '__foo__',
- null, ' bar');
-
- // Triple asterisk
- MT.test('*foo**bar*hello** world',
- 'em', '*foo',
- 'emstrong', '**bar*',
- 'strong', 'hello**',
- null, ' world');
-
- // Triple underscore
- MT.test('_foo__bar_hello__ world',
- 'em', '_foo',
- 'emstrong', '__bar_',
- 'strong', 'hello__',
- null, ' world');
-
- // Triple mixed
- // "...same character must be used to open and close an emphasis span.""
- MT.test('_foo**bar*hello__ world',
- 'em', '_foo',
- 'emstrong', '**bar*hello__ world');
-
- MT.test('*foo__bar_hello** world',
- 'em', '*foo',
- 'emstrong', '__bar_hello** world');
- </script>
-
- <h2>Escaping</h2>
- <script language="javascript">
-
- // These characters should be escaped:
- // \ backslash
- // ` backtick
- // * asterisk
- // _ underscore
- // {} curly braces
- // [] square brackets
- // () parentheses
- // # hash mark
- // + plus sign
- // - minus sign (hyphen)
- // . dot
- // ! exclamation mark
- //
- // Backtick (code)
- MT.test('foo \\`bar\\`',
- null, 'foo \\`bar\\`');
- MT.test('foo \\\\`bar\\\\`',
- null, 'foo \\\\',
- 'comment', '`bar\\\\`');
- // Asterisk (em)
- MT.test('foo \\*bar\\*',
- null, 'foo \\*bar\\*');
- MT.test('foo \\\\*bar\\\\*',
- null, 'foo \\\\',
- 'em', '*bar\\\\*');
- // Underscore (em)
- MT.test('foo \\_bar\\_',
- null, 'foo \\_bar\\_');
- MT.test('foo \\\\_bar\\\\_',
- null, 'foo \\\\',
- 'em', '_bar\\\\_');
- // Hash mark (headers)
- MT.test('\\# foo',
- null, '\\# foo');
- MT.test('\\\\# foo',
- null, '\\\\# foo');
- </script>
-
- <h2>Summary</h2>
- <script language="javascript">
- MT.printSummary();
- </script>
-
- </body>
-</html>
-
View
1,084 mode/markdown/test.js
@@ -0,0 +1,1084 @@
+// Initiate ModeTest and set defaults
+var MT = ModeTest;
+MT.modeName = 'markdown';
+MT.modeOptions = {};
+
+MT.testMode(
+ 'plainText',
+ 'foo',
+ [
+ null, 'foo'
+ ]
+);
+
+// Code blocks using 4 spaces (regardless of CodeMirror.tabSize value)
+MT.testMode(
+ 'codeBlocksUsing4Spaces',
+ ' foo',
+ [
+ null, ' ',
+ 'comment', 'foo'
+ ]
+);
+
+// Code blocks using 1 tab (regardless of CodeMirror.indentWithTabs value)
+MT.testMode(
+ 'codeBlocksUsing1Tab',
+ '\tfoo',
+ [
+ null, '\t',
+ 'comment', 'foo'
+ ]
+);
+
+// Inline code using backticks
+MT.testMode(
+ 'inlineCodeUsingBackticks',
+ 'foo `bar`',
+ [
+ null, 'foo ',
+ 'comment', '`bar`'
+ ]
+);
+
+// Unclosed backticks
+// Instead of simply marking as CODE, it would be nice to have an
+// incomplete flag for CODE, that is styled slightly different.
+MT.testMode(
+ 'unclosedBackticks',
+ 'foo `bar',
+ [
+ null, 'foo ',
+ 'comment', '`bar'
+ ]
+);
+
+// Per documentation: "To include a literal backtick character within a
+// code span, you can use multiple backticks as the opening and closing
+// delimiters"
+MT.testMode(
+ 'doubleBackticks',
+ '``foo ` bar``',
+ [
+ 'comment', '``foo ` bar``'
+ ]
+);
+
+// Tests based on Dingus
+// http://daringfireball.net/projects/markdown/dingus
+//
+// Multiple backticks within an inline code block
+MT.testMode(
+ 'consecutiveBackticks',
+ '`foo```bar`',
+ [
+ 'comment', '`foo```bar`'
+ ]
+);
+// Multiple backticks within an inline code block with a second code block
+MT.testMode(
+ 'consecutiveBackticks',
+ '`foo```bar` hello `world`',
+ [
+ 'comment', '`foo```bar`',
+ null, ' hello ',
+ 'comment', '`world`'
+ ]
+);
+// Unclosed with several different groups of backticks
+MT.testMode(
+ 'unclosedBackticks',
+ '``foo ``` bar` hello',
+ [
+ 'comment', '``foo ``` bar` hello'
+ ]
+);
+// Closed with several different groups of backticks
+MT.testMode(
+ 'closedBackticks',
+ '``foo ``` bar` hello`` world',
+ [
+ 'comment', '``foo ``` bar` hello``',
+ null, ' world'
+ ]
+);
+
+// atx headers
+// http://daringfireball.net/projects/markdown/syntax#header
+//
+// H1
+MT.testMode(
+ 'atxH1',
+ '# foo',
+ [
+ 'header', '# foo'
+ ]
+);
+// H2
+MT.testMode(
+ 'atxH2',
+ '## foo',
+ [
+ 'header', '## foo'
+ ]
+);
+// H3
+MT.testMode(
+ 'atxH3',
+ '### foo',
+ [
+ 'header', '### foo'
+ ]
+);
+// H4
+MT.testMode(
+ 'atxH4',
+ '#### foo',
+ [
+ 'header', '#### foo'
+ ]
+);
+// H5
+MT.testMode(
+ 'atxH5',
+ '##### foo',
+ [
+ 'header', '##### foo'
+ ]
+);
+// H6
+MT.testMode(
+ 'atxH6',
+ '###### foo',
+ [
+ 'header', '###### foo'
+ ]
+);
+// H6 - 7x '#' should still be H6, per Dingus
+// http://daringfireball.net/projects/markdown/dingus
+MT.testMode(
+ 'atxH6NotH7',
+ '####### foo',
+ [
+ 'header', '####### foo'
+ ]
+);
+
+// Setext headers - H1, H2
+// Per documentation, "Any number of underlining =’s or -’s will work."
+// http://daringfireball.net/projects/markdown/syntax#header
+// Ideally, the text would be marked as `header` as well, but this is
+// not really feasible at the moment. So, instead, we're testing against
+// what works today, to avoid any regressions.
+//
+// Check if single underlining = works
+MT.testMode(
+ 'setextH1',
+ 'foo\n=',
+ [
+ null, 'foo',
+ 'header', '='
+ ]
+);
+// Check if 3+ ='s work
+MT.testMode(
+ 'setextH1',
+ 'foo\n===',
+ [
+ null, 'foo',
+ 'header', '==='
+ ]
+);
+// Check if single underlining - works
+MT.testMode(
+ 'setextH2',
+ 'foo\n-',
+ [
+ null, 'foo',
+ 'header', '-'
+ ]
+);
+// Check if 3+ -'s work
+MT.testMode(
+ 'setextH2',
+ 'foo\n---',
+ [
+ null, 'foo',
+ 'header', '---'
+ ]
+);
+
+// Single-line blockquote with trailing space
+MT.testMode(
+ 'blockquoteSpace',
+ '> foo',
+ [
+ 'quote', '> foo'
+ ]
+);
+
+// Single-line blockquote
+MT.testMode(
+ 'blockquoteNoSpace',
+ '>foo',
+ [
+ 'quote', '>foo'
+ ]
+);
+
+// Single-line blockquote followed by normal paragraph
+MT.testMode(
+ 'blockquoteThenParagraph',
+ '>foo\n\nbar',
+ [
+ 'quote', '>foo',
+ null, 'bar'
+ ]
+);
+
+// Multi-line blockquote (lazy mode)
+MT.testMode(
+ 'multiBlockquoteLazy',
+ '>foo\nbar',
+ [
+ 'quote', '>foo',
+ 'quote', 'bar'
+ ]
+);
+
+// Multi-line blockquote followed by normal paragraph (lazy mode)
+MT.testMode(
+ 'multiBlockquoteLazyThenParagraph',
+ '>foo\nbar\n\nhello',
+ [
+ 'quote', '>foo',
+ 'quote', 'bar',
+ null, 'hello'
+ ]
+);
+
+// Multi-line blockquote (non-lazy mode)
+MT.testMode(
+ 'multiBlockquote',
+ '>foo\n>bar',
+ [
+ 'quote', '>foo',
+ 'quote', '>bar'
+ ]
+);
+
+// Multi-line blockquote followed by normal paragraph (non-lazy mode)
+MT.testMode(
+ 'multiBlockquoteThenParagraph',
+ '>foo\n>bar\n\nhello',
+ [
+ 'quote', '>foo',
+ 'quote', '>bar',
+ null, 'hello'
+ ]
+);
+
+// Check list types
+MT.testMode(
+ 'listAsterisk',
+ '* foo\n* bar',
+ [
+ 'string', '* foo',
+ 'string', '* bar'
+ ]
+);
+MT.testMode(
+ 'listPlus',
+ '+ foo\n+ bar',
+ [
+ 'string', '+ foo',
+ 'string', '+ bar'
+ ]
+);
+MT.testMode(
+ 'listDash',
+ '- foo\n- bar',
+ [
+ 'string', '- foo',
+ 'string', '- bar'
+ ]
+);
+MT.testMode(
+ 'listNumber',
+ '1. foo\n2. bar',
+ [
+ 'string', '1. foo',
+ 'string', '2. bar'
+ ]
+);
+
+// Formatting in lists (*)
+MT.testMode(
+ 'listAsteriskFormatting',
+ '* *foo* bar\n\n* **foo** bar\n\n* ***foo*** bar\n\n* `foo` bar',
+ [
+ 'string', '* ',
+ 'string em', '*foo*',
+ 'string', ' bar',
+ 'string', '* ',
+ 'string strong', '**foo**',
+ 'string', ' bar',
+ 'string', '* ',
+ 'string strong', '**',
+ 'string emstrong', '*foo**',
+ 'string em', '*',
+ 'string', ' bar',
+ 'string', '* ',
+ 'string comment', '`foo`',
+ 'string', ' bar'
+ ]
+);
+// Formatting in lists (+)
+MT.testMode(
+ 'listPlusFormatting',
+ '+ *foo* bar\n\n+ **foo** bar\n\n+ ***foo*** bar\n\n+ `foo` bar',
+ [
+ 'string', '+ ',
+ 'string em', '*foo*',
+ 'string', ' bar',
+ 'string', '+ ',
+ 'string strong', '**foo**',
+ 'string', ' bar',
+ 'string', '+ ',
+ 'string strong', '**',
+ 'string emstrong', '*foo**',
+ 'string em', '*',
+ 'string', ' bar',
+ 'string', '+ ',
+ 'string comment', '`foo`',
+ 'string', ' bar'
+ ]
+);
+// Formatting in lists (-)
+MT.testMode(
+ 'listDashFormatting',
+ '- *foo* bar\n\n- **foo** bar\n\n- ***foo*** bar\n\n- `foo` bar',
+ [
+ 'string', '- ',
+ 'string em', '*foo*',
+ 'string', ' bar',
+ 'string', '- ',
+ 'string strong', '**foo**',
+ 'string', ' bar',
+ 'string', '- ',
+ 'string strong', '**',
+ 'string emstrong', '*foo**',
+ 'string em', '*',
+ 'string', ' bar',
+ 'string', '- ',
+ 'string comment', '`foo`',
+ 'string', ' bar'
+ ]
+);
+// Formatting in lists (1.)
+MT.testMode(
+ 'listNumberFormatting',
+ '1. *foo* bar\n\n2. **foo** bar\n\n3. ***foo*** bar\n\n4. `foo` bar',
+ [
+ 'string', '1. ',
+ 'string em', '*foo*',
+ 'string', ' bar',
+ 'string', '2. ',
+ 'string strong', '**foo**',
+ 'string', ' bar',
+ 'string', '3. ',
+ 'string strong', '**',
+ 'string emstrong', '*foo**',
+ 'string em', '*',
+ 'string', ' bar',
+ 'string', '4. ',
+ 'string comment', '`foo`',
+ 'string', ' bar'
+ ]
+);
+
+// Paragraph lists
+MT.testMode(
+ 'listParagraph',
+ '* foo\n\n* bar',
+ [
+ 'string', '* foo',
+ 'string', '* bar'
+ ]
+);
+
+// Multi-paragraph lists
+//
+// 4 spaces
+MT.testMode(
+ 'listMultiParagraph',
+ '* foo\n\n* bar\n\n hello',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, ' ',
+ 'string', 'hello'
+ ]
+);
+// 4 spaces, extra blank lines (should still be list, per Dingus)
+MT.testMode(
+ 'listMultiParagraphExtra',
+ '* foo\n\n* bar\n\n\n hello',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, ' ',
+ 'string', 'hello'
+ ]
+);
+// 4 spaces, plus 1 space (should still be list, per Dingus)
+MT.testMode(
+ 'listMultiParagraphExtraSpace',
+ '* foo\n\n* bar\n\n hello\n\n world',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, ' ',
+ 'string', 'hello',
+ null, ' ',
+ 'string', 'world'
+ ]
+);
+// 1 tab
+MT.testMode(
+ 'listTab',
+ '* foo\n\n* bar\n\n\thello',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, '\t',
+ 'string', 'hello'
+ ]
+);
+// No indent
+MT.testMode(
+ 'listNoIndent',
+ '* foo\n\n* bar\n\nhello',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, 'hello'
+ ]
+);
+// Blockquote
+MT.testMode(
+ 'blockquote',
+ '* foo\n\n* bar\n\n > hello',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, ' ',
+ 'string quote', '> hello'
+ ]
+);
+// Code block
+MT.testMode(
+ 'blockquoteCode',
+ '* foo\n\n* bar\n\n > hello\n\n world',
+ [
+ 'string', '* foo',
+ 'string', '* bar',
+ null, ' ',
+ 'comment', '> hello',
+ null, ' ',
+ 'string', 'world'
+ ]
+);
+// Code block followed by text
+MT.testMode(
+ 'blockquoteCodeText',
+ '* foo\n\n bar\n\n hello\n\n world',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'string', 'bar',
+ null, ' ',
+ 'comment', 'hello',
+ null, ' ',
+ 'string', 'world'
+ ]
+);
+
+// Nested list
+//
+// *
+MT.testMode(
+ 'listAsteriskNested',
+ '* foo\n\n * bar',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'string', '* bar'
+ ]
+);
+// +
+MT.testMode(
+ 'listPlusNested',
+ '+ foo\n\n + bar',
+ [
+ 'string', '+ foo',
+ null, ' ',
+ 'string', '+ bar'
+ ]
+);
+// -
+MT.testMode(
+ 'listDashNested',
+ '- foo\n\n - bar',
+ [
+ 'string', '- foo',
+ null, ' ',
+ 'string', '- bar'
+ ]
+);
+// 1.
+MT.testMode(
+ 'listNumberNested',
+ '1. foo\n\n 2. bar',
+ [
+ 'string', '1. foo',
+ null, ' ',
+ 'string', '2. bar'
+ ]
+);
+// Mixed
+MT.testMode(
+ 'listMixed',
+ '* foo\n\n + bar\n\n - hello\n\n 1. world',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'string', '+ bar',
+ null, ' ',
+ 'string', '- hello',
+ null, ' ',
+ 'string', '1. world'
+ ]
+);
+// Blockquote
+MT.testMode(
+ 'listBlockquote',
+ '* foo\n\n + bar\n\n > hello',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'string', '+ bar',
+ null, ' ',
+ 'quote string', '> hello'
+ ]
+);
+// Code
+MT.testMode(
+ 'listCode',
+ '* foo\n\n + bar\n\n hello',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'string', '+ bar',
+ null, ' ',
+ 'comment', 'hello'
+ ]
+);
+// Code followed by text
+MT.testMode(
+ 'listCodeText',
+ '* foo\n\n bar\n\nhello',
+ [
+ 'string', '* foo',
+ null, ' ',
+ 'comment', 'bar',
+ null, 'hello'
+ ]
+);
+
+// Following tests directly from official Markdown documentation
+// http://daringfireball.net/projects/markdown/syntax#hr
+MT.testMode(
+ 'hrSpace',
+ '* * *',
+ [
+ 'hr', '* * *'
+ ]
+);
+
+MT.testMode(
+ 'hr',
+ '***',
+ [
+ 'hr', '***'
+ ]
+);
+
+MT.testMode(
+ 'hrLong',
+ '*****',
+ [
+ 'hr', '*****'
+ ]
+);
+
+MT.testMode(
+ 'hrSpaceDash',
+ '- - -',
+ [
+ 'hr', '- - -'
+ ]
+);
+
+MT.testMode(
+ 'hrDashLong',
+ '---------------------------------------',
+ [
+ 'hr', '---------------------------------------'
+ ]
+);
+
+// Inline link with title
+MT.testMode(
+ 'linkTitle',
+ '[foo](http://example.com/ "bar") hello',
+ [
+ 'link', '[foo]',
+ 'string', '(http://example.com/ "bar")',
+ null, ' hello'
+ ]
+);
+
+// Inline link without title
+MT.testMode(
+ 'linkNoTitle',
+ '[foo](http://example.com/) bar',
+ [
+ 'link', '[foo]',
+ 'string', '(http://example.com/)',
+ null, ' bar'
+ ]
+);
+
+// Reference-style links
+MT.testMode(
+ 'linkReference',
+ '[foo][bar] hello',
+ [
+ 'link', '[foo]',
+ 'string', '[bar]',
+ null, ' hello'
+ ]
+);
+
+// Reference-style links with optional space separator (per docuentation)
+// "You can optionally use a space to separate the sets of brackets"
+MT.testMode(
+ 'linkReferenceSpace',
+ '[foo] [bar] hello',
+ [
+ 'link', '[foo]',
+ null, ' ',
+ 'string', '[bar]',
+ null, ' hello'
+ ]
+);
+// Should only allow a single space ("...use *a* space...")
+MT.testMode(
+ 'linkReferenceDoubleSpace',
+ '[foo] [bar] hello',
+ [
+ null, '[foo] [bar] hello'
+ ]
+);
+
+// Reference-style links with implicit link name
+MT.testMode(
+ 'linkImplicit',
+ '[foo][] hello',
+ [
+ 'link', '[foo]',
+ 'string', '[]',
+ null, ' hello'
+ ]
+);
+
+// @todo It would be nice if, at some point, the document was actually
+// checked to see if the referenced link exists
+
+// Link label, for reference-style links (taken from documentation)
+//
+// No title
+MT.testMode(
+ 'labelNoTitle',
+ '[foo]: http://example.com/',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/'
+ ]
+);
+// Space in ID and title
+MT.testMode(
+ 'labelSpaceTitle',
+ '[foo bar]: http://example.com/ "hello"',
+ [
+ 'link', '[foo bar]:',
+ null, ' ',
+ 'string', 'http://example.com/ "hello"'
+ ]
+);
+// Double title
+MT.testMode(
+ 'labelDoubleTitle',
+ '[foo bar]: http://example.com/ "hello" "world"',
+ [
+ 'link', '[foo bar]:',
+ null, ' ',
+ 'string', 'http://example.com/ "hello"',
+ null, ' "world"'
+ ]
+);
+// Double quotes around title
+MT.testMode(
+ 'labelTitleDoubleQuotes',
+ '[foo]: http://example.com/ "bar"',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/ "bar"'
+ ]
+);
+// Single quotes around title
+MT.testMode(
+ 'labelTitleSingleQuotes',
+ '[foo]: http://example.com/ \'bar\'',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/ \'bar\''
+ ]
+);
+// Parentheses around title
+MT.testMode(
+ 'labelTitleParenthese',
+ '[foo]: http://example.com/ (bar)',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/ (bar)'
+ ]
+);
+// Invalid title
+MT.testMode(
+ 'labelTitleInvalid',
+ '[foo]: http://example.com/ bar',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/',
+ null, ' bar'
+ ]
+);
+// Angle brackets around URL
+MT.testMode(
+ 'labelLinkAngleBrackets',
+ '[foo]: <http://example.com/> "bar"',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', '<http://example.com/> "bar"'
+ ]
+);
+// Title on next line per documentation (double quotes)
+MT.testMode(
+ 'labelTitleNextDoubleQuotes',
+ '[foo]: http://example.com/\n"bar" hello',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/',
+ 'string', '"bar"',
+ null, ' hello'
+ ]
+);
+// Title on next line per documentation (single quotes)
+MT.testMode(
+ 'labelTitleNextSingleQuotes',
+ '[foo]: http://example.com/\n\'bar\' hello',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/',
+ 'string', '\'bar\'',
+ null, ' hello'
+ ]
+);
+// Title on next line per documentation (parentheses)
+MT.testMode(
+ 'labelTitleNextParenthese',
+ '[foo]: http://example.com/\n(bar) hello',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/',
+ 'string', '(bar)',
+ null, ' hello'
+ ]
+);
+// Title on next line per documentation (mixed)
+MT.testMode(
+ 'labelTitleNextMixed',
+ '[foo]: http://example.com/\n(bar" hello',
+ [
+ 'link', '[foo]:',
+ null, ' ',
+ 'string', 'http://example.com/',
+ null, '(bar" hello'
+ ]
+);
+
+// Automatic links
+MT.testMode(
+ 'linkWeb',
+ '<http://example.com/> foo',
+ [
+ 'link', '<http://example.com/>',
+ null, ' foo'
+ ]
+);
+
+// Automatic email links
+MT.testMode(
+ 'linkEmail',
+ '<user@example.com> foo',
+ [
+ 'link', '<user@example.com>',
+ null, ' foo'
+ ]
+);
+
+// Single asterisk
+MT.testMode(
+ 'emAsterisk',
+ '*foo* bar',
+ [
+ 'em', '*foo*',
+ null, ' bar'
+ ]
+);
+
+// Single underscore
+MT.testMode(
+ 'emUnderscore',
+ '_foo_ bar',
+ [
+ 'em', '_foo_',
+ null, ' bar'
+ ]
+);
+
+// Emphasis characters within a word
+MT.testMode(
+ 'emInWordAsterisk',
+ 'foo*bar*hello',
+ [
+ null, 'foo',
+ 'em', '*bar*',
+ null, 'hello'
+ ]
+);
+MT.testMode(
+ 'emInWordUnderscore',
+ 'foo_bar_hello',
+ [
+ null, 'foo',
+ 'em', '_bar_',
+ null, 'hello'
+ ]
+);
+// Per documentation: "...surround an * or _ with spaces, it’ll be
+// treated as a literal asterisk or underscore."
+//
+// Inside EM
+MT.testMode(
+ 'emEscapedBySpaceIn',
+ 'foo _bar _ hello_ world',
+ [
+ null, 'foo ',
+ 'em', '_bar _ hello_',
+ null, ' world'
+ ]
+);
+// Outside EM
+MT.testMode(
+ 'emEscapedBySpaceOut',
+ 'foo _ bar_hello_world',
+ [
+ null, 'foo _ bar',
+ 'em', '_hello_',
+ null, 'world'
+ ]
+);
+
+// Unclosed emphasis characters
+// Instead of simply marking as EM / STRONG, it would be nice to have an
+// incomplete flag for EM and STRONG, that is styled slightly different.
+MT.testMode(
+ 'emIncompleteAsterisk',
+ 'foo *bar',
+ [
+ null, 'foo ',
+ 'em', '*bar'
+ ]
+);
+MT.testMode(
+ 'emIncompleteUnderscore',
+ 'foo _bar',
+ [
+ null, 'foo ',
+ 'em', '_bar'
+ ]
+);
+
+// Double asterisk
+MT.testMode(
+ 'strongAsterisk',
+ '**foo** bar',
+ [
+ 'strong', '**foo**',
+ null, ' bar'
+ ]
+);
+
+// Double underscore
+MT.testMode(
+ 'strongUnderscore',
+ '__foo__ bar',
+ [
+ 'strong', '__foo__',
+ null, ' bar'
+ ]
+);
+
+// Triple asterisk
+MT.testMode(
+ 'emStrongAsterisk',
+ '*foo**bar*hello** world',
+ [
+ 'em', '*foo',
+ 'emstrong', '**bar*',
+ 'strong', 'hello**',
+ null, ' world'
+ ]
+);
+
+// Triple underscore
+MT.testMode(
+ 'emStrongUnderscore',
+ '_foo__bar_hello__ world',
+ [
+ 'em', '_foo',
+ 'emstrong', '__bar_',
+ 'strong', 'hello__',
+ null, ' world'
+ ]
+);
+
+// Triple mixed
+// "...same character must be used to open and close an emphasis span.""
+MT.testMode(
+ 'emStrongMixed',
+ '_foo**bar*hello__ world',
+ [
+ 'em', '_foo',
+ 'emstrong', '**bar*hello__ world'
+ ]
+);
+
+MT.testMode(
+ 'emStrongMixed',
+ '*foo__bar_hello** world',
+ [
+ 'em', '*foo',
+ 'emstrong', '__bar_hello** world'
+ ]
+);
+
+// These characters should be escaped:
+// \ backslash
+// ` backtick
+// * asterisk
+// _ underscore
+// {} curly braces
+// [] square brackets
+// () parentheses
+// # hash mark
+// + plus sign
+// - minus sign (hyphen)
+// . dot
+// ! exclamation mark
+//
+// Backtick (code)
+MT.testMode(
+ 'escapeBacktick',
+ 'foo \\`bar\\`',
+ [
+ null, 'foo \\`bar\\`'
+ ]
+);
+MT.testMode(
+ 'doubleEscapeBacktick',
+ 'foo \\\\`bar\\\\`',
+ [
+ null, 'foo \\\\',
+ 'comment', '`bar\\\\`'
+ ]
+);
+// Asterisk (em)
+MT.testMode(
+ 'escapeAsterisk',
+ 'foo \\*bar\\*',
+ [
+ null, 'foo \\*bar\\*'
+ ]
+);
+MT.testMode(
+ 'doubleEscapeAsterisk',
+ 'foo \\\\*bar\\\\*',
+ [
+ null, 'foo \\\\',
+ 'em', '*bar\\\\*'
+ ]
+);
+// Underscore (em)
+MT.testMode(
+ 'escapeUnderscore',
+ 'foo \\_bar\\_',
+ [
+ null, 'foo \\_bar\\_'
+ ]
+);
+MT.testMode(
+ 'doubleEscapeUnderscore',
+ 'foo \\\\_bar\\\\_',
+ [
+ null, 'foo \\\\',
+ 'em', '_bar\\\\_'
+ ]
+);
+// Hash mark (headers)
+MT.testMode(
+ 'escapeHash',
+ '\\# foo',
+ [
+ null, '\\# foo'
+ ]
+);
+MT.testMode(
+ 'doubleEscapeHash',
+ '\\\\# foo',
+ [
+ null, '\\\\# foo'
+ ]
+);
View
2 mode/stex/index.html
@@ -92,5 +92,7 @@
<p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
+ <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#stex_*">normal</a>, <a href="../../test/index.html#verbose,stex_*">verbose</a>.</p>
+
</body>
</html>
View
231 mode/stex/test.html
@@ -1,231 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <meta charset="utf-8">
- <title>CodeMirror: sTeX mode</title>
- <link rel="stylesheet" href="../../lib/codemirror.css">
- <script src="../../lib/codemirror.js"></script>
- <script src="stex.js"></script>
- <link rel="stylesheet" href="../../test/mode_test.css">
- <script src="../../test/mode_test.js"></script>
- <link rel="stylesheet" href="../../doc/docs.css">
- </head>
- <body>
- <h1>Tests for the sTeX Mode</h1>
- <h2>Basics</h2>
- <script language="javascript">
- MT = ModeTest;
-
- MT.test('foo',
- null, 'foo');
-
- MT.test('foo bar',
- null, 'foo bar');
- </script>
-
- <h2>Tags</h2>
- <script language="javascript">
- MT.test('\\begin{document}\n\\end{document}',
- 'tag', '\\begin',
- 'bracket', '{',
- 'atom', 'document',
- 'bracket', '}',
- 'tag', '\\end',
- 'bracket', '{',
- 'atom', 'document',
- 'bracket', '}');
-
- MT.test('\\begin{equation}\n E=mc^2\n\\end{equation}',
- 'tag', '\\begin',
- 'bracket', '{',
- 'atom', 'equation',
- 'bracket', '}',
- null, ' E=mc^2',
- 'tag', '\\end',
- 'bracket', '{',
- 'atom', 'equation',
- 'bracket', '}');
-
- MT.test('\\begin{module}[]',
- 'tag', '\\begin',
- 'bracket', '{',
- 'atom', 'module',
- 'bracket', '}[]');
-
- MT.test('\\begin{module}[id=bbt-size]',
- 'tag', '\\begin',
- 'bracket', '{',
- 'atom', 'module',
- 'bracket', '}[',
- null, 'id=bbt-size',
- 'bracket', ']');
-
- MT.test('\\importmodule[b-b-t]{b-b-t}',
- 'tag', '\\importmodule',
- 'bracket', '[',
- 'string', 'b-b-t',
- 'bracket', ']{',
- 'builtin', 'b-b-t',
- 'bracket', '}');
-
- MT.test('\\importmodule[\\KWARCslides{dmath/en/cardinality}]{card}',
- 'tag', '\\importmodule',
- 'bracket', '[',
- 'tag', '\\KWARCslides',
- 'bracket', '{',
- 'string', 'dmath/en/cardinality',
- 'bracket', '}]{',
- 'builtin', 'card',
- 'bracket', '}');
-
- MT.test('\\PSforPDF[1]{#1}', // could treat #1 specially
- 'tag', '\\PSforPDF',
- 'bracket', '[',
- 'atom', '1',
- 'bracket', ']{',
- null, '#1',
- 'bracket', '}');
- </script>
-
- <h2>Comments</h2>
- <script language="javascript">
- MT.test('% foo',
- 'comment', '% foo');
-
- MT.test('\\item% bar',
- 'tag', '\\item',
- 'comment', '% bar');
-
- MT.test(' % \\item',
- null, ' ',
- 'comment', '% \\item');
-
- MT.test('%\nfoo',
- 'comment', '%',
- null, 'foo');
- </script>
-
- <h2>Errors</h2>
- <script language="javascript">
- MT.test('\\begin}{',
- 'tag', '\\begin',
- 'error', '}',
- 'bracket', '{');
-
- MT.test('\\item]{',
- 'tag', '\\item',
- 'error', ']',
- 'bracket', '{');
-
- MT.test('% }',
- 'comment', '% }');
- </script>
-
- <h2>Character Escapes</h2>
- <script language="javascript">
- MT.test('the \\# key',
- null, 'the ',
- 'tag', '\\#',
- null, ' key');
-
- MT.test('a \\$5 stetson',
- null, 'a ',
- 'tag', '\\$',
- 'atom', 5,
- null, ' stetson');
-
- MT.test('100\\% beef',
- 'atom', '100',
- 'tag', '\\%',
- null, ' beef');
-
- MT.test('L \\& N',
- null, 'L ',
- 'tag', '\\&',
- null, ' N');
-
- MT.test('foo\\_bar',
- null, 'foo',
- 'tag', '\\_',
- null, 'bar');
-
- MT.test('\\emph{\\{}',
- 'tag', '\\emph',
- 'bracket','{',
- 'tag', '\\{',
- 'bracket','}');
-
- MT.test('\\emph{\\}}',
- 'tag', '\\emph',
- 'bracket','{',
- 'tag', '\\}',
- 'bracket','}');
-
- MT.test('section \\S1',
- null, 'section ',
- 'tag', '\\S',
- 'atom', '1');
-
- MT.test('para \\P2',
- null, 'para ',
- 'tag', '\\P',
- 'atom', '2');
-
- </script>
-
- <h2>Spacing control</h2>
-
- <script language="javascript">
- MT.test('x\\,y', // thinspace
- null, 'x',
- 'tag', '\\,',
- null, 'y');
-
- MT.test('x\\;y', // thickspace
- null, 'x',
- 'tag', '\\;',
- null, 'y');
-
- MT.test('x\\!y', // negative thinspace
- null, 'x',
- 'tag', '\\!',
- null, 'y');
-
- MT.test('J.\\ L.\\ is', // period not ending a sentence
- null, 'J.\\ L.\\ is'); // maybe could be better
-
- MT.test('X\\@. The', // period ending a sentence
- null, 'X',
- 'tag', '\\@',
- null, '. The');
-
- MT.test('{\\em If\\/} I', // italic correction
- 'bracket', '{',
- 'tag', '\\em',
- null, ' If',
- 'tag', '\\/',
- 'bracket', '}',
- null, ' I');
-
- </script>
-
- <h2>New Commands</h2>
-
- Should be able to define a new command that happens to be a method on Array
- (e.g. <tt>pop</tt>):
- <script language="javascript">
- MT.test('\\newcommand{\\pop}',
- 'tag', '\\newcommand',
- 'bracket', '{',
- 'tag', '\\pop',
- 'bracket', '}');
- </script>
-
- <h2>Summary</h2>
- <script language="javascript">
- MT.printSummary();
- </script>
-
- </body>
-</html>
-
View
343 mode/stex/test.js
@@ -0,0 +1,343 @@
+var MT = ModeTest;
+MT.modeName = 'stex';
+MT.modeOptions = {};
+
+MT.testMode(
+ 'word',
+ 'foo',
+ [
+ null, 'foo'
+ ]
+);
+
+MT.testMode(
+ 'twoWords',
+ 'foo bar',
+ [
+ null, 'foo bar'
+ ]
+);
+
+MT.testMode(
+ 'beginEndDocument',
+ '\\begin{document}\n\\end{document}',
+ [
+ 'tag', '\\begin',
+ 'bracket', '{',
+ 'atom', 'document',
+ 'bracket', '}',
+ 'tag', '\\end',
+ 'bracket', '{',
+ 'atom', 'document',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'beginEndEquation',
+ '\\begin{equation}\n E=mc^2\n\\end{equation}',
+ [
+ 'tag', '\\begin',
+ 'bracket', '{',
+ 'atom', 'equation',
+ 'bracket', '}',
+ null, ' E=mc^2',
+ 'tag', '\\end',
+ 'bracket', '{',
+ 'atom', 'equation',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'beginModule',
+ '\\begin{module}[]',
+ [
+ 'tag', '\\begin',
+ 'bracket', '{',
+ 'atom', 'module',
+ 'bracket', '}[]'
+ ]
+);
+
+MT.testMode(
+ 'beginModuleId',
+ '\\begin{module}[id=bbt-size]',
+ [
+ 'tag', '\\begin',
+ 'bracket', '{',
+ 'atom', 'module',
+ 'bracket', '}[',
+ null, 'id=bbt-size',
+ 'bracket', ']'
+ ]
+);
+
+MT.testMode(
+ 'importModule',
+ '\\importmodule[b-b-t]{b-b-t}',
+ [
+ 'tag', '\\importmodule',
+ 'bracket', '[',
+ 'string', 'b-b-t',
+ 'bracket', ']{',
+ 'builtin', 'b-b-t',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'importModulePath',
+ '\\importmodule[\\KWARCslides{dmath/en/cardinality}]{card}',
+ [
+ 'tag', '\\importmodule',
+ 'bracket', '[',
+ 'tag', '\\KWARCslides',
+ 'bracket', '{',
+ 'string', 'dmath/en/cardinality',
+ 'bracket', '}]{',
+ 'builtin', 'card',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'psForPDF',
+ '\\PSforPDF[1]{#1}', // could treat #1 specially
+ [
+ 'tag', '\\PSforPDF',
+ 'bracket', '[',
+ 'atom', '1',
+ 'bracket', ']{',
+ null, '#1',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'comment',
+ '% foo',
+ [
+ 'comment', '% foo'
+ ]
+);
+
+MT.testMode(
+ 'tagComment',
+ '\\item% bar',
+ [
+ 'tag', '\\item',
+ 'comment', '% bar'
+ ]
+);
+
+MT.testMode(
+ 'commentTag',
+ ' % \\item',
+ [
+ null, ' ',
+ 'comment', '% \\item'
+ ]
+);
+
+MT.testMode(
+ 'commentLineBreak',
+ '%\nfoo',
+ [
+ 'comment', '%',
+ null, 'foo'
+ ]
+);
+
+MT.testMode(
+ 'tagErrorCurly',
+ '\\begin}{',
+ [
+ 'tag', '\\begin',
+ 'error', '}',
+ 'bracket', '{'
+ ]
+);
+
+MT.testMode(
+ 'tagErrorSquare',
+ '\\item]{',
+ [
+ 'tag', '\\item',
+ 'error', ']',
+ 'bracket', '{'
+ ]
+);
+
+MT.testMode(
+ 'commentCurly',
+ '% }',
+ [
+ 'comment', '% }'
+ ]
+);
+
+MT.testMode(
+ 'tagHash',
+ 'the \\# key',
+ [
+ null, 'the ',
+ 'tag', '\\#',
+ null, ' key'
+ ]
+);
+
+MT.testMode(
+ 'tagNumber',
+ 'a \\$5 stetson',
+ [
+ null, 'a ',
+ 'tag', '\\$',
+ 'atom', 5,
+ null, ' stetson'
+ ]
+);
+
+MT.testMode(
+ 'tagPercent',
+ '100\\% beef',
+ [
+ 'atom', '100',
+ 'tag', '\\%',
+ null, ' beef'
+ ]
+);
+
+MT.testMode(
+ 'tagAmpersand',
+ 'L \\& N',
+ [
+ null, 'L ',
+ 'tag', '\\&',
+ null, ' N'
+ ]
+);
+
+MT.testMode(
+ 'tagUnderscore',
+ 'foo\\_bar',
+ [
+ null, 'foo',
+ 'tag', '\\_',
+ null, 'bar'
+ ]
+);
+
+MT.testMode(
+ 'tagBracketOpen',
+ '\\emph{\\{}',
+ [
+ 'tag', '\\emph',
+ 'bracket', '{',
+ 'tag', '\\{',
+ 'bracket', '}'
+ ]
+);
+
+MT.testMode(
+ 'tagBracketClose',
+ '\\emph{\\}}',
+ [