Skip to content

Instantly share code, notes, and snippets.

@muekoeff
Created January 5, 2020 21:34
Show Gist options
  • Save muekoeff/7e083f83411a73b10c2db85f5c8cd054 to your computer and use it in GitHub Desktop.
Save muekoeff/7e083f83411a73b10c2db85f5c8cd054 to your computer and use it in GitHub Desktop.
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
first_line_match: (^\={1,6}.*?\={1,6}) # Title, number of = doesn't have to balanced for simplicity's sake
name: "MediaWiki"
scope: text.mediawiki
contexts:
main:
# https://www.mediawiki.org/wiki/Markup_spec
- include: startofline
- include: anywhere
# vvv Start of line
startofline:
# Unary
- include: horizontal_line
- include: lists
# Binary
- include: heading
horizontal_line:
- match: "^----"
scope: keyword
lists:
- include: lists_numbered
- include: lists_bulleted
- match: "^[:;][*#:;]*"
scope: keyword
push:
- meta_scope: markup.list
- include: anywhere
- match: "\n"
pop: true
lists_bulleted:
- match: "^\\*[*#:;]*"
scope: keyword
push:
- meta_scope: markup.list.unnumbered
- include: anywhere
- match: "\n"
pop: true
lists_numbered:
- match: "^\\#+[*#:;]*"
scope: keyword
push:
- meta_scope: markup.list.numbered
- include: anywhere
- match: "\n"
pop: true
heading:
- match: "^={1,6}(?=[^=])"
scope: keyword
push:
- meta_scope: markup.heading
- match: "={1,6}"
scope: keyword
pop: true
# ^^^ Start of line
# vvv Anywhere
anywhere:
# Unary
- include: magicwords
- include: signatures
# Binary
- include: onwiki_link
- include: link
- include: bold
- include: italic
- include: transclusions
magicwords:
# https://www.mediawiki.org/wiki/Help:Magic_words
- match: "__NOTOC__|__FORCETOC__|__TOC__|__NOEDITSECTION__|__NEWSECTIONLINK__|__NONEWSECTIONLINK__|__NOGALLERY__|__HIDDENCAT__|__EXPECTUNUSEDCATEGORY__|__NOCONTENTCONVERT__|__NOCC__|__NOTITLECONVERT__|__NOTC__|__START__|__END__|__INDEX__|__NOINDEX__|__STATICREDIRECT__|__NOGLOBAL__|__DISAMBIG__"
scope: keyword
signatures:
- match: "~{3,5}"
scope: keyword
onwiki_link:
- match: "\\[\\["
scope: keyword
push:
- meta_scope: markup.underline.link
- match: "\\]]"
scope: keyword
pop: true
- match: "(\\|)(.*?)(\\]])"
captures:
1: keyword
2: text.mediawiki
3: keyword
pop: true
link:
- match: "\\["
scope: keyword
push:
- meta_scope: markup.underline.link
- match: "\\]"
scope: keyword
pop: true
- match: "( )(.*?)(\\])"
captures:
1: keyword
2: text.mediawiki
3: keyword
pop: true
bold:
- match: "'''"
scope: keyword
push:
- meta_scope: markup.bold
- match: "'''"
scope: keyword
pop: true
- include: anywhere
italic:
- match: "''"
scope: keyword
push:
- meta_scope: markup.italic
- match: "''"
scope: keyword
pop: true
- include: anywhere
transclusions:
- match: "({{/?)([a-zA-Z0-9: ]+)"
captures:
1: keyword
2: variable.function
push:
- meta_scope: meta.function.parameters
- match: "}}"
scope: keyword
pop: true
- match: "(\\|)([^|]+)(=)"
captures:
1: keyword
2: variable.function
3: keyword
- match: "\\|"
scope: keyword
- include: anywhere
# ^^^ Anywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment