Skip to content

Instantly share code, notes, and snippets.

@h6y3
Created June 16, 2025 23:04
Show Gist options
  • Save h6y3/4b17889c1396d98eca67af0f20fabe08 to your computer and use it in GitHub Desktop.
Save h6y3/4b17889c1396d98eca67af0f20fabe08 to your computer and use it in GitHub Desktop.
Drafts Syntax For Tiddlywiki 5
{
"name": "TiddlyWiki",
"author": "Claude AI Assistant",
"description": "Complete TiddlyWiki 5 WikiText syntax highlighting for iOS Drafts. Supports all major WikiText elements including formatting, links, widgets, macros, procedures, functions, filters, transclusions, and more.",
"sampleText": "! TiddlyWiki Sample\n\nThis is ''bold'' and //italic// text with ^^superscript^^ and ~~subscript~~.\n\n* Bullet list\n** Nested item\n# Numbered list\n\n|!Header 1|!Header 2|\n|Cell 1|Cell 2|\n\n[[Internal Link]] and [ext[External|https://example.com]]\n\n{{TranscludedTiddler}}\n\n<$button>Click Me</$button>\n\n<<myMacro param:\"value\">>\n\n[tag[important]sort[created]]",
"rangeExtensionType": {
"default": "lookAround1000"
},
"featureKeys": [
{
"id": "highlightWidgets",
"name": "Highlight Widgets",
"description": "Enable syntax highlighting for TiddlyWiki widgets like <$button>, <$list>, etc.",
"defaultValue": true
},
{
"id": "highlightFilters",
"name": "Highlight Filters",
"description": "Enable syntax highlighting for filter expressions [tag[name]sort[field]].",
"defaultValue": true
},
{
"id": "highlightMacros",
"name": "Highlight Macros",
"description": "Enable syntax highlighting for macro calls <<macro>> and definitions \\define.",
"defaultValue": true
}
],
"patterns": [
{
"comment": "HTML-style comments",
"match": "<!--[\\s\\S]*?-->",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.comment"
}
}
},
{
"comment": "Literal text blocks (no formatting)",
"match": "\\{\\{\\{([\\s\\S]*?)\\}\\}\\}",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.raw"
},
"1": {
"scope": "text.monospace"
}
}
},
{
"comment": "Code blocks with triple backticks",
"match": "^```([\\s\\S]*?)^```$",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.code"
},
"1": {
"scope": "text.monospace"
}
}
},
{
"comment": "Typed blocks with $$$",
"match": "^\\$\\$\\$\\s*([^\\n]*)\\n([\\s\\S]*?)^\\$\\$\\$$",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.code"
},
"1": {
"scope": "markup.heading"
},
"2": {
"scope": "text.monospace"
}
}
},
{
"comment": "TiddlyWiki headings with !",
"match": "^(!{1,6})\\s+(.+)$",
"exclusive": true,
"captures": {
"1": {
"scope": "markup.heading"
},
"2": {
"scope": "text.heading"
}
}
},
{
"comment": "Horizontal rules",
"match": "^---+$",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.heading"
}
}
},
{
"comment": "Table rows with headers",
"match": "^\\|(.*)\\|\\s*$",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.table"
},
"1": {
"scope": "text.normal"
}
}
},
{
"comment": "Block quotes",
"match": "^(>{1,})\\s+(.+)$",
"exclusive": true,
"captures": {
"1": {
"scope": "markup.quote"
},
"2": {
"scope": "text.quote"
}
}
},
{
"comment": "Bullet lists",
"match": "^(\\s*)(\\*{1,})\\s+(.+)$",
"exclusive": true,
"captures": {
"1": {
"scope": "text.normal"
},
"2": {
"scope": "markup.list"
},
"3": {
"scope": "text.normal"
}
}
},
{
"comment": "Numbered lists",
"match": "^(\\s*)(#{1,})\\s+(.+)$",
"exclusive": true,
"captures": {
"1": {
"scope": "text.normal"
},
"2": {
"scope": "markup.list"
},
"3": {
"scope": "text.normal"
}
}
},
{
"comment": "Definition lists",
"match": "^;([^:]+):(.+)$",
"exclusive": true,
"captures": {
"0": {
"scope": "markup.list"
},
"1": {
"scope": "text.bold"
},
"2": {
"scope": "text.normal"
}
}
},
{
"comment": "Macro definitions",
"match": "^\\\\define\\s+(\\w+)\\(([^)]*)\\)([\\s\\S]*?)^\\\\end",
"exclusive": true,
"featureKeys": "highlightMacros",
"captures": {
"0": {
"scope": "markup.code"
},
"1": {
"scope": "text.bold"
},
"2": {
"scope": "text.italic"
},
"3": {
"scope": "text.normal"
}
}
},
{
"comment": "Procedure definitions (TW 5.3+)",
"match": "^\\\\procedure\\s+(\\w+)\\(([^)]*)\\)([\\s\\S]*?)^\\\\end",
"exclusive": true,
"featureKeys": "highlightMacros",
"captures": {
"0": {
"scope": "markup.code"
},
"1": {
"scope": "text.bold"
},
"2": {
"scope": "text.italic"
},
"3": {
"scope": "text.normal"
}
}
},
{
"comment": "Function definitions (TW 5.3+)",
"match": "^\\\\function\\s+(\\w+)\\(([^)]*)\\)\\s*(.+)$",
"exclusive": true,
"featureKeys": "highlightMacros",
"captures": {
"0": {
"scope": "markup.code"
},
"1": {
"scope": "text.bold"
},
"2": {
"scope": "text.italic"
},
"3": {
"scope": "color.blue"
}
}
},
{
"comment": "TiddlyWiki widgets",
"match": "(<\\$)(\\w+)([^>]*?)(\\s*/?>)",
"exclusive": false,
"featureKeys": "highlightWidgets",
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.bold, color.purple"
},
"3": {
"scope": "text.italic"
},
"4": {
"scope": "markup"
}
}
},
{
"comment": "Widget closing tags",
"match": "(<\\/\\$)(\\w+)(>)",
"exclusive": false,
"featureKeys": "highlightWidgets",
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.bold, color.purple"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Conditional shortcuts (TW 5.3.3+)",
"match": "(<%)(if|else|endif)(\\s[^%]*?)(%>)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.bold, color.orange"
},
"3": {
"scope": "text.italic"
},
"4": {
"scope": "markup"
}
}
},
{
"comment": "Filter expressions",
"match": "(\\[)([^\\]]+)(\\])",
"exclusive": false,
"featureKeys": "highlightFilters",
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.blue"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Macro calls",
"match": "(<<)([^>]+)(>>)",
"exclusive": false,
"featureKeys": "highlightMacros",
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.green"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Field transclusions",
"match": "(\\{\\{)([^}]*!!\\w+)(\\}\\})",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.cyan"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Template transclusions",
"match": "(\\{\\{)([^}]*\\|\\|[^}]*)(\\}\\})",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.cyan"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Basic transclusions",
"match": "(\\{\\{)([^}]+)(\\}\\})",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.cyan"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "External links with display text",
"match": "(\\[ext\\[)([^\\|]+)(\\|)([^\\]]+)(\\]\\])",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.link"
},
"3": {
"scope": "markup"
},
"4": {
"scope": "color.blue"
},
"5": {
"scope": "markup"
}
}
},
{
"comment": "Images with alt text",
"match": "(\\[img\\[)([^\\|]+)(\\|)([^\\]]+)(\\]\\])",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.italic"
},
"3": {
"scope": "markup"
},
"4": {
"scope": "color.blue"
},
"5": {
"scope": "markup"
}
}
},
{
"comment": "Basic images",
"match": "(\\[img\\[)([^\\]]+)(\\]\\])",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.blue"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Internal links with display text",
"match": "(\\[\\[)([^\\|]+)(\\|)([^\\]]+)(\\]\\])",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.link"
},
"3": {
"scope": "markup"
},
"4": {
"scope": "text.link"
},
"5": {
"scope": "markup"
}
}
},
{
"comment": "Basic internal links",
"match": "(\\[\\[)([^\\]]+)(\\]\\])",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.link"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "URLs",
"match": "https?:\\/\\/[^\\s]+",
"exclusive": false,
"captures": {
"0": {
"scope": "text.link"
}
}
},
{
"comment": "CSS styling with classes and styles",
"match": "(@@)(\\.\\w+\\s+[^;]+;|[^@]+)(@@)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.purple"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "CSS styling basic",
"match": "(@@)([^@]+)(@@)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "color.purple"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "System tiddler references",
"match": "\\$:\\/[^\\s\\]\\}\\)]+",
"exclusive": false,
"captures": {
"0": {
"scope": "color.orange"
}
}
},
{
"comment": "Bold text",
"match": "('')([^']+|'[^']+)('')",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.bold"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Italic text",
"match": "(\\/\\/)([^\\/]+|\\/ [^\\/]+)(\\/\\/)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.italic"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Underlined text",
"match": "(__)([^_]+|_[^_]+)(__)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.underline"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Strikethrough text",
"match": "(--)([^-]+|-[^-]+)(--)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.strikethrough"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Superscript text",
"match": "(\\^\\^)([^\\^]+|\\^[^\\^]+)(\\^\\^)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.superscript"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Subscript text",
"match": "(~~)([^~]+|~[^~]+)(~~)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.subscript"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "Inline code",
"match": "(`)([^`]+)(`)",
"exclusive": false,
"captures": {
"1": {
"scope": "markup"
},
"2": {
"scope": "text.monospace"
},
"3": {
"scope": "markup"
}
}
},
{
"comment": "HTML entities",
"match": "&[a-zA-Z][a-zA-Z0-9]*;|&#[0-9]+;|&#x[0-9a-fA-F]+;",
"exclusive": false,
"captures": {
"0": {
"scope": "markup.entity"
}
}
}
],
"navigationPatterns": [
{
"match": "^! (.*)$",
"comment": "H1 level TiddlyWiki headers with !",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H1",
"level": 0
},
{
"match": "^!! (.*)$",
"comment": "H2 level TiddlyWiki headers with !!",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H2",
"level": 1
},
{
"match": "^!!! (.*)$",
"comment": "H3 level TiddlyWiki headers with !!!",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H3",
"level": 2
},
{
"match": "^!!!! (.*)$",
"comment": "H4 level TiddlyWiki headers with !!!!",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H4",
"level": 3
},
{
"match": "^!!!!! (.*)$",
"comment": "H5 level TiddlyWiki headers with !!!!!",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H5",
"level": 4
},
{
"match": "^!!!!!! (.*)$",
"comment": "H6 level TiddlyWiki headers with !!!!!!",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "H6",
"level": 5
},
{
"match": "^\\\\define\\s+(\\w+)",
"comment": "Macro definitions",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "MACRO",
"level": 1
},
{
"match": "^\\\\procedure\\s+(\\w+)",
"comment": "Procedure definitions",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "PROC",
"level": 1
},
{
"match": "^\\\\function\\s+(\\w+)",
"comment": "Function definitions",
"rangeCapture": "0",
"labelCapture": "1",
"prefix": "FUNC",
"level": 1
}
],
"indentationPatterns": [
{
"match": "(^\\s*\\*+ |^\\s*#+ |^\\s*>+ ).*",
"comment": "Indent TiddlyWiki lists and blockquotes",
"indentCapture": "1",
"indentScope": "text.normal"
}
],
"taskMarkDefinitions": [
{
"enabled": true,
"match": "\\* (\\[[ xX]\\]) (.*)$",
"rangeType": "line",
"captures": {
"interactive": "1",
"state": "1",
"label": "2"
},
"states": [
"[ ]",
"[x]"
],
"initialState": "[ ]",
"completedState": ["[x]", "[X]"],
"scopes": {
"interactive": "text.monospace.bold"
}
}
],
"linkDefinitions": [
{
"enabled": true,
"match": "\\[\\[([^\\|\\]]+)(?:\\|([^\\]]+))?\\]\\]",
"captures": {
"key": "1",
"value": "2",
"link": "0"
},
"templates": {
"": "tiddlywiki://[[value]]"
},
"scopes": {
"key": "text.link",
"value": "text.link",
"link": "text.link"
}
},
{
"enabled": true,
"match": "\\[ext\\[([^\\|\\]]+)\\|([^\\]]+)\\]\\]",
"captures": {
"key": "1",
"value": "2",
"link": "0"
},
"templates": {
"": "[[value]]"
},
"scopes": {
"key": "text.link",
"value": "color.blue",
"link": "text.link"
}
},
{
"enabled": true,
"match": "(https?:\\/\\/[^\\s]+)",
"captures": {
"key": "1",
"value": "1",
"link": "1"
},
"templates": {
"": "[[value_unencoded]]"
},
"scopes": {
"link": "text.link"
}
}
],
"autocompleteDefinitions": [
{
"trigger": "[[",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "Internal Link",
"value": "TiddlerName",
"prefix": "[[",
"suffix": "]]"
},
{
"label": "Link with Display Text",
"value": "Display Text|TiddlerName",
"prefix": "[[",
"suffix": "]]"
}
],
"enabled": true
},
{
"trigger": "{{",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "Transclude Tiddler",
"value": "TiddlerName",
"prefix": "{{",
"suffix": "}}"
},
{
"label": "Transclude Field",
"value": "TiddlerName!!field",
"prefix": "{{",
"suffix": "}}"
},
{
"label": "Current Tiddler Field",
"value": "!!field",
"prefix": "{{",
"suffix": "}}"
},
{
"label": "Template Transclusion",
"value": "TiddlerName||TemplateName",
"prefix": "{{",
"suffix": "}}"
}
],
"enabled": true
},
{
"trigger": "<<",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "Macro Call",
"value": "macroName",
"prefix": "<<",
"suffix": ">>"
},
{
"label": "Macro with Parameters",
"value": "macroName param1:\"value1\" param2:\"value2\"",
"prefix": "<<",
"suffix": ">>"
},
{
"label": "Now Macro",
"value": "now",
"prefix": "<<",
"suffix": ">>"
},
{
"label": "Today Macro",
"value": "today",
"prefix": "<<",
"suffix": ">>"
}
],
"enabled": true
},
{
"trigger": "<$",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "Button Widget",
"value": "button>Click Me</$button",
"prefix": "<$",
"suffix": ">"
},
{
"label": "List Widget",
"value": "list filter=\"[tag[example]]\"></$list",
"prefix": "<$",
"suffix": ">"
},
{
"label": "Text Widget",
"value": "text text=\"Hello World\"/>",
"prefix": "<$",
"suffix": ""
},
{
"label": "Link Widget",
"value": "link to=\"TiddlerName\">Link Text</$link",
"prefix": "<$",
"suffix": ">"
},
{
"label": "Transclude Widget",
"value": "transclude tiddler=\"TiddlerName\"/>",
"prefix": "<$",
"suffix": ""
},
{
"label": "Set Widget",
"value": "set name=\"variable\" value=\"text\">content</$set",
"prefix": "<$",
"suffix": ">"
},
{
"label": "Vars Widget",
"value": "vars var1=\"value1\" var2=\"value2\">content</$vars",
"prefix": "<$",
"suffix": ">"
},
{
"label": "Reveal Widget",
"value": "reveal type=\"match\" state=\"$:/temp/state\" text=\"show\">content</$reveal",
"prefix": "<$",
"suffix": ">"
}
],
"enabled": true
},
{
"trigger": "[",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "All Tiddlers Filter",
"value": "all[tiddlers]",
"prefix": "[",
"suffix": "]"
},
{
"label": "Tag Filter",
"value": "tag[tagname]",
"prefix": "[",
"suffix": "]"
},
{
"label": "Search Filter",
"value": "search[keyword]",
"prefix": "[",
"suffix": "]"
},
{
"label": "Sort Filter",
"value": "sort[created]",
"prefix": "[",
"suffix": "]"
},
{
"label": "Limit Filter",
"value": "limit[10]",
"prefix": "[",
"suffix": "]"
},
{
"label": "Field Filter",
"value": "field:fieldname[value]",
"prefix": "[",
"suffix": "]"
}
],
"enabled": true
},
{
"trigger": "\\\\",
"type": "static",
"processTemplateTags": false,
"items": [
{
"label": "Define Macro",
"value": "define macroname(param:\"default\")\nMacro content with $param$\n\\end",
"prefix": "\\",
"suffix": ""
},
{
"label": "Define Procedure",
"value": "procedure procname(param)\nProcedure content with <<param>>\n\\end",
"prefix": "\\",
"suffix": ""
},
{
"label": "Define Function",
"value": "function funcname(param) [filter[expression]]",
"prefix": "\\",
"suffix": ""
},
{
"label": "Import",
"value": "import [subfilter{$:/core/config/GlobalImportFilter}]",
"prefix": "\\",
"suffix": ""
}
],
"enabled": true
}
],
"listCompletionDefinitions": [
{
"comment": "TiddlyWiki bullet lists with task marks",
"enabled": true,
"match": "(^\\s*)(\\*+ (?:\\[[ xX]\\] )?)(.*)",
"captures": {
"indent": "1",
"prefix": "2",
"line": "3"
},
"replacements": {
"[x]": "[ ]",
"[X]": "[ ]"
}
},
{
"comment": "TiddlyWiki numbered lists",
"enabled": true,
"match": "(^\\s*)(#+ )(.*)",
"captures": {
"indent": "1",
"prefix": "2",
"line": "3"
}
},
{
"comment": "TiddlyWiki block quotes",
"enabled": true,
"match": "(^\\s*)(>+ )(.*)",
"captures": {
"indent": "1",
"prefix": "2",
"line": "3"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment