diff --git a/ansi-preview/tsconfig.json b/ansi-preview/tsconfig.json index 4375112..8258db2 100644 --- a/ansi-preview/tsconfig.json +++ b/ansi-preview/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "Node16", "target": "ES2022", - // "rootDir": "src", + "rootDir": "src", "useDefineForClassFields": true, "lib": ["ESNext", "ES2022", "es2021", "DOM"], "allowJs": true, @@ -19,5 +19,6 @@ "declaration": true, "declarationMap": false, "sourceMap": false - } + }, + "include": ["src"] } diff --git a/ansi2/src/html.rs b/ansi2/src/html.rs index 176fbab..622cf93 100644 --- a/ansi2/src/html.rs +++ b/ansi2/src/html.rs @@ -39,7 +39,6 @@ pub fn to_html>( s.push_str("
"); for c in row.iter() { let mut text_class = vec!["char".into()]; - let mut bg_class = vec!["char".into()]; if c.bold { text_class.push("bold".into()); } @@ -69,9 +68,8 @@ pub fn to_html>( if !c.bg_color.is_default() { let name = "bg-".to_string() + &c.bg_color.class_name(); - bg_class.push(name); - - if let crate::lex::AnsiColor::Rgb(r, g, b) = c.color { + text_class.push(name); + if let crate::lex::AnsiColor::Rgb(r, g, b) = c.bg_color { color256.insert(format!( ".bg-rgb_{r}_{g}_{b}{{background:{};}}\n", get_hex((r, g, b)) @@ -84,7 +82,6 @@ pub fn to_html>( } let text_class = text_class.join(" ").trim().to_string(); - let bg_class = bg_class.join(" "); let html_char = c.char.to_string(); let html_char = html_escape::encode_text(&html_char); let class_str = if text_class.is_empty() { @@ -92,9 +89,7 @@ pub fn to_html>( } else { format!("class='{text_class}'") }; - s.push_str(&format!( - "
{html_char}
", - )) + s.push_str(&format!("
{html_char}
",)) } s.push_str("
"); } diff --git a/ansi2/src/svg.rs b/ansi2/src/svg.rs index bc15095..5ba88e2 100644 --- a/ansi2/src/svg.rs +++ b/ansi2/src/svg.rs @@ -51,7 +51,7 @@ pub fn to_svg, T: ColorTable>( r#""# )); - if let crate::lex::AnsiColor::Rgb(r, g, b) = c.color { + if let crate::lex::AnsiColor::Rgb(r, g, b) = c.bg_color { color256.insert(format!( ".bg-rgb_{r}_{g}_{b}{{fill:{};}}\n", get_hex((r, g, b)) diff --git a/assets/update.sh b/assets/update.sh index b656b01..898ed17 100755 --- a/assets/update.sh +++ b/assets/update.sh @@ -1,9 +1,13 @@ #!/bin/bash -for i in win11 vitest 8bit-color 24bit-color nu-ls ansi-default sample colortable hyperlink-demo +for i in win11 vitest 8bit-color 24bit-color nu-ls ansi-default colortable hyperlink-demo do cat "$i.ans" | node ../ansi2-wasm/bin/cli.js -c > "$i.svg" cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=light -c > "$i-light.svg" cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=dark -c > "$i-dark.svg" + + cat "$i.ans" | node ../ansi2-wasm/bin/cli.js -c -f html > "$i.html" + cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=light -c -f html > "$i-light.html" + cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=dark -c -f html > "$i-dark.html" echo "$i done" done \ No newline at end of file