pub enum Language {
Show 31 variants
Rust,
Ocaml,
C,
Cpp,
Go,
Java,
JavaScript,
TypeScript,
Python,
Shell,
Html,
Css,
Jsonc,
Sql,
Kotlin,
Toml,
Lua,
Yaml,
Php,
Ruby,
Zig,
R,
Dart,
Swift,
CSharp,
Scala,
Vue,
Svelte,
Markdown,
Perl,
Unknown,
}Expand description
A language OComment has a built-in scanner for.
The serde representation is the canonical name Self::as_str returns.
FromStr accepts that name and every spelling in Self::aliases,
case-folded and with - and _ ignored, so C++, cxx and cpp all
name Self::Cpp.
Variants§
Rust
Rust, detected from .rs.
Ocaml
OCaml, detected from .ml and .mli.
C
C, detected from .c and .h; .m selects Dialect::ObjectiveC.
Cpp
C++, detected from .cpp and its siblings; .mm and .cu select
Dialect::ObjectiveCpp and Dialect::Cuda.
Go
Go, detected from .go.
Java
Java, detected from .java.
JavaScript
JavaScript, detected from .js, .mjs and .cjs; .jsx selects
Dialect::Jsx.
TypeScript
TypeScript, detected from .ts, .mts and .cts; .tsx selects
Dialect::Tsx.
Python
Python, detected from .py, .pyw and .pyi.
Shell
Shell, detected from .sh, .bash and .zsh, and from a Dockerfile
or Makefile name.
Html
HTML, detected from .html and its siblings. <script> and <style>
bodies are scanned as JavaScript and CSS.
Css
CSS, detected from .css.
Jsonc
JSON with comments, detected from .jsonc, .json5, and from a
tsconfig.json or jsconfig.json name.
Sql
SQL, detected from .sql. The Dialect decides the string and
comment rules.
Kotlin
Kotlin, detected from .kt and .kts.
Toml
TOML, detected from .toml and from the lock file names written in
it, such as Cargo.lock.
Lua
Lua, detected from .lua and .rockspec, and from a lua or
luajit #! line.
Yaml
YAML, detected from .yml and .yaml, and from the extensionless
configuration names written in it, such as .clang-format.
Php
PHP, detected from .php, .phtml and .phpt, and from a php #!
line. The inline HTML around the <?php ... ?> tags is content.
Ruby
Ruby, detected from .rb and its siblings, from the extensionless
project files written in it, such as Gemfile, and from a ruby #!
line.
Zig
Zig, detected from .zig and from the .zon of Zig Object Notation.
It has no block comment: /* is two operators.
R
R, detected from .r in either case, from a .Rprofile name, and from
an Rscript or r #! line.
Dart
Dart, detected from .dart and from a dart #! line. Its block
comments nest.
Swift
Swift, detected from .swift and from a swift #! line. Its block
comments nest and #/ ... /# is an opaque regular expression literal.
CSharp
C#, detected from .cs and from the .csx of a script. A line whose
first non-blank byte is # is a preprocessor directive and carries at
most a // comment.
Scala
Scala, detected from .scala and from the .sc of a script, and from
a scala or scala-cli #! line. Its block comments nest, a string
is interpolated when an identifier stands directly before its quote,
and a < with the shape of an XML literal opens one.
Vue
Vue, detected from the .vue of a single-file component. Its template
is HTML with {{ ... }} code, and its <script> and <style> bodies
are scanned as their own languages, the lang attribute choosing which.
Svelte
Svelte, detected from the .svelte of a component. Its template is
HTML with { ... } code, and its <script> and <style> bodies are
scanned as their own languages.
Markdown
Markdown, detected from .md, .markdown and the .Rmd of an R
Markdown document. HTML comments are comments, fenced code blocks are
scanned as the language their info string names, and inline and
indented code are opaque.
Perl
Perl, detected from .pl, .pm and .t, and from a perl #!
line. Its quote words, here-documents and regular expressions hide a
#, its POD blocks are opaque, and a / the parse context alone
settles is reported as lexically ambiguous.
Unknown
No built-in scanner, and the default.
Scanning it yields no comments and one unknown-language error
diagnostic. A syntax with no built-in scanner is handled by a
DeclarativeProfile or by
transform_spans instead.