diff --git a/EXAMPLES.md b/EXAMPLES.md index 53411445..609c1a4a 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -34,4 +34,3 @@ | [peterlyons.com](https://peterlyons.com) | https://github.com/focusaurus/peterlyons.com-zola | | [blog.turbo.fish](https://blog.turbo.fish) | https://git.sr.ht/~jplatte/blog.turbo.fish | | [guerinpe.com](https://guerinpe.com) | https://github.com/Grelot/blog | - diff --git a/components/config/examples/generate_sublime.rs b/components/config/examples/generate_sublime.rs index 981e3998..86747d27 100644 --- a/components/config/examples/generate_sublime.rs +++ b/components/config/examples/generate_sublime.rs @@ -3,7 +3,11 @@ //! Although it is a valid example for serializing syntaxes, you probably won't need //! to do this yourself unless you want to cache your own compiled grammars. extern crate syntect; + +use std::collections::HashMap; +use std::collections::HashSet; use std::env; +use std::iter::FromIterator; use syntect::dumps::*; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSetBuilder; @@ -26,10 +30,25 @@ fn main() { builder.add_from_folder(package_dir, true).unwrap(); let ss = builder.build(); dump_to_file(&ss, packpath_newlines).unwrap(); + let mut syntaxes: HashMap> = HashMap::new(); - for s in ss.syntaxes() { - if !s.file_extensions.is_empty() { - println!("- {} -> {:?}", s.name, s.file_extensions); + for s in ss.syntaxes().iter() { + syntaxes + .entry(s.name.clone()) + .and_modify(|e| { + for ext in &s.file_extensions { + e.insert(ext.clone()); + } + }) + .or_insert_with(|| HashSet::from_iter(s.file_extensions.iter().cloned())); + } + let mut keys = syntaxes.keys().collect::>(); + keys.sort_by(|a, b| a.to_lowercase().cmp(&b.to_lowercase())); + for k in keys { + if !syntaxes[k].is_empty() { + let mut extensions_sorted = syntaxes[k].iter().cloned().collect::>(); + extensions_sorted.sort(); + println!("- {} -> {:?}", k, extensions_sorted); } } } diff --git a/docs/content/documentation/content/syntax-highlighting.md b/docs/content/documentation/content/syntax-highlighting.md index f3d97e99..34b32d11 100644 --- a/docs/content/documentation/content/syntax-highlighting.md +++ b/docs/content/documentation/content/syntax-highlighting.md @@ -23,105 +23,104 @@ interpreted as plain text. Here is a full list of the supported languages and the short names you can use: ``` -- Plain Text -> ["txt"] -- Assembly x86 (NASM) -> ["asm", "inc", "nasm"] -- Crystal -> ["cr"] -- Dart -> ["dart"] -- Elixir -> ["ex", "exs"] -- fsharp -> ["fs"] -- Handlebars -> ["handlebars", "handlebars.html", "hbr", "hbrs", "hbs", "hdbs", "hjs", "mu", "mustache", "rac", "stache", "template", "tmpl"] -- Jinja2 -> ["j2", "jinja2"] -- Julia -> ["jl"] -- Kotlin -> ["kt", "kts"] -- Less -> ["less", "css.less"] -- MiniZinc (MZN) -> ["mzn", "dzn"] -- Nim -> ["nim", "nims"] -- ASP -> ["asa"] -- HTML (ASP) -> ["asp"] - ActionScript -> ["as"] - AppleScript -> ["applescript", "script editor"] +- ASP -> ["asa"] +- Assembly x86 (NASM) -> ["asm", "inc", "nasm"] - Batch File -> ["bat", "cmd"] -- NAnt Build File -> ["build"] -- C# -> ["cs", "csx"] -- C++ -> ["cpp", "cc", "cp", "cxx", "c++", "C", "h", "hh", "hpp", "hxx", "h++", "inl", "ipp"] +- 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"] -- CSS -> ["css", "css.erb", "css.liquid"] +- 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"] -- Erlang -> ["erl", "hrl", "Emakefile", "emakefile"] -- HTML (Erlang) -> ["yaws"] -- Git Attributes -> ["attributes", "gitattributes", ".gitattributes"] +- 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", ".gitconfig", ".gitmodules"] -- Git Ignore -> ["exclude", "gitignore", ".gitignore"] +- 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 -> ["groovy", "gvy", "gradle", "Jenkinsfile"] -- HTML -> ["html", "htm", "shtml", "xhtml"] +- 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"] -- Literate Haskell -> ["lhs"] -- Java Server Page (JSP) -> ["jsp"] -- Java -> ["java", "bsh"] +- 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"] -- 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"] -- JavaScript -> ["js", "htc"] -- BibTeX -> ["bib"] -- LaTeX -> ["tex", "ltx"] -- TeX -> ["sty", "cls"] -- Lisp -> ["lisp", "cl", "clisp", "l", "mud", "el", "scm", "ss", "lsp", "fasl"] +- 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 -> ["make", "GNUmakefile", "makefile", "Makefile", "makefile.am", "Makefile.am", "makefile.in", "Makefile.in", "OCamlMakefile", "mak", "mk"] -- Markdown -> ["md", "mdown", "markdown", "markdn"] +- 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"] -- Objective-C++ -> ["mm", "M", "h"] -- Objective-C -> ["m", "h"] +- Pascal -> ["dpr", "p", "pas"] +- Perl -> ["PL", "pl", "pm", "pod", "t"] - PHP -> ["php", "php3", "php4", "php5", "php7", "phps", "phpt", "phtml"] -- Pascal -> ["pas", "p", "dpr"] -- Perl -> ["pl", "pm", "pod", "t", "PL"] -- Python -> ["py", "py3", "pyw", "pyi", "pyx", "pyx.in", "pxd", "pxd.in", "pxi", "pxi.in", "rpy", "cpy", "SConstruct", "Sconstruct", "sconstruct", "SConscript", "gyp", "gypi", "Snakefile", "wscript"] -- R -> ["R", "r", "s", "S", "Rprofile"] +- 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"] -- HTML (Rails) -> ["rails", "rhtml", "erb", "html.erb"] -- JavaScript (Rails) -> ["js.erb"] -- Ruby Haml -> ["haml", "sass"] -- Ruby on Rails -> ["rxml", "builder"] -- SQL (Rails) -> ["erbsql", "sql.erb"] -- Regular Expression -> ["re"] -- reStructuredText -> ["rst", "rest"] -- 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"] -- Rust -> ["rs"] -- SQL -> ["sql", "ddl", "dml"] -- Scala -> ["scala", "sbt"] -- 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"] -- HTML (Tcl) -> ["adp"] -- Tcl -> ["tcl"] -- Textile -> ["textile"] -- XML -> ["xml", "xsd", "xslt", "tld", "dtml", "rss", "opml", "svg"] -- YAML -> ["yaml", "yml", "sublime-syntax"] -- PowerShell -> ["ps1", "psm1", "psd1"] -- SWI-Prolog -> ["pro"] - Reason -> ["re", "rei"] -- CMake C Header -> ["h.in"] -- CMake C++ Header -> ["hh.in", "hpp.in", "hxx.in", "h++.in"] -- CMake -> ["CMakeLists.txt", "cmake"] -- CMakeCache -> ["CMakeCache.txt"] -- Generic Config -> ["cfg", "conf", "config", "ini", "pro", "mak", "mk", "Doxyfile", "inputrc", ".inputrc", "dircolors", ".dircolors", "gitmodules", ".gitmodules", "gitignore", ".gitignore", "gitattributes", ".gitattributes"] -- Elm -> ["elm"] -- Linker Script -> ["ld"] +- 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"] -- TOML -> ["toml", "tml"] +- Tcl -> ["tcl"] +- TeX -> ["cls", "sty"] +- Textile -> ["textile"] +- TOML -> ["Cargo.lock", "Gopkg.lock", "Pipfile", "tml", "toml"] - TypeScript -> ["ts"] - TypeScriptReact -> ["tsx"] - VimL -> ["vim"] -- Nix -> ["nix"] -- TOML -> ["toml", "tml", "Cargo.lock", "Gopkg.lock", "Pipfile"] +- 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).