Nedávno som písal niekoľko blogových príspevkov o Mikrotiku a hoci môj
neovim podporuje syntax RouterOS v markdown .md súboroch vo vnútri
kódových blokov cez sheerun/vim-polyglot, zola na to nemá vstavanú
podporu.
Claude mi však dokázal po niekoľkých iteráciách previesť tento
vim skript
do súboru vo formáte Sublime syntax. Najprv nastavte zolu, aby načítavala
extra súbory so syntaxou, a to v config.toml:
[markdown]
extra_syntaxes_and_themes = ["syntaxes"]
Potom vytvorte súbor syntaxes/routeros.sublime-syntax:
%YAML 1.2
---
name: RouterOS
file_extensions:
- rsc
- ros
scope: source.routeros
contexts:
main:
- include: comments
- include: strings
- include: variables
- include: submenus
- include: keywords
- include: operators
- include: interfaces
- include: services
- include: booleans
- include: special
comments:
- match: '^\s*#.*'
scope: comment.line.routeros
strings:
- match: '"'
scope: punctuation.definition.string.begin.routeros
push:
- meta_scope: string.quoted.double.routeros
- match: '\\["\\nrt$?_abfv]|\\\x\x'
scope: constant.character.escape.routeros
- match: '"'
scope: punctuation.definition.string.end.routeros
pop: true
variables:
- match: "[a-zA-Z0-9-/]*(?==)"
scope: variable.parameter.routeros
- match: '\$[a-zA-Z0-9-]*'
scope: variable.other.routeros
submenus:
- match: "(?<=[a-z])/[a-zA-Z0-9-]*"
scope: entity.name.function.routeros
keywords:
- match: '\b(if)\b'
scope: keyword.control.conditional.routeros
- match: '\b(do|while|for|foreach)\b'
scope: keyword.control.loop.routeros
- match: '\b(global|local)\b'
scope: storage.type.routeros
- match: '\b(beep|delay|put|len|typeof|pick|log|time|set|find|environment|terminal|error|parse|resolve|toarray|tobool|toid|toip|toip6|tonum|tostr|totime|add|remove|enable|disable|where|get|print|export|edit|find|append|as-value|brief|detail|count-only|file|follow|follow-only|from|interval|terse|value-list|without-paging|return)\b'
scope: keyword.other.routeros
operators:
- match: "[<>!]="
scope: keyword.operator.comparison.routeros
- match: "<<|>>"
scope: keyword.operator.bitwise.routors
- match: "[-+*<>=!~^&.,]"
scope: keyword.operator.routeros
- match: '\b(and|or|in)\b'
scope: keyword.operator.logical.routeros
interfaces:
- match: 'bridge\d+|ether\d+|wlan\d+|pppoe-(out|in)\d+'
scope: support.type.routeros
services:
- match: '(?<=set\s)(api-ssl|api|dns|ftp|http|https|pim|ntp|smb|ssh|telnet|winbox|www|www-ssl)'
scope: support.type.routeros
booleans:
- match: '\b(yes|no|true|false)\b'
scope: constant.language.boolean.routeros
special:
- match: "[():{}|]"
scope: punctuation.routeros
- match: '\[|\]'
scope: punctuation.routeros
- match: "[,=]"
scope: punctuation.separator.routeros
- match: '\\$'
scope: constant.character.escape.routeros
Potom pridajte nejaký kódový blok routeros a výsledok správne funguje s
príkazom zola serve.
Prispievanie do upstream #
Nenašiel som, kde by som to mohol prispieť do upstream projektu, pretože situácia sa zdá byť dosť zamotaná:
- zola nemá vo svojom kóde žiadne súbory so zvýrazňovaním syntaxe
- zola samotná zrejme používa
syntect - syntect zasa nemá žiadne súbory so syntaxou a možno používa
Packages - Packages zjavne neprijímajú nové PR príspevky s jazykmi
Ak viete, kde to prispieť, dajte mi vedieť.