|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- +++
- title = "Syntax Highlighting"
- weight = 80
- +++
-
- Zola comes with built-in syntax highlighting but you first
- need to enable it in the [configuration](@/documentation/getting-started/configuration.md).
-
- Once this is done, Zola will automatically highlight all code blocks
- in your content. A code block in Markdown looks like the following:
-
- ````md
-
- ```rust
- let highlight = true;
- ```
-
- ````
-
- You can replace the `rust` by the language you want to highlight or not put anything to get it
- interpreted as plain text.
-
- Here is a full list of the supported languages and the short names you can use:
-
- ```
- - ActionScript -> ["as"]
- - AppleScript -> ["applescript", "script editor"]
- - ASP -> ["asa"]
- - Assembly x86 (NASM) -> ["asm", "inc", "nasm"]
- - Batch File -> ["bat", "cmd"]
- - BibTeX -> ["bib"]
- - Bourne Again Shell (bash) -> [".bash_aliases", ".bash_completions", ".bash_functions", ".bash_login", ".bash_logout", ".bash_profile", ".bash_variables", ".bashrc", ".profile", ".textmate_init", ".zshrc", "bash", "fish", "sh", "zsh"]
- - C -> ["c", "h"]
- - C# -> ["cs", "csx"]
- - C++ -> ["C", "c++", "cc", "cp", "cpp", "cxx", "h", "h++", "hh", "hpp", "hxx", "inl", "ipp"]
- - Clojure -> ["clj"]
- - CMake -> ["CMakeLists.txt", "cmake"]
- - CMake C Header -> ["h.in"]
- - CMake C++ Header -> ["h++.in", "hh.in", "hpp.in", "hxx.in"]
- - CMakeCache -> ["CMakeCache.txt"]
- - Crystal -> ["cr"]
- - CSS -> ["css", "css.erb", "css.liquid"]
- - D -> ["d", "di"]
- - Dart -> ["dart"]
- - Diff -> ["diff", "patch"]
- - Elixir -> ["ex", "exs"]
- - Elm -> ["elm"]
- - Erlang -> ["Emakefile", "emakefile", "erl", "hrl"]
- - fsharp -> ["fs"]
- - Generic Config -> [".dircolors", ".gitattributes", ".gitignore", ".gitmodules", ".inputrc", "Doxyfile", "cfg", "conf", "config", "dircolors", "gitattributes", "gitignore", "gitmodules", "ini", "inputrc", "mak", "mk", "pro"]
- - Git Attributes -> [".gitattributes", "attributes", "gitattributes"]
- - Git Commit -> ["COMMIT_EDITMSG", "MERGE_MSG", "TAG_EDITMSG"]
- - Git Config -> [".gitconfig", ".gitmodules", "gitconfig"]
- - Git Ignore -> [".gitignore", "exclude", "gitignore"]
- - Git Link -> [".git"]
- - Git Log -> ["gitlog"]
- - Git Rebase Todo -> ["git-rebase-todo"]
- - Go -> ["go"]
- - Graphviz (DOT) -> ["DOT", "dot", "gv"]
- - Groovy -> ["Jenkinsfile", "gradle", "groovy", "gvy"]
- - Handlebars -> ["handlebars", "handlebars.html", "hbr", "hbrs", "hbs", "hdbs", "hjs", "mu", "mustache", "rac", "stache", "template", "tmpl"]
- - Haskell -> ["hs"]
- - HTML -> ["htm", "html", "shtml", "xhtml"]
- - HTML (ASP) -> ["asp"]
- - HTML (Erlang) -> ["yaws"]
- - HTML (Rails) -> ["erb", "html.erb", "rails", "rhtml"]
- - HTML (Tcl) -> ["adp"]
- - Java -> ["bsh", "java"]
- - Java Properties -> ["properties"]
- - Java Server Page (JSP) -> ["jsp"]
- - JavaScript -> ["htc", "js"]
- - JavaScript (Rails) -> ["js.erb"]
- - Jinja2 -> ["j2", "jinja2"]
- - JSON -> ["json", "sublime-build", "sublime-color-scheme", "sublime-commands", "sublime-completions", "sublime-keymap", "sublime-macro", "sublime-menu", "sublime-mousemap", "sublime-project", "sublime-settings", "sublime-theme"]
- - Julia -> ["jl"]
- - Kotlin -> ["kt", "kts"]
- - LaTeX -> ["ltx", "tex"]
- - Less -> ["css.less", "less"]
- - Linker Script -> ["ld"]
- - Lisp -> ["cl", "clisp", "el", "fasl", "l", "lisp", "lsp", "mud", "scm", "ss"]
- - Literate Haskell -> ["lhs"]
- - Lua -> ["lua"]
- - Makefile -> ["GNUmakefile", "Makefile", "Makefile.am", "Makefile.in", "OCamlMakefile", "mak", "make", "makefile", "makefile.am", "makefile.in", "mk"]
- - Markdown -> ["markdn", "markdown", "md", "mdown"]
- - MATLAB -> ["matlab"]
- - MiniZinc (MZN) -> ["dzn", "mzn"]
- - NAnt Build File -> ["build"]
- - Nim -> ["nim", "nims"]
- - Nix -> ["nix"]
- - Objective-C -> ["h", "m"]
- - Objective-C++ -> ["M", "h", "mm"]
- - OCaml -> ["ml", "mli"]
- - OCamllex -> ["mll"]
- - OCamlyacc -> ["mly"]
- - Pascal -> ["dpr", "p", "pas"]
- - Perl -> ["PL", "pl", "pm", "pod", "t"]
- - PHP -> ["php", "php3", "php4", "php5", "php7", "phps", "phpt", "phtml"]
- - Plain Text -> ["txt"]
- - PowerShell -> ["ps1", "psd1", "psm1"]
- - Python -> ["SConscript", "SConstruct", "Sconstruct", "Snakefile", "cpy", "gyp", "gypi", "pxd", "pxd.in", "pxi", "pxi.in", "py", "py3", "pyi", "pyw", "pyx", "pyx.in", "rpy", "sconstruct", "wscript"]
- - R -> ["R", "Rprofile", "S", "r", "s"]
- - Rd (R Documentation) -> ["rd"]
- - Reason -> ["re", "rei"]
- - Regular Expression -> ["re"]
- - reStructuredText -> ["rest", "rst"]
- - Ruby -> ["Appfile", "Appraisals", "Berksfile", "Brewfile", "Cheffile", "Deliverfile", "Fastfile", "Gemfile", "Guardfile", "Rakefile", "Rantfile", "Scanfile", "Snapfile", "Thorfile", "Vagrantfile", "capfile", "cgi", "config.ru", "fcgi", "gemspec", "irbrc", "jbuilder", "podspec", "prawn", "rabl", "rake", "rb", "rbx", "rjs", "ruby.rail", "simplecov", "thor"]
- - Ruby Haml -> ["haml", "sass"]
- - Ruby on Rails -> ["builder", "rxml"]
- - Rust -> ["rs"]
- - Scala -> ["sbt", "scala"]
- - SQL -> ["ddl", "dml", "sql"]
- - SQL (Rails) -> ["erbsql", "sql.erb"]
- - SWI-Prolog -> ["pro"]
- - Swift -> ["swift"]
- - Tcl -> ["tcl"]
- - TeX -> ["cls", "sty"]
- - Textile -> ["textile"]
- - TOML -> ["Cargo.lock", "Gopkg.lock", "Pipfile", "tml", "toml"]
- - TypeScript -> ["ts"]
- - TypeScriptReact -> ["tsx"]
- - VimL -> ["vim"]
- - XML -> ["dtml", "opml", "rss", "svg", "tld", "xml", "xsd", "xslt"]
- - YAML -> ["sublime-syntax", "yaml", "yml"]
- ```
-
- If you want to highlight a language not on that list, please open an issue or a pull request on the [Zola repo](https://github.com/getzola/zola).
- Alternatively, the `extra_syntaxes` config option can be used to add additional syntax files.
-
- If your site source is laid out as follows:
-
- ```
- .
- ├── config.toml
- ├── content/
- │ └── ...
- ├── static/
- │ └── ...
- ├── syntaxes/
- │ ├── Sublime-Language1/
- │ │ └── lang1.sublime-syntax
- │ └── lang2.sublime-syntax
- └── templates/
- └── ...
- ```
-
- you would set your `extra_syntaxes` to `["syntaxes", "syntaxes/Sublime-Language1"]` in order to load `lang1.sublime-syntax` and `lang2.sublime-syntax`.
|