You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

syntax-highlighting.md 5.8KB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. +++
  2. title = "Syntax Highlighting"
  3. weight = 80
  4. +++
  5. Zola comes with built-in syntax highlighting but you first
  6. need to enable it in the [configuration](./documentation/getting-started/configuration.md).
  7. Once this is done, Zola will automatically highlight all code blocks
  8. in your content. A code block in Markdown looks like the following:
  9. ````md
  10. ```rust
  11. let highlight = true;
  12. ```
  13. ````
  14. You can replace the `rust` by the language you want to highlight or not put anything to get it
  15. interpreted as plain text.
  16. Here is a full list of the supported languages and the short names you can use:
  17. ```
  18. - Plain Text -> ["txt"]
  19. - Assembly x86 (NASM) -> ["asm", "inc", "nasm"]
  20. - Crystal -> ["cr"]
  21. - Dart -> ["dart"]
  22. - Elixir -> ["ex", "exs"]
  23. - fsharp -> ["fs"]
  24. - Handlebars -> ["handlebars", "handlebars.html", "hbr", "hbrs", "hbs", "hdbs", "hjs", "mu", "mustache", "rac", "stache", "template", "tmpl"]
  25. - Jinja2 -> ["j2", "jinja2"]
  26. - Julia -> ["jl"]
  27. - Kotlin -> ["kt", "kts"]
  28. - Less -> ["less", "css.less"]
  29. - MiniZinc (MZN) -> ["mzn", "dzn"]
  30. - Nim -> ["nim", "nims"]
  31. - ASP -> ["asa"]
  32. - HTML (ASP) -> ["asp"]
  33. - ActionScript -> ["as"]
  34. - AppleScript -> ["applescript", "script editor"]
  35. - Batch File -> ["bat", "cmd"]
  36. - NAnt Build File -> ["build"]
  37. - C# -> ["cs", "csx"]
  38. - C++ -> ["cpp", "cc", "cp", "cxx", "c++", "C", "h", "hh", "hpp", "hxx", "h++", "inl", "ipp"]
  39. - C -> ["c", "h"]
  40. - CSS -> ["css", "css.erb", "css.liquid"]
  41. - Clojure -> ["clj"]
  42. - D -> ["d", "di"]
  43. - Diff -> ["diff", "patch"]
  44. - Erlang -> ["erl", "hrl", "Emakefile", "emakefile"]
  45. - HTML (Erlang) -> ["yaws"]
  46. - Git Attributes -> ["attributes", "gitattributes", ".gitattributes"]
  47. - Git Commit -> ["COMMIT_EDITMSG", "MERGE_MSG", "TAG_EDITMSG"]
  48. - Git Config -> ["gitconfig", ".gitconfig", ".gitmodules"]
  49. - Git Ignore -> ["exclude", "gitignore", ".gitignore"]
  50. - Git Link -> [".git"]
  51. - Git Log -> ["gitlog"]
  52. - Git Rebase Todo -> ["git-rebase-todo"]
  53. - Go -> ["go"]
  54. - Graphviz (DOT) -> ["dot", "DOT", "gv"]
  55. - Groovy -> ["groovy", "gvy", "gradle", "Jenkinsfile"]
  56. - HTML -> ["html", "htm", "shtml", "xhtml"]
  57. - Haskell -> ["hs"]
  58. - Literate Haskell -> ["lhs"]
  59. - Java Server Page (JSP) -> ["jsp"]
  60. - Java -> ["java", "bsh"]
  61. - Java Properties -> ["properties"]
  62. - JSON -> ["json", "sublime-settings", "sublime-menu", "sublime-keymap", "sublime-mousemap", "sublime-theme", "sublime-build", "sublime-project", "sublime-completions", "sublime-commands", "sublime-macro", "sublime-color-scheme"]
  63. - JavaScript -> ["js", "htc"]
  64. - BibTeX -> ["bib"]
  65. - LaTeX -> ["tex", "ltx"]
  66. - TeX -> ["sty", "cls"]
  67. - Lisp -> ["lisp", "cl", "clisp", "l", "mud", "el", "scm", "ss", "lsp", "fasl"]
  68. - Lua -> ["lua"]
  69. - Makefile -> ["make", "GNUmakefile", "makefile", "Makefile", "makefile.am", "Makefile.am", "makefile.in", "Makefile.in", "OCamlMakefile", "mak", "mk"]
  70. - Markdown -> ["md", "mdown", "markdown", "markdn"]
  71. - MATLAB -> ["matlab"]
  72. - OCaml -> ["ml", "mli"]
  73. - OCamllex -> ["mll"]
  74. - OCamlyacc -> ["mly"]
  75. - Objective-C++ -> ["mm", "M", "h"]
  76. - Objective-C -> ["m", "h"]
  77. - PHP -> ["php", "php3", "php4", "php5", "php7", "phps", "phpt", "phtml"]
  78. - Pascal -> ["pas", "p", "dpr"]
  79. - Perl -> ["pl", "pm", "pod", "t", "PL"]
  80. - Python -> ["py", "py3", "pyw", "pyi", "pyx", "pyx.in", "pxd", "pxd.in", "pxi", "pxi.in", "rpy", "cpy", "SConstruct", "Sconstruct", "sconstruct", "SConscript", "gyp", "gypi", "Snakefile", "wscript"]
  81. - R -> ["R", "r", "s", "S", "Rprofile"]
  82. - Rd (R Documentation) -> ["rd"]
  83. - HTML (Rails) -> ["rails", "rhtml", "erb", "html.erb"]
  84. - JavaScript (Rails) -> ["js.erb"]
  85. - Ruby Haml -> ["haml", "sass"]
  86. - Ruby on Rails -> ["rxml", "builder"]
  87. - SQL (Rails) -> ["erbsql", "sql.erb"]
  88. - Regular Expression -> ["re"]
  89. - reStructuredText -> ["rst", "rest"]
  90. - Ruby -> ["rb", "Appfile", "Appraisals", "Berksfile", "Brewfile", "capfile", "cgi", "Cheffile", "config.ru", "Deliverfile", "Fastfile", "fcgi", "Gemfile", "gemspec", "Guardfile", "irbrc", "jbuilder", "podspec", "prawn", "rabl", "rake", "Rakefile", "Rantfile", "rbx", "rjs", "ruby.rail", "Scanfile", "simplecov", "Snapfile", "thor", "Thorfile", "Vagrantfile"]
  91. - Rust -> ["rs"]
  92. - SQL -> ["sql", "ddl", "dml"]
  93. - Scala -> ["scala", "sbt"]
  94. - Bourne Again Shell (bash) -> ["sh", "bash", "zsh", "fish", ".bash_aliases", ".bash_completions", ".bash_functions", ".bash_login", ".bash_logout", ".bash_profile", ".bash_variables", ".bashrc", ".profile", ".textmate_init", ".zshrc"]
  95. - HTML (Tcl) -> ["adp"]
  96. - Tcl -> ["tcl"]
  97. - Textile -> ["textile"]
  98. - XML -> ["xml", "xsd", "xslt", "tld", "dtml", "rss", "opml", "svg"]
  99. - YAML -> ["yaml", "yml", "sublime-syntax"]
  100. - PowerShell -> ["ps1", "psm1", "psd1"]
  101. - SWI-Prolog -> ["pro"]
  102. - Reason -> ["re", "rei"]
  103. - CMake C Header -> ["h.in"]
  104. - CMake C++ Header -> ["hh.in", "hpp.in", "hxx.in", "h++.in"]
  105. - CMake -> ["CMakeLists.txt", "cmake"]
  106. - CMakeCache -> ["CMakeCache.txt"]
  107. - Generic Config -> ["cfg", "conf", "config", "ini", "pro", "mak", "mk", "Doxyfile", "inputrc", ".inputrc", "dircolors", ".dircolors", "gitmodules", ".gitmodules", "gitignore", ".gitignore", "gitattributes", ".gitattributes"]
  108. - Elm -> ["elm"]
  109. - Linker Script -> ["ld"]
  110. - Swift -> ["swift"]
  111. - TOML -> ["toml", "tml"]
  112. - TypeScript -> ["ts"]
  113. - TypeScriptReact -> ["tsx"]
  114. - VimL -> ["vim"]
  115. - TOML -> ["toml", "tml", "Cargo.lock", "Gopkg.lock", "Pipfile"]
  116. ```
  117. 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).
  118. Alternatively, the `extra_syntaxes` config option can be used to add additional syntax files.
  119. If your site source is laid out as follows:
  120. ```
  121. .
  122. ├── config.toml
  123. ├── content/
  124. │   └── ...
  125. ├── static/
  126. │   └── ...
  127. ├── syntaxes/
  128. │   ├── Sublime-Language1/
  129. │   │   └── lang1.sublime-syntax
  130. │   └── lang2.sublime-syntax
  131. └── templates/
  132. └── ...
  133. ```
  134. you would set your `extra_syntaxes` to `["syntaxes", "syntaxes/Sublime-Language1"]` in order to load `lang1.sublime-syntax` and `lang2.sublime-syntax`.