mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
update to support fenced code
This commit is contained in:
parent
a87794e7b2
commit
890f3db10a
10 changed files with 828 additions and 724 deletions
|
@ -2,6 +2,18 @@ use roc_parse::highlight::Token;
|
|||
use roc_region::all::Loc;
|
||||
|
||||
pub fn highlight_roc_code(code: &str) -> String {
|
||||
let buf = highlight(code);
|
||||
|
||||
format!("<pre><samp>{}</samp></pre>", buf.join(""))
|
||||
}
|
||||
|
||||
pub fn highlight_roc_code_inline(code: &str) -> String {
|
||||
let buf = highlight(code);
|
||||
|
||||
format!("<code>{}</code>", buf.join(""))
|
||||
}
|
||||
|
||||
pub fn highlight(code: &str) -> Vec<String> {
|
||||
let locations: Vec<Loc<Token>> = roc_parse::highlight::highlight(code);
|
||||
let mut buf: Vec<String> = Vec::new();
|
||||
let mut offset = 0;
|
||||
|
@ -90,7 +102,7 @@ pub fn highlight_roc_code(code: &str) -> String {
|
|||
offset = location.byte_range().end;
|
||||
}
|
||||
|
||||
format!("<pre><samp>{}</samp></pre>", buf.join(""))
|
||||
buf
|
||||
}
|
||||
|
||||
fn push_html_span(mut buf: Vec<String>, curr: &str, class: &str) -> Vec<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue