I was doing some Mikrotik related blog posts recently and even though my neovim has support for RouterOS syntax in markdown .md files inside code blocks via sheerun/vim-polyglot, zola does not have a built in support for it.

Claude was however able to convert this vim script into a Sublime syntax file after a few iterations. Setup zola to read extra syntax files first in config.toml:

[markdown]
extra_syntaxes_and_themes = ["syntaxes"]

Then create the file 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

Then add some routeros code block result correctly works with zola serve command.

Contributing upstream#

I have not found where could I contribute this upstream, because so far it appears to be a tangled mess:

  1. zola does not have any syntax highlighting files in their codebase
  2. zola itself appear to use syntect
  3. syntect in turnd does not have any syntax files either and maybe it is using Packages
  4. Packages appear to not accept new PR language contributions

If you know where to contribute it, please let me know.