diff options
author | Sylvain Chiron <chironsylvain@orange.fr> | 2023-02-27 00:08:46 +0100 |
---|---|---|
committer | Sylvain Chiron <chironsylvain@orange.fr> | 2023-02-27 00:08:46 +0100 |
commit | b239a26109c2d25db3c5c010f50a1890f9e5ced5 (patch) | |
tree | 8e88c0d140f3038c5d98e16b77c6413f8aee332d | |
parent | e62adde93ec8bb09eb9cdf929e6adf3888a7931e (diff) | |
download | gtksourceview-b239a26109c2d25db3c5c010f50a1890f9e5ced5.tar.gz |
html.lang: simplified management of headings; fix errors caused by embedding hooks
-rw-r--r-- | data/language-specs/html.lang | 153 |
1 files changed, 31 insertions, 122 deletions
diff --git a/data/language-specs/html.lang b/data/language-specs/html.lang index 7904ba59..e069a7cf 100644 --- a/data/language-specs/html.lang +++ b/data/language-specs/html.lang @@ -69,39 +69,37 @@ HTML tags and attributes. --> <context id="embedded-lang-hook"> - <start>\%{def:never-match}</start> - <end></end> + <match>\%{def:never-match}</match> </context> - <!-- Certain HTML tags (e.g. h1) require container contexts that - exclude highlighting from embedding languages. Languages can - replace this context when they need to highlight all content, - but not inside HTML tags and attributes. + <!-- This one is for languages such as Markdown and MediaWiki + in which HTML tags can be included. Their syntax will be + recognized in text nodes, but not in attribute values. --> - <context id="embedded-lang-hook-content"> - <start>\%{def:never-match}</start> - <end></end> + <match>\%{def:never-match}</match> </context> - <context id="heading-tag" once-only="true"> - <start>\%{def:always-match}</start> - <end>></end> + <context id="heading-element-content" style-inside="true" end-parent="true" class-disabled="no-spell-check"> + <start>></start> + <end></h[1-6]\s*></end> <include> + <context sub-pattern="0" where="start" style-ref="tag"/> <context sub-pattern="0" where="end" style-ref="tag"/> - <context ref="generic-tag"/> + <context ref="embedded-lang-hook"/> + <context ref="embedded-lang-hook-content"/> + <context extend-parent="false"> + <start>\%{def:always-match}</start> + <include> + <context ref="html"/> + </include> + </context> </include> </context> - <define-regex id="h1-close"></h1\s*></define-regex> - <define-regex id="h2-close"></h2\s*></define-regex> - <define-regex id="h3-close"></h3\s*></define-regex> - <define-regex id="h4-close"></h4\s*></define-regex> - <define-regex id="h5-close"></h5\s*></define-regex> - <define-regex id="h6-close"></h6\s*></define-regex> - <context id="headings"> <include> + <!-- Inside <title> tags, no other tags are recognized. --> <context id="title" class="no-spell-check"> <start><title\%]</start> <include> @@ -114,6 +112,7 @@ <include> <context sub-pattern="0" where="start" style-ref="tag"/> <context sub-pattern="0" where="end" style-ref="tag"/> + <context ref="xml:entity"/> <context ref="embedded-lang-hook"/> <context ref="embedded-lang-hook-content"/> </include> @@ -125,23 +124,8 @@ <start><h1\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h1" class-disabled="no-spell-check"> - <start>(?!\%{h1-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h1-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h1-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h1"/> </include> </context> @@ -149,23 +133,8 @@ <start><h2\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h2" class-disabled="no-spell-check"> - <start>(?!\%{h2-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h2-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h2-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h2"/> </include> </context> @@ -173,23 +142,8 @@ <start><h3\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h3" class-disabled="no-spell-check"> - <start>(?!\%{h3-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h3-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h3-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h3"/> </include> </context> @@ -197,23 +151,8 @@ <start><h4\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h4" class-disabled="no-spell-check"> - <start>(?!\%{h4-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h4-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h4-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h4"/> </include> </context> @@ -221,23 +160,8 @@ <start><h5\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h5" class-disabled="no-spell-check"> - <start>(?!\%{h5-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h5-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h5-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h5"/> </include> </context> @@ -245,23 +169,8 @@ <start><h6\%]</start> <include> <context sub-pattern="0" where="start" style-ref="tag"/> - <context ref="heading-tag"/> - - <context style-ref="h6" class-disabled="no-spell-check"> - <start>(?!\%{h6-close})</start> - <include> - <context end-parent="true"> - <match>(?=\%{h6-close})</match> - </context> - <context ref="embedded-lang-hook"/> - <context ref="embedded-lang-hook-content"/> - <context ref="tag"/> - </include> - </context> - - <context style-ref="tag" end-parent="true"> - <match>\%{h6-close}</match> - </context> + <context ref="generic-tag"/> + <context ref="heading-element-content" style-ref="h6"/> </include> </context> </include> |