The replace
command finds <pre> blocks
on an html page and replaces them with highlighted blocks.
The command doesn't change to the source file; it outputs
a copy of the document.
Or use watch mode and highlighting will be updated every time you save the source file:
Each <pre>
block needs a
data-paint="language"
--html-only
--css-only
data-html-only
data-css-inline
Check this page before and after syntax highlighting:
Set with the data-paint="xx"
attribute:
<pre data-paint="rs"> |
use std::io::{BufReader,BufRead}; use std::fs::File; fn main() { let file = File::open("file.txt").unwrap(); for line in BufReader::new(file).lines() { println!("{}", line.unwrap()); } }
Add with the data-line-numbers
attribute:
<pre data-paint="py" data-line-numbers> |
with open("foobar.txt") as f: for line in f: process(line)
Add line numbers and header with a data-gist-like
attribute. Give it a title with data-title="x"
<pre data-paint="c" data-title="read_file.c" data-gist-like> |
#include#include int main(void) { FILE *stream; char *line = NULL; size_t len = 0; ssize_t read; stream = fopen("file.txt", "r"); if (stream == NULL) exit(EXIT_FAILURE); while ((read = getline(&line, &len, stream)) != -1) { printf("Retrieved line of length %zu :\n", read); printf("%s", line); } free(line); fclose(stream); exit(EXIT_SUCCESS); }
Set with the data-theme="xx"
attribute.
If you have more than one theme on a page you'll need to use
data-css-prefix
data-css-inline
<pre data-paint="go" data-theme="dracula" data-css-prefix="dark_example"> |