Skip to content

Commit

Permalink
[Markdown] more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall committed Feb 13, 2017
1 parent 367afa2 commit 4abd6fb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
33 changes: 25 additions & 8 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ variables:
\s* # Optional whitespace
(\))
)
skip_html_tags: '(?:<[^>]+>)'
skip_self_closing_html_tags: '(?:<(?:hr|br)\b[^>]*>)'
skip_html_tag_content: '(?:<[^>]+[^<]*</[^>]+>)'
skip_html_tags: '(?:{{skip_self_closing_html_tags}}|{{skip_html_tag_content}})'
contexts:
main:
- match: |-
Expand Down Expand Up @@ -241,7 +243,11 @@ contexts:
)
| \*{3,} # not applicable
| [ \t]\*+ # Match whitespace followed by the style closer because it doesn't close the style
| (?!\*\*). # Everything else besides style closer
| (?!
{{skip_html_tags}} # emulate possessive quantifers by repeating patterns
| {{backticks}}
| {{escape}}
| \*\*). # Everything else besides style closer
)+
\*\* # Close
)
Expand All @@ -262,7 +268,7 @@ contexts:
- include: italic
- match: |-
(?x)
(\b__)(?=\S)(?!_) # Open
(\b__)(?=\S)(?!_) # Open
(?=
(?:
{{skip_html_tags}} # HTML tags
Expand All @@ -278,7 +284,11 @@ contexts:
)
| _{3,} # not applicable
| [ \t]_+ # Match whitespace followed by the style closer because it doesn't close the style
| (?!__). # Everything else besides style closer
| (?!
{{skip_html_tags}} # emulate possessive quantifers by repeating patterns
| {{backticks}}
| {{escape}}
| __). # Everything else besides style closer
)+
__ # Close
)
Expand Down Expand Up @@ -426,7 +436,11 @@ contexts:
)
| \*{2,} # Must be bold opener or closer or not applicable
| [ \t]\*+ # Match whitespace followed by the style closer because it doesn't close the style
| (?!\*). # Everything else besides style closer
| (?!
{{skip_html_tags}} # emulate possessive quantifers by repeating patterns
| {{backticks}}
| {{escape}}
| \*). # Everything else besides style closer
)+
\* # Close
)
Expand All @@ -447,7 +461,7 @@ contexts:
- include: bold
- match: |-
(?x)
(\b_)(?=\S)(?!_) # Open
(\b_)(?=\S)(?!_) # Open
(?=
(?:
{{skip_html_tags}} # HTML tags
Expand All @@ -463,7 +477,11 @@ contexts:
)
| _{2,} # Must be bold opener or closer or not applicable
| [ \t]_+ # Match whitespace followed by the style closer because it doesn't close the style
| (?!_). # Everything else besides style closer
| (?!
{{skip_html_tags}} # emulate possessive quantifers by repeating patterns
| {{backticks}}
| {{escape}}
| _). # Everything else besides style closer
)+
_ # Close
)
Expand All @@ -475,7 +493,6 @@ contexts:
(?x)
[ \t]*_{3,} # if there are more than 3 its not applicable to be bold or italic
| [ \t]+_(?!_) # whitespace followed by 1 is also not applicable (but whitespace followed by 2 could be bold punctuation)
- match: (\1)(?!\1)
captures:
1: punctuation.definition.italic.end.markdown
Expand Down
39 changes: 39 additions & 0 deletions Markdown/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,42 @@ more _tests <span class="test_">here</span>_
| ^ punctuation.definition.italic.begin
| ^ - punctuation.definition
| ^ punctuation.definition.italic.end
_more `tests_` here_
| <- punctuation.definition.italic.begin
| ^^^^^^^^ markup.raw.inline
| ^ punctuation.definition.italic.end
__more `tests__` here__
| <- punctuation.definition.bold.begin
| ^^^^^^^^^ markup.raw.inline
| ^^ punctuation.definition.bold.end
_test <span>text_ not formatted</span>
| <- - punctuation
| ^ - punctuation
__test <span>text__ not formatted</span>
| <- - punctuation
| ^^ - punctuation
*test <span>text* not formatted</span>
| <- - punctuation
| ^ - punctuation
**test <span>text** not formatted</span>
| <- - punctuation
| ^^ - punctuation
_test <span>text **formatted**</span>_
| <- punctuation
| ^^ punctuation
| ^^ punctuation
| ^ punctuation
*test <span>text __formatted__</span>*
| <- punctuation
| ^^ punctuation
| ^^ punctuation
| ^ punctuation
*test <span>text __formatted__</span>* **more** _text_
| <- punctuation
| ^^ punctuation
| ^^ punctuation
| ^ punctuation
| ^^ punctuation
| ^^ punctuation
| ^ punctuation
| ^ punctuation

0 comments on commit 4abd6fb

Please sign in to comment.