Enum inkjet::Language

source ·
#[non_exhaustive]
pub enum Language {
Show 81 variants Runtime(fn() -> &'static HighlightConfiguration), Plaintext, Ada, Asm, Astro, Awk, Bash, Bibtex, Bicep, Blueprint, C, Capnp, Clojure, CSharp, CommonLisp, Cpp, Css, Cue, D, Dart, Diff, Dockerfile, Eex, Elisp, Elixir, Elm, Erlang, Forth, Fortran, Gdscript, Gleam, Glsl, Go, Haskell, Hcl, Heex, Html, Iex, Ini, Java, Javascript, Json, Jsx, Kotlin, Latex, Llvm, Lua, Make, Matlab, Meson, Nim, Nix, ObjectiveC, Ocaml, OcamlInterface, OpenScad, Pascal, Php, ProtoBuf, Python, R, Racket, Regex, Ruby, Rust, Scala, Scheme, Scss, Sql, Svelte, Swift, Toml, Typescript, Tsx, Vimscript, Wast, Wat, X86asm, Wgsl, Yaml, Zig,
}
Expand description

The set of all languages supported by Inkjet.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Runtime(fn() -> &'static HighlightConfiguration)

A language resolved at runtime using the provided function pointer.

This allows languages not statically known to Inkjet to be used in formatting.

§Examples

fn rust_config() -> &'static HighlightConfiguration {
    Language::Rust.config()
}

let code = r#"
    fn main() {
        println!("Hello, world!");
    }
"#;

let mut highlighter = Highlighter::new();

let _string = highlighter.highlight_to_string(
    Language::Runtime(rust_config),
    &formatter::Html,
    code
)
.expect("Highlighting should not fail");
§

Plaintext

Available on crate feature language-plaintext only.

A plaintext “language.” Highlighting with this is a no-op.

§

Ada

Available on crate feature language-ada only.
§

Asm

Available on crate feature language-asm only.
§

Astro

Available on crate feature language-astro only.
§

Awk

Available on crate feature language-awk only.
§

Bash

Available on crate feature language-bash only.
§

Bibtex

Available on crate feature language-bibtex only.
§

Bicep

Available on crate feature language-bicep only.
§

Blueprint

Available on crate feature language-blueprint only.
§

C

Available on crate feature language-c only.
§

Capnp

Available on crate feature language-capnp only.
§

Clojure

Available on crate feature language-clojure only.
§

CSharp

Available on crate feature language-c-sharp only.
§

CommonLisp

Available on crate feature language-commonlisp only.
§

Cpp

Available on crate feature language-cpp only.
§

Css

Available on crate feature language-css only.
§

Cue

Available on crate feature language-cue only.
§

D

Available on crate feature language-d only.
§

Dart

Available on crate feature language-dart only.
§

Diff

Available on crate feature language-diff only.
§

Dockerfile

Available on crate feature language-dockerfile only.
§

Eex

Available on crate feature language-eex only.
§

Elisp

Available on crate feature language-elisp only.
§

Elixir

Available on crate feature language-elixir only.
§

Elm

Available on crate feature language-elm only.
§

Erlang

Available on crate feature language-erlang only.
§

Forth

Available on crate feature language-forth only.
§

Fortran

Available on crate feature language-fortran only.
§

Gdscript

Available on crate feature language-gdscript only.
§

Gleam

Available on crate feature language-gleam only.
§

Glsl

Available on crate feature language-glsl only.
§

Go

Available on crate feature language-go only.
§

Haskell

Available on crate feature language-haskell only.
§

Hcl

Available on crate feature language-hcl only.
§

Heex

Available on crate feature language-heex only.
§

Html

Available on crate feature language-html only.
§

Iex

Available on crate feature language-iex only.
§

Ini

Available on crate feature language-ini only.
§

Java

Available on crate feature language-java only.
§

Javascript

Available on crate feature language-javascript only.
§

Json

Available on crate feature language-json only.
§

Jsx

Available on crate feature language-jsx only.
§

Kotlin

Available on crate feature language-kotlin only.
§

Latex

Available on crate feature language-latex only.
§

Llvm

Available on crate feature language-llvm only.
§

Lua

Available on crate feature language-lua only.
§

Make

Available on crate feature language-make only.
§

Matlab

Available on crate feature language-matlab only.
§

Meson

Available on crate feature language-meson only.
§

Nim

Available on crate feature language-nim only.
§

Nix

Available on crate feature language-nix only.
§

ObjectiveC

Available on crate feature language-objc only.
§

Ocaml

Available on crate feature language-ocaml only.
§

OcamlInterface

Available on crate feature language-ocaml-interface only.
§

OpenScad

Available on crate feature language-openscad only.
§

Pascal

Available on crate feature language-pascal only.
§

Php

Available on crate feature language-php only.
§

ProtoBuf

Available on crate feature language-proto only.
§

Python

Available on crate feature language-python only.
§

R

Available on crate feature language-r only.
§

Racket

Available on crate feature language-racket only.
§

Regex

Available on crate feature language-regex only.
§

Ruby

Available on crate feature language-ruby only.
§

Rust

Available on crate feature language-rust only.
§

Scala

Available on crate feature language-scala only.
§

Scheme

Available on crate feature language-scheme only.
§

Scss

Available on crate feature language-scss only.
§

Sql

Available on crate feature language-sql only.
§

Svelte

Available on crate feature language-svelte only.
§

Swift

Available on crate feature language-swift only.
§

Toml

Available on crate feature language-toml only.
§

Typescript

Available on crate feature language-typescript only.
§

Tsx

Available on crate feature language-tsx only.
§

Vimscript

Available on crate feature language-vim only.
§

Wast

Available on crate feature language-wast only.
§

Wat

Available on crate feature language-wat only.
§

X86asm

Available on crate feature language-x86asm only.
§

Wgsl

Available on crate feature language-wgsl only.
§

Yaml

Available on crate feature language-yaml only.
§

Zig

Available on crate feature language-zig only.

Implementations§

source§

impl Language

source

pub const ALL_LANGS: &'static [Self] = _

Array containing all (statically known) language variants.

source

pub fn from_token(token: impl AsRef<str>) -> Option<Self>

Attempts to convert a string token (such as rust or rs) into the corresponding language.

Returns None if the language was not found.

The tokens for each language are sourced from its name and aliases keys in build/languages.toml.

§Example
assert_eq!(
    Language::from_token("rs").unwrap(),
    Language::Rust
);
source

pub fn config(&self) -> &'static HighlightConfiguration

Get the underlying HighlightConfiguration for a language.

Trait Implementations§

source§

impl Clone for Language

source§

fn clone(&self) -> Language

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Language

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Language

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Language

source§

fn eq(&self, other: &Language) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Language

source§

impl Eq for Language

source§

impl StructuralPartialEq for Language

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.