[gtksourceview] html: add support for headings styling



commit b04dc97a62fc09b558beffbfc486ccecc943c662
Author: Andreas Fuchs <anduchs gmail com>
Date:   Fri May 31 10:56:13 2013 +0200

    html: add support for headings styling
    
    - Add support for def:headings1 to 5 for h1 to h5 tags in html
    with working attribute highlighting

 data/language-specs/html.lang |  100 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)
---
diff --git a/data/language-specs/html.lang b/data/language-specs/html.lang
index 8583a98..8d98b2b 100644
--- a/data/language-specs/html.lang
+++ b/data/language-specs/html.lang
@@ -37,6 +37,12 @@
         <style id="attrib-value" _name="Attribute Value" map-to="xml:attribute-value"/>
         <style id="dtd" _name="DTD" map-to="xml:doctype"/>
         <style id="error" _name="Error" map-to="xml:error"/>
+        <style id="title" _name="Page title" map-to="def:heading0"/>
+        <style id="h1" _name="Heading level 1" map-to="def:heading1"/>
+        <style id="h2" _name="Heading level 2" map-to="def:heading2"/>
+        <style id="h3" _name="Heading level 3" map-to="def:heading3"/>
+        <style id="h4" _name="Heading level 4" map-to="def:heading4"/>
+        <style id="h5" _name="Heading level 5" map-to="def:heading5"/>
     </styles>
 
     <default-regex-options case-sensitive="false"/>
@@ -65,6 +71,99 @@
             <end></end>
         </context>
 
+        <context id="headings">
+            <include>
+                <context id="title" style-inside="true" style-ref="title" end-at-line-end="true">
+                    <start>&lt;title&gt;</start>
+                    <end>&lt;/title&gt;</end>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context sub-pattern="0" where="end" style-ref="tag"/>
+                    </include>
+                </context>
+                <context id="h1" end-at-line-end="true">
+                    <start>&lt;\s*h1</start>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context ref="generic-tag"/>
+                        <context id="h1-inside" style-inside="true" style-ref="h1" end-at-line-end="true" 
end-parent="true">
+                            <start>&gt;</start>
+                            <end>&lt;\s*/h1\s*&gt;</end>
+                            <include>
+                                <context sub-pattern="0" where="start" style-ref="tag"/>
+                                <context sub-pattern="0" where="end" style-ref="tag"/>
+                                <!-- We cannot match any further here, because matching to tag will override 
our end-match -->
+                            </include>
+                        </context>
+                    </include>
+                </context>
+                <context id="h2" end-at-line-end="true">
+                    <start>&lt;\s*h2</start>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context ref="generic-tag"/>
+                        <context id="h2-inside" style-inside="true" style-ref="h2" end-at-line-end="true" 
end-parent="true">
+                            <start>&gt;</start>
+                            <end>&lt;\s*/h2\s*&gt;</end>
+                            <include>
+                                <context sub-pattern="0" where="start" style-ref="tag"/>
+                                <context sub-pattern="0" where="end" style-ref="tag"/>
+                                <!-- We cannot match any further here, because matching to tag will override 
our end-match -->
+                            </include>
+                        </context>
+                    </include>
+                </context>
+                <context id="h3" end-at-line-end="true">
+                    <start>&lt;\s*h3</start>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context ref="generic-tag"/>
+                        <context id="h3-inside" style-inside="true" style-ref="h3" end-at-line-end="true" 
end-parent="true">
+                            <start>&gt;</start>
+                            <end>&lt;\s*/h3\s*&gt;</end>
+                            <include>
+                                <context sub-pattern="0" where="start" style-ref="tag"/>
+                                <context sub-pattern="0" where="end" style-ref="tag"/>
+                                <!-- We cannot match any further here, because matching to tag will override 
our end-match -->
+                            </include>
+                        </context>
+                    </include>
+                </context>
+                <context id="h4" end-at-line-end="true">
+                    <start>&lt;\s*h4</start>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context ref="generic-tag"/>
+                        <context id="h4-inside" style-inside="true" style-ref="h4" end-at-line-end="true" 
end-parent="true">
+                            <start>&gt;</start>
+                            <end>&lt;\s*/h4\s*&gt;</end>
+                            <include>
+                                <context sub-pattern="0" where="start" style-ref="tag"/>
+                                <context sub-pattern="0" where="end" style-ref="tag"/>
+                                <!-- We cannot match any further here, because matching to tag will override 
our end-match -->
+                            </include>
+                        </context>
+                    </include>
+                </context>
+                <context id="h5" end-at-line-end="true">
+                    <start>&lt;\s*h5</start>
+                    <include>
+                        <context sub-pattern="0" where="start" style-ref="tag"/>
+                        <context ref="generic-tag"/>
+                        <context id="h5-inside" style-inside="true" style-ref="h5" end-at-line-end="true" 
end-parent="true">
+                            <start>&gt;</start>
+                            <end>&lt;\s*/h5\s*&gt;</end>
+                            <include>
+                                <context sub-pattern="0" where="start" style-ref="tag"/>
+                                <context sub-pattern="0" where="end" style-ref="tag"/>
+                                <!-- We cannot match any further here, because matching to tag will override 
our end-match -->
+                            </include>
+                        </context>
+                    </include>
+                </context>
+            </include>
+        </context>
+
         <context id="generic-tag">
             <include>
 
@@ -170,6 +269,7 @@
                 <context ref="xml:cdata"/>
                 <context ref="comment"/>
                 <context ref="dtd"/>
+                <context ref="headings"/>
                 <context ref="style"/>
                 <context ref="script"/>
                 <context ref="tag"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]