The highlighting of a code element
lines/2 makes one HTML fragment for each line of a source text. Makeup
lexes the text when a lexer package or a lexer of Expresso.Lexers
registers the language, and it escapes each token. Without a lexer for the language, or without a language, the
function escapes each line and puts it in one span, with no class.
Expresso.CodeVerifier gives a warning for a language with no lexer.
stylesheet/0 gives the rules of the token classes, and the renderer writes
them into the document.
Each fragment holds its line break, and no text node of a fragment is only
white space. Expresso.Deck.render/1 writes the document with Floki, and
Floki drops a text node that is only white space. Therefore the function
puts each white space token into the span of the token before it, and it
puts a zero width space into a line that has no other character.
Summary
Functions
Return the name of each language that a lexer registers, in alphabetical order
Make one HTML fragment for each line of the text
Give the CSS of the token classes, for the class highlight
Functions
@spec languages() :: [String.t()]
Return the name of each language that a lexer registers, in alphabetical order
iex> "elixir" in Expresso.Highlight.languages()
true
iex> "toml" in Expresso.Highlight.languages()
true
iex> "cobol" in Expresso.Highlight.languages()
false
Make one HTML fragment for each line of the text
The language is a name that a lexer package or Expresso.Lexers
registers, such as "elixir", "js", "rust" or "toml".
languages/0 returns each name. A language with no lexer, or no language, gives plain lines.
The option trailing_comments: false removes a comment at the end of a
line that has code before it, with the white space before the comment. A
line that is only a comment stays. A text with no lexer keeps its comments,
because only a lexer finds them.
Each fragment starts with a span element and ends with one, and the last
span holds the line break. Floki removes a text node of white space only,
so the white space of a template around a fragment does not join the text
of the line.
iex> Expresso.Highlight.lines("a < 1", nil)
["<span>a < 1
@spec stylesheet() :: String.t()
Give the CSS of the token classes, for the class highlight
Each color is a custom property of Expresso.Palette, such as
--code-keyword, so the theme of the deck gives the colors.