diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
| commit | a98b5ea6fe8e8cc98a55e0fd793e6e8660ea31c1 (patch) | |
| tree | 542810ab5aef99150db228bb54fd58303dcb31c7 /public/prism/prism-inform7.js | |
| parent | ab355897a12b7bda1089a44de326d41455a0f7a3 (diff) | |
chore: add prismjs for syntax highlighting
Diffstat (limited to 'public/prism/prism-inform7.js')
| -rw-r--r-- | public/prism/prism-inform7.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/public/prism/prism-inform7.js b/public/prism/prism-inform7.js new file mode 100644 index 0000000..f0fe7e1 --- /dev/null +++ b/public/prism/prism-inform7.js @@ -0,0 +1,68 @@ +Prism.languages.inform7 = { + string: { + pattern: /"[^"]*"/, + inside: { + substitution: { + pattern: /\[[^\[\]]+\]/, + inside: { + delimiter: { + pattern: /\[|\]/, + alias: 'punctuation', + }, + // See rest below + }, + }, + }, + }, + comment: { + pattern: /\[[^\[\]]+\]/, + greedy: true, + }, + title: { + pattern: /^[ \t]*(?:book|chapter|part(?! of)|section|table|volume)\b.+/im, + alias: 'important', + }, + number: { + pattern: + /(^|[^-])(?:\b\d+(?:\.\d+)?(?:\^\d+)?(?:(?!\d)\w+)?|\b(?:eight|eleven|five|four|nine|one|seven|six|ten|three|twelve|two))\b(?!-)/i, + lookbehind: true, + }, + verb: { + pattern: + /(^|[^-])\b(?:answering|applying to|are|asking|attacking|be(?:ing)?|burning|buying|called|carries|carry(?! out)|carrying|climbing|closing|conceal(?:ing|s)?|consulting|contain(?:ing|s)?|cutting|drinking|dropping|eating|enclos(?:es?|ing)|entering|examining|exiting|getting|giving|going|ha(?:s|ve|ving)|hold(?:ing|s)?|impl(?:ies|y)|incorporat(?:es?|ing)|inserting|is|jumping|kissing|listening|locking|looking|mean(?:ing|s)?|opening|provid(?:es?|ing)|pulling|pushing|putting|relat(?:es?|ing)|removing|searching|see(?:ing|s)?|setting|showing|singing|sleeping|smelling|squeezing|support(?:ing|s)?|swearing|switching|taking|tasting|telling|thinking|throwing|touching|turning|tying|unlock(?:ing|s)?|var(?:ies|y|ying)|waiting|waking|waving|wear(?:ing|s)?)\b(?!-)/i, + lookbehind: true, + alias: 'operator', + }, + keyword: { + pattern: + /(^|[^-])\b(?:after|before|carry out|check|continue the action|definition(?= *:)|do nothing|else|end (?:if|the story|unless)|every turn|if|include|instead(?: of)?|let|move|no|now|otherwise|repeat|report|resume the story|rule for|running through|say(?:ing)?|stop the action|test|try(?:ing)?|understand|unless|use|when|while|yes)\b(?!-)/i, + lookbehind: true, + }, + property: { + pattern: + /(^|[^-])\b(?:adjacent(?! to)|carried|closed|concealed|contained|dark|described|edible|empty|enclosed|enterable|even|female|fixed in place|full|handled|held|improper-named|incorporated|inedible|invisible|lighted|lit|lock(?:able|ed)|male|marked for listing|mentioned|negative|neuter|non-(?:empty|full|recurring)|odd|opaque|open(?:able)?|plural-named|portable|positive|privately-named|proper-named|provided|publically-named|pushable between rooms|recurring|related|rubbing|scenery|seen|singular-named|supported|swinging|switch(?:able|ed(?: off| on)?)|touch(?:able|ed)|transparent|unconcealed|undescribed|unlit|unlocked|unmarked for listing|unmentioned|unopenable|untouchable|unvisited|variable|visible|visited|wearable|worn)\b(?!-)/i, + lookbehind: true, + alias: 'symbol', + }, + position: { + pattern: + /(^|[^-])\b(?:above|adjacent to|back side of|below|between|down|east|everywhere|front side|here|in|inside(?: from)?|north(?:east|west)?|nowhere|on(?: top of)?|other side|outside(?: from)?|parts? of|regionally in|south(?:east|west)?|through|up|west|within)\b(?!-)/i, + lookbehind: true, + alias: 'keyword', + }, + type: { + pattern: + /(^|[^-])\b(?:actions?|activit(?:ies|y)|actors?|animals?|backdrops?|containers?|devices?|directions?|doors?|holders?|kinds?|lists?|m[ae]n|nobody|nothing|nouns?|numbers?|objects?|people|persons?|player(?:'s holdall)?|regions?|relations?|rooms?|rule(?:book)?s?|scenes?|someone|something|supporters?|tables?|texts?|things?|time|vehicles?|wom[ae]n)\b(?!-)/i, + lookbehind: true, + alias: 'variable', + }, + punctuation: /[.,:;(){}]/, +}; + +Prism.languages.inform7['string'].inside['substitution'].inside.rest = + Prism.languages.inform7; +// We don't want the remaining text in the substitution to be highlighted as the string. +Prism.languages.inform7['string'].inside['substitution'].inside.rest.text = { + pattern: /\S(?:\s*\S)*/, + alias: 'comment', +}; |
