Patch Markdown syntax

closes #963
see #977
This commit is contained in:
sharkdp 2020-05-11 20:22:50 +02:00
parent ce4717144a
commit 48441b99ef
2 changed files with 179 additions and 6 deletions

View File

@ -1,22 +1,27 @@
# Upcoming release
# unreleased
## Features
## Bugfixes
## Other
## New syntaxes
## New themes
## `bat` as a library
## Packaging
# v0.15.1
## Bugfixes
- Fix highlighting of Markdown files, see #963 and #977
- Fix `base16` theme (was broken since in v0.14), see #972, #934 and #979 (@mk12).
Users suffering from #865 ("no color for bat in ssh from a Windows client") can use the `ansi-dark` and `ansi-light` themes from now on.
## Other
## New syntaxes
- Fortran, see #957
- Email (@mariozaizar)
- QML, see #962 (@pylipp)
## New themes
## `bat` as a library
## Packaging
# v0.15.0
## Features

View File

@ -0,0 +1,168 @@
diff --git syntaxes/01_Packages/Markdown/Markdown.sublime-syntax syntaxes/01_Packages/Markdown/Markdown.sublime-syntax
index 19dc685d..6afd87ae 100644
--- syntaxes/01_Packages/Markdown/Markdown.sublime-syntax
+++ syntaxes/01_Packages/Markdown/Markdown.sublime-syntax
@@ -24,7 +24,6 @@ variables:
)
[ \t]*$ # followed by any number of tabs or spaces, followed by the end of the line
)
- setext_escape: ^(?=\s{0,3}(?:---+|===+)\s*$)
block_quote: (?:[ ]{,3}>(?:.|$)) # between 0 and 3 spaces, followed by a greater than sign, followed by any character or the end of the line
atx_heading: (?:[#]{1,6}\s*) # between 1 and 6 hashes, followed by any amount of whitespace
indented_code_block: (?:[ ]{4}|\t) # 4 spaces or a tab
@@ -277,69 +276,40 @@ contexts:
8: markup.underline.link.markdown
push: [link-ref-def, after-link-title, link-title]
- match: '^(?=\S)(?![=-]{3,}\s*$)'
- branch_point: heading2-branch
- branch:
- - not-heading2
- - heading2
-
- not-paragraph:
- - match: |-
- (?x) # pop out of this context when one of the following conditions are met:
- ^(?:
- \s*$ # the line is blank (or only contains whitespace)
- | (?=
- {{block_quote}} # a block quote begins the line
- | [ ]{,3}[*+-][ ] # an unordered list item begins the line
- | [ ]{,3}1[.][ ] # an ordered list item with number "1" begins the line
- | \# # an ATX heading begins the line
- | [ ]{,3}<( # all types of HTML blocks except type 7 may interrupt a paragraph
- {{html_tag_block_end_at_close_tag}} # 1
- | !-- # 2
- | \? # 3
- | ![A-Z] # 4
- | !\[CDATA\[ # 5
- | {{html_tag_block_end_at_blank_line}} # 6
+ push:
+ - meta_scope: meta.paragraph.markdown
+ - match: |-
+ (?x) # pop out of this context when one of the following conditions are met:
+ ^(?:
+ \s*$ # the line is blank (or only contains whitespace)
+ | (?=
+ {{block_quote}} # a block quote begins the line
+ | [ ]{,3}[*+-][ ] # an unordered list item begins the line
+ | [ ]{,3}1[.][ ] # an ordered list item with number "1" begins the line
+ | \# # an ATX heading begins the line
+ | [ ]{,3}<( # all types of HTML blocks except type 7 may interrupt a paragraph
+ {{html_tag_block_end_at_close_tag}} # 1
+ | !-- # 2
+ | \? # 3
+ | ![A-Z] # 4
+ | !\[CDATA\[ # 5
+ | {{html_tag_block_end_at_blank_line}} # 6
+ )
)
)
- )
- pop: true
-
- not-heading2:
- - include: not-paragraph
- - match: (?=\S)
- branch_point: heading1-branch
- branch:
- - paragraph
- - heading1
- - match: ''
- pop: true
-
- paragraph:
- - meta_scope: meta.paragraph.markdown
- - match: ^\s{0,3}===+\s*$
- fail: heading1-branch
- - match: ^\s{0,3}---+\s*$
- fail: heading2-branch
- - include: not-paragraph
- - include: inline-bold-italic-linebreak
- - include: scope:text.html.basic
-
- heading1:
- - meta_scope: markup.heading.1.markdown
- - include: inline-bold-italic-linebreak
- - match: '^[ \t]{0,3}(={3,})(?=[ \t]*$)'
- captures:
- 1: markup.heading.1.setext.markdown punctuation.definition.heading.setext.markdown
- pop: true
-
- heading2:
- - meta_scope: markup.heading.2.markdown
- - include: inline-bold-italic-linebreak
- - match: '^[ \t]{0,3}(-{3,})(?=[ \t]*$)'
- captures:
- 1: markup.heading.2.setext.markdown punctuation.definition.heading.setext.markdown
- pop: true
-
+ pop: true
+ - include: inline-bold-italic-linebreak
+ - include: scope:text.html.basic
+ - match: '^(={3,})(?=[ \t]*$)'
+ scope: markup.heading.1.setext.markdown
+ captures:
+ 1: punctuation.definition.heading.setext.markdown
+ pop: true
+ - match: '^(-{3,})(?=[ \t]*$)'
+ scope: markup.heading.2.setext.markdown
+ captures:
+ 1: punctuation.definition.heading.setext.markdown
+ pop: true
link-ref-def:
- meta_scope: meta.link.reference.def.markdown
- match: ''
@@ -430,8 +400,6 @@ contexts:
push:
- meta_scope: markup.bold.markdown
- meta_content_scope: markup.italic.markdown
- - match: '{{setext_escape}}'
- pop: true
- match: |-
(?x)
[ \t]*\*{4,} # if there are more than 3 its not applicable to be bold or italic
@@ -446,8 +414,6 @@ contexts:
scope: punctuation.definition.bold.end.markdown
set:
- meta_content_scope: markup.italic.markdown
- - match: '{{setext_escape}}'
- pop: true
- match: |-
(?x)
[ \t]*\*{3,} # if there are more than 3 its not applicable to be bold or italic
@@ -463,8 +429,6 @@ contexts:
scope: punctuation.definition.italic.end.markdown
set:
- meta_content_scope: markup.bold.markdown
- - match: '{{setext_escape}}'
- pop: true
- match: |-
(?x)
[ \t]*\*{3,} # if there are more than 3 its not applicable to be bold or italic
@@ -727,8 +691,6 @@ contexts:
scope: punctuation.definition.italic.begin.markdown
push:
- meta_scope: markup.italic.markdown
- - match: '{{setext_escape}}'
- pop: true
- match: |-
(?x)
[ \t]*\*{4,} # if there are more than 3 its not applicable to be bold or italic
@@ -745,8 +707,6 @@ contexts:
scope: punctuation.definition.italic.begin.markdown
push:
- meta_scope: markup.italic.markdown
- - match: '{{setext_escape}}'
- pop: true
- match: |-
(?x)
[ \t]*_{4,} # if there are more than 3 its not applicable to be bold or italic
@@ -773,8 +733,6 @@ contexts:
- include: bold-italic-trailing
bold-italic-trailing:
- include: scope:text.html.basic
- - match: '{{setext_escape}}'
- pop: true
- match: ^\s*$\n?
scope: invalid.illegal.non-terminated.bold-italic.markdown
pop: true