[gtksourceview] Add support for mediawiki syntax



commit db965e3ac704c574d04023606d4b7afc4ec133ad
Author: Jean-Philippe Fleury <contact jpfleury net>
Date:   Mon Oct 8 22:00:38 2012 +0100

    Add support for mediawiki syntax
    
    https://bugzilla.gnome.org/show_bug.cgi?id=635381
    
    Signed-off-by: Carnë Draug <carandraug+dev gmail com>

 data/language-specs/Makefile.am    |    1 +
 data/language-specs/mediawiki.lang |  323 ++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                     |    1 +
 3 files changed, 325 insertions(+), 0 deletions(-)
---
diff --git a/data/language-specs/Makefile.am b/data/language-specs/Makefile.am
index da45bd0..912d6b0 100644
--- a/data/language-specs/Makefile.am
+++ b/data/language-specs/Makefile.am
@@ -62,6 +62,7 @@ LANGUAGES =                   \
        mallard.lang            \
        markdown.lang           \
        matlab.lang             \
+       mediawiki.lang          \
        modelica.lang           \
        mxml.lang               \
        nemerle.lang            \
diff --git a/data/language-specs/mediawiki.lang b/data/language-specs/mediawiki.lang
new file mode 100644
index 0000000..8c1c0b4
--- /dev/null
+++ b/data/language-specs/mediawiki.lang
@@ -0,0 +1,323 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Author: Jean-Philippe Fleury <contact jpfleury net>
+Copyright © Jean-Philippe Fleury, 2009, 2011-2012.
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<language id="mediawiki" _name="MediaWiki" version="2.0" _section="Markup">
+  <metadata>
+    <property name="block-comment-start">&lt;!--</property>
+    <property name="block-comment-end">--&gt;</property>
+  </metadata>
+  
+  <styles>
+    <style id="strong-emphasis" _name="Strong emphasis"   map-to="def:statement"/>
+    <style id="light-emphasis"  _name="Light emphasis"    map-to="def:doc-comment-element"/>
+    <style id="signature"       _name="Signature"         map-to="def:statement"/>
+    <style id="url"             _name="URL"               map-to="def:underlined"/>
+    <style id="link"            _name="Link"              map-to="def:comment"/>
+    <style id="link-symbol"     _name="Symbol on a link"  map-to="def:shebang"/>
+    <style id="line"            _name="Line"              map-to="def:type"/>
+    <style id="list"            _name="List"              map-to="def:statement"/>
+    <style id="magic-word"      _name="Magic word"        map-to="def:statement"/>
+    <style id="table-symbol"    _name="Symbol of a table" map-to="def:statement"/>
+    <style id="preformatted"    _name="Preformatted"      map-to="def:identifier"/>
+    <style id="redirect"        _name="Redirect"          map-to="def:statement"/>
+    <style id="title"           _name="Title"             map-to="def:type"/>
+    <style id="template"        _name="Template"          map-to="def:statement"/>
+  </styles>
+  
+  <definitions>
+    <!-- See <http://www.mediawiki.org/wiki/Manual:$wgUrlProtocols>. -->
+    <define-regex 
id="regex-url">(http://|https://|ftp://|irc://|gopher://|telnet://|nntp://|worldwind://|mailto:|news:)[^\s]+</define-regex>
+    
+    <define-regex id="regex-internal-link">\[\[\s*[^\[\]\s][^\[\]]*?((\|)[^\[\]\|]*)?\]\]</define-regex>
+    
+    <context id="double-emphasis" style-ref="strong-emphasis">
+      <match>'''''.+?'''''</match>
+    </context>
+    
+    <context id="strong-emphasis" style-ref="strong-emphasis">
+      <match>'''.+?'''</match>
+    </context>
+    
+    <context id="light-emphasis" style-ref="light-emphasis">
+      <match>''.+?''</match>
+    </context>
+    
+    <!-- See <http://www.mediawiki.org/wiki/Help:Signatures/fr>. -->
+    <context id="signature" style-ref="signature">
+      <match>~{3,5}</match>
+    </context>
+    
+    <context id="url" style-ref="url">
+      <match>(\%{regex-url})</match>
+      <include>
+        <context sub-pattern="1" style-ref="link"/>
+      </include>
+    </context>
+    
+    <context id="internal-link" style-ref="link">
+      <match>\%{regex-internal-link}</match>
+      <include>
+        <context sub-pattern="2" style-ref="link-symbol"/>
+      </include>
+    </context>
+    
+    <context id="external-link" style-ref="link">
+      <match extended="true">
+        (?&lt;!\[)
+        \[
+        \s*
+        (\%{regex-url})
+        [^\[\]]*
+        \]
+        (?!\])
+      </match>
+      <include>
+        <context sub-pattern="1" style-ref="url"/>
+      </include>
+    </context>
+    
+    <context id="line" style-ref="line">
+      <match>^-{4,}</match>
+    </context>
+    
+    <context id="list">
+      <match>^((\*|#(?!REDIRECT))+)\s*[^\*#\s]+</match>
+      <include>
+        <context sub-pattern="1" style-ref="list"/>
+      </include>
+    </context>
+    
+    <context id="glossary-term">
+      <match extended="true">
+        ^(;)
+        \s*
+        [^;:\s]+?
+        [^:]*
+        (:?)
+      </match>
+      <include>
+        <context sub-pattern="1" style-ref="list"/>
+        <context sub-pattern="2" style-ref="list"/>
+      </include>
+    </context>
+    
+    <context id="glossary-definition">
+      <match extended="true">
+        ^(:)
+        \s*
+        [^;:\s]+
+      </match>
+      <include>
+        <context sub-pattern="1" style-ref="list"/>
+      </include>
+    </context>
+    
+    <!-- Magic words. See <http://www.mediawiki.org/wiki/Help:Magic_words>. -->
+    
+    <context id="magic-word-1" style-ref="magic-word">
+      <prefix>__</prefix>
+      <suffix>__</suffix>
+      
+      <!-- Behavior switches. -->
+      <keyword>NOTOC</keyword>
+      <keyword>FORCETOC</keyword>
+      <keyword>TOC</keyword>
+      <keyword>NOEDITSECTION</keyword>
+      <keyword>NEWSECTIONLINK</keyword>
+      <keyword>NONEWSECTIONLINK</keyword>
+      <keyword>NOGALLERY</keyword>
+      <keyword>HIDDENCAT</keyword>
+      <keyword>NOCONTENTCONVERT</keyword>
+      <keyword>NOCC</keyword>
+      <keyword>NOTITLECONVERT</keyword>
+      <keyword>NOTC</keyword>
+      <keyword>START</keyword>
+      <keyword>END</keyword>
+      <keyword>INDEX</keyword>
+      <keyword>NOINDEX</keyword>
+      <keyword>STATICREDIRECT</keyword>
+    </context>
+    
+    <context id="magic-word-2" style-ref="magic-word">
+      <prefix>{{</prefix>
+      <suffix>}}</suffix>
+      
+      <!-- Date and time. -->
+      <keyword>CURRENTYEAR</keyword>
+      <keyword>CURRENTMONTH</keyword>
+      <keyword>CURRENTMONTHNAME</keyword>
+      <keyword>CURRENTMONTHNAMEGEN</keyword>
+      <keyword>CURRENTMONTHABBREV</keyword>
+      <keyword>CURRENTDAY</keyword>
+      <keyword>CURRENTDAY2</keyword>
+      <keyword>CURRENTDOW</keyword>
+      <keyword>CURRENTDAYNAME</keyword>
+      <keyword>CURRENTTIME</keyword>
+      <keyword>CURRENTHOUR</keyword>
+      <keyword>CURRENTWEEK</keyword>
+      <keyword>CURRENTTIMESTAMP</keyword>
+      <keyword>LOCALYEAR</keyword>
+      <keyword>LOCALMONTH</keyword>
+      <keyword>LOCALMONTHNAME</keyword>
+      <keyword>LOCALMONTHNAMEGEN</keyword>
+      <keyword>LOCALMONTHABBREV</keyword>
+      <keyword>LOCALDAY</keyword>
+      <keyword>LOCALDAY2</keyword>
+      <keyword>LOCALDOW</keyword>
+      <keyword>LOCALDAYNAME</keyword>
+      <keyword>LOCALTIME</keyword>
+      <keyword>LOCALHOUR</keyword>
+      <keyword>LOCALWEEK</keyword>
+      <keyword>LOCALTIMESTAMP</keyword>
+
+      <!-- Technical metadata. -->
+      <keyword>SITENAME</keyword>
+      <keyword>SERVER</keyword>
+      <keyword>SERVERNAME</keyword>
+      <keyword>DIRMARK</keyword>
+      <keyword>DIRECTIONMARK</keyword>
+      <keyword>SCRIPTPATH</keyword>
+      <keyword>STYLEPATH</keyword>
+      <keyword>CURRENTVERSION</keyword>
+      <keyword>CONTENTLANGUAGE</keyword>
+      <keyword>CONTENTLANG</keyword>
+      <keyword>REVISIONID</keyword>
+      <keyword>REVISIONDAY</keyword>
+      <keyword>REVISIONDAY2</keyword>
+      <keyword>REVISIONMONTH</keyword>
+      <keyword>REVISIONMONTH1</keyword>
+      <keyword>REVISIONYEAR</keyword>
+      <keyword>REVISIONTIMESTAMP</keyword>
+      <keyword>REVISIONUSER</keyword>
+
+      <!-- Statistics. -->
+      <keyword>NUMBEROFPAGES</keyword>
+      <keyword>NUMBEROFARTICLES</keyword>
+      <keyword>NUMBEROFFILES</keyword>
+      <keyword>NUMBEROFEDITS</keyword>
+      <keyword>NUMBEROFVIEWS</keyword>
+      <keyword>NUMBEROFUSERS</keyword>
+      <keyword>NUMBEROFADMINS</keyword>
+      <keyword>NUMBEROFACTIVEUSERS</keyword>
+
+      <!-- Page names. -->
+      <keyword>FULLPAGENAME</keyword>
+      <keyword>PAGENAME</keyword>
+      <keyword>BASEPAGENAME</keyword>
+      <keyword>SUBPAGENAME</keyword>
+      <keyword>SUBJECTPAGENAME</keyword>
+      <keyword>TALKPAGENAME</keyword>
+      <keyword>FULLPAGENAMEE</keyword>
+      <keyword>PAGENAMEE</keyword>
+      <keyword>BASEPAGENAMEE</keyword>
+      <keyword>SUBPAGENAMEE</keyword>
+      <keyword>SUBJECTPAGENAMEE</keyword>
+      <keyword>TALKPAGENAMEE</keyword>
+
+      <!-- Namespaces. -->
+      <keyword>NAMESPACE</keyword>
+      <keyword>SUBJECTSPACE</keyword>
+      <keyword>ARTICLESPACE</keyword>
+      <keyword>TALKSPACE</keyword>
+      <keyword>NAMESPACEE</keyword>
+      <keyword>SUBJECTSPACEE</keyword>
+      <keyword>TALKSPACEE</keyword>
+    </context>
+    
+    <context id="table">
+      <start>^\s*({\|)</start>
+      <end>^\s*(\|})</end>
+      <include>
+        <context sub-pattern="1" where="start" style-ref="table-symbol"/>
+        <context sub-pattern="1" where="end" style-ref="table-symbol"/>
+        <context ref="double-emphasis"/>
+        <context ref="strong-emphasis"/>
+        <context ref="light-emphasis"/>
+        <context ref="signature"/>
+        <context ref="url"/>
+        <context ref="internal-link"/>
+        <context ref="external-link"/>
+        <context ref="magic-word-1"/>
+        <context ref="magic-word-2"/>
+        <context ref="html:html"/>
+        <context id="table-symbol" extend-parent="false" style-ref="table-symbol">
+          <match extended="true">
+            ^\s*(\|\+ | \|-+ | !) | \| | !{2,}
+          </match>
+        </context>
+      </include>
+    </context>
+    
+    <context id="preformatted" style-ref="preformatted">
+      <match>^ +[^ ]+.*$</match>
+    </context>
+    
+    <context id="redirect">
+      <match>^(#REDIRECT)\s*(\%{regex-internal-link})</match>
+      <include>
+        <context sub-pattern="1" style-ref="redirect"/>
+        <context sub-pattern="2" style-ref="link"/>
+        <context sub-pattern="4" style-ref="link-symbol"/>
+      </include>
+    </context>
+    
+    <context id="title" style-ref="title">
+      <match>^=.+=\s*$</match>
+    </context>
+    
+    <context id="template">
+      <match>({{)\s*[^{}\s]+[^{}]*(}})</match>
+      <include>
+        <context sub-pattern="1" style-ref="template"/>
+        <context sub-pattern="2" style-ref="template"/>
+      </include>
+    </context>
+    
+    <context id="mediawiki-syntax">
+      <include>
+        <context ref="double-emphasis"/>
+        <context ref="strong-emphasis"/>
+        <context ref="light-emphasis"/>
+        <context ref="signature"/>
+        <context ref="url"/>
+        <context ref="internal-link"/>
+        <context ref="external-link"/>
+        <context ref="line"/>
+        <context ref="list"/>
+        <context ref="glossary-term"/>
+        <context ref="glossary-definition"/>
+        <context ref="magic-word-1"/>
+        <context ref="magic-word-2"/>
+        <context ref="table"/>
+        <context ref="preformatted"/>
+        <context ref="redirect"/>
+        <context ref="title"/>
+        <context ref="template"/>
+      </include>
+    </context>
+    
+    <replace id="html:embedded-lang-hook" ref="mediawiki-syntax"/>
+    
+    <context id="mediawiki">
+      <include>
+        <context ref="mediawiki-syntax"/>
+        <context ref="html:html"/>
+      </include>
+    </context>
+  </definitions>
+</language>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0accf6f..f053565 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -60,6 +60,7 @@ data/language-specs/makefile.lang
 data/language-specs/mallard.lang
 data/language-specs/markdown.lang
 data/language-specs/matlab.lang
+data/language-specs/mediawiki.lang
 data/language-specs/modelica.lang
 data/language-specs/mxml.lang
 data/language-specs/nemerle.lang


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