|
AsmGrader 0.0.0
|
Classes | |
| struct | Options |
Typedefs | |
| using | Option = std::pair<inspection::Token::Kind, fmt::text_style> |
Functions | |
| std::string | render_blocks (std::string_view str, bool skip_styling) |
Parses and renders literal blocks, returning a form meant for displaying to a console user, as by means of fmt::styled. The syntax for a literal string is a sequence of characters started by the sequence %#` and ended by a single backtick `. Backticks within the sequence may be escaped using \`. | |
| std::string | highlight (std::string_view str, const Options &opts=Options::get_default_options()) |
Applies syntax highlighting to str by means of first passing it through inspection::Tokenizer, then applying highlighting as specified by opts to the obtained tokens. | |
| std::string | highlight (const inspection::Token &token, const Options &opts=Options::get_default_options()) |
Returns a stringified and highlighted version of the supplied token. Highlighting and spacing is done based on opts. | |
| std::string | highlight (std::span< const inspection::Token > tokens, const Options &opts=Options::get_default_options()) |
Returns a stringified and highlighted version of the supplied range of tokens. Highlighting and spacing is done based on opts. | |
| using asmgrader::highlight::Option = std::pair<inspection::Token::Kind, fmt::text_style> |
| std::string asmgrader::highlight::highlight | ( | const inspection::Token & | token, |
| const Options & | opts = Options::get_default_options() ) |
Returns a stringified and highlighted version of the supplied token. Highlighting and spacing is done based on opts.
| std::string asmgrader::highlight::highlight | ( | std::span< const inspection::Token > | tokens, |
| const Options & | opts = Options::get_default_options() ) |
Returns a stringified and highlighted version of the supplied range of tokens. Highlighting and spacing is done based on opts.
| std::string asmgrader::highlight::highlight | ( | std::string_view | str, |
| const Options & | opts = Options::get_default_options() ) |
Applies syntax highlighting to str by means of first passing it through inspection::Tokenizer, then applying highlighting as specified by opts to the obtained tokens.
Special consideration is taken for literal blocks that should NOT be considered for tokenization or syntax highlighting. These strings are surrounded by `` backticks and are removed before the tokenization stage, then added back in the correct position afterwards. There are other properties that will be considered when parsing this syntax that may be found at parse_literal_strs.
| std::string asmgrader::highlight::render_blocks | ( | std::string_view | str, |
| bool | skip_styling ) |
Parses and renders literal blocks, returning a form meant for displaying to a console user, as by means of fmt::styled. The syntax for a literal string is a sequence of characters started by the sequence %#` and ended by a single backtick `. Backticks within the sequence may be escaped using \`.
This plain form is not very useful here, but is handy to disable tokenization with highlight(std::string_view, const Options&).
| str | The string to parse literal blocks from |
| skip_styling | Whether to skip all styling. |
Example, with possible output from highlight(std::string_view, const Options&):
%#`I am a literal block with a some \`backticks!\``
int main() { return 0; } %#`hey, this is main!`
I am a literal block with a some `backticks!` int main() { return 0; } hey, this is main!
A style may also be specified within each literal block with the syntax <style-name> positioned at the very beginning of the block. Multiple style-name fields may be seperated by ,s without spaces. To begin a block with a literal < character, escape it with a \. Supported style names are:
fg:ansi-name | bg:ansi-name - where ansi-name is one of: black, red, green, yellow, blue, magenta, cyan, or whitefg:#hex-color | bg:#hex-color - where hex-color is a 6-digit hex rgb color value (e.g., red foreground fg:#FF0000)bold | italic | underline | blink | strikethroughExample:
I am a not formatted, but %#`<fg:red>I am IMPORTANT RED text` and %#`<bold,underline,bg:#66FF00>I'm bolded and underlined, with a bright green background` and %#`\<I'm not styled, as the < is escaped`
I am a not formatted, but I am IMPORTANT RED text and I'm bolded and underlined, with a bright green background and <I'm not styled, as the < is escaped