diff options
-rw-r--r-- | contrib/gtksourceview-3.0/language-specs/ousia.lang | 48 | ||||
-rw-r--r-- | contrib/test.osdm | 29 |
2 files changed, 63 insertions, 14 deletions
diff --git a/contrib/gtksourceview-3.0/language-specs/ousia.lang b/contrib/gtksourceview-3.0/language-specs/ousia.lang index a4d598e..4cefac3 100644 --- a/contrib/gtksourceview-3.0/language-specs/ousia.lang +++ b/contrib/gtksourceview-3.0/language-specs/ousia.lang @@ -21,43 +21,63 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --> -<language id="ousia" _name="Ousia" version="2.0" _section="Source"> +<language id="ousia" _name="Ousia" version="2.0" _section="Markup"> <metadata> <property name="mimetypes">text/vnd.ousia</property> - <property name="globs">*.opd;*.opm</property> + <property name="globs">*.osdm</property> <property name="line-comment-start">%</property> <property name="block-comment-start">%{</property> <property name="block-comment-end">}%</property> </metadata> <styles> <style id="comment" _name="Comment" map-to="def:comment"/> - <style id="common-commands" _name="Command" map-to="def:keyword"/> - <style id="command" _name="Command" map-to="def:keyword"/> + <style id="common-commands" _name="Command" map-to="latex:common-commands"/> + <style id="command" _name="Command" map-to="latex:command"/> <style id="name" _name="Name" map-to="def:identifier"/> </styles> <definitions> <!-- An ousia command --> - <define-regex id="builtin">\\(include|import|begin|end)</define-regex> - <define-regex id="command">\\[^#[{\s]*</define-regex> - <define-regex id="name">#[^#[{}\s]*</define-regex> + <define-regex id="identifier">[a-zA-z][a-zA-z_-]*</define-regex> + <define-regex id="identifierWithNS">\%{identifier}(:\%{identifier})*</define-regex> + <define-regex id="command">(?P<command_cmd>\\\%{identifierWithNS})(?P<command_name>#\%{identifier})?</define-regex> + <define-regex id="begin_command">(?P<begin>\\begin){(?P<begin_cmd>\%{identifierWithNS})(?P<begin_name>#\%{identifier})?}</define-regex> + <define-regex id="end_command">(?P<end>\\end){(?P<end_cmd>\%{identifierWithNS})}</define-regex> + <define-regex id="builtin">\\(begin|end|import|include)</define-regex> <context id="ousia"> <include> + <!-- Begin command --> + <context id="begin-command" class="no-spell-check"> + <match>\%{begin_command}</match> + <include> + <context sub-pattern="begin" style-ref="common-commands"/> + <context sub-pattern="begin_cmd" style-ref="command"/> + <context sub-pattern="begin_name" style-ref="name"/> + </include> + </context> + + <!-- End command --> + <context id="end-command" class="no-spell-check"> + <match>\%{end_command}</match> + <include> + <context sub-pattern="end" style-ref="common-commands"/> + <context sub-pattern="end_cmd" style-ref="command"/> + </include> + </context> + <!-- Keywords --> <context id="common-commands" style-ref="common-commands" class="no-spell-check"> <match>\%{builtin}</match> </context> <!-- Any command --> - <context id="command" style-ref="command" class="no-spell-check"> + <context id="command" class="no-spell-check"> <match>\%{command}</match> + <include> + <context sub-pattern="command_cmd" style-ref="command"/> + <context sub-pattern="command_name" style-ref="name"/> + </include> </context> - <!-- Name --> - <context id="name" style-ref="name" class="no-spell-check"> - <match>\%{name}</match> - </context> - - <!-- Multiline comments --> <context id="comment-multiline" style-ref="comment"> <start>%{</start> diff --git a/contrib/test.osdm b/contrib/test.osdm new file mode 100644 index 0000000..100bc77 --- /dev/null +++ b/contrib/test.osdm @@ -0,0 +1,29 @@ +%{ + We're currently inside a block comment. + %{ + Note that block comments can be nested, easily allowing you to comment + out blocks which already contain comments. + }% +}% + +% Well, line comments, as we know them from TeX also work + +\import{meta} +\import{book} + +\domain#special_words{ + \struct#latex + \struct#ousia +} + +\book{ + \include{chapters/chapter1} + \include{chapters/chapter2} + + \begin{note}{Behaviour of "Include"} + Analogous to the `include` command in \latex, \ousia forces the included + file to be *complete* in a sense, that it must not have dangling open + commands. + \end{note} +} + |