first pass at color name => theme color processing for pikchr
This commit is contained in:
@@ -14,6 +14,7 @@ import { bind_data_async } from './async-steps';
|
||||
import { render_vega_spec } from './vega';
|
||||
import { parse_attributes } from './attrs';
|
||||
import { MarkdownOptions } from './render';
|
||||
import { post_process_pikchr_svg } from './pikchr';
|
||||
|
||||
export function create_renderer(opts: MarkdownOptions) {
|
||||
const renderer = new marked.Renderer();
|
||||
@@ -275,23 +276,3 @@ function post_process_nomnoml_svg(svg: string, size?: string) {
|
||||
|
||||
return svg;
|
||||
}
|
||||
|
||||
const svg_text_fill_rgb_000 = /\b<text fill="rgb\(0,0,0\)"/gi;
|
||||
const svg_fill_rgb_000 = /fill:rgb\(0,0,0\)/gi;
|
||||
const svg_stroke_rgb_000 = /stroke:rgb\(0,0,0\)/gi;
|
||||
|
||||
// todo: css variables
|
||||
function post_process_pikchr_svg(svg: string, size?: string) {
|
||||
svg = strip_svg(svg);
|
||||
|
||||
// text
|
||||
svg = svg.replace(svg_text_fill_rgb_000, '<text fill="var(--theme-text-body, currentcolor)"');
|
||||
|
||||
// arrow heads
|
||||
svg = svg.replace(svg_fill_rgb_000, 'fill:var(--theme-line, currentcolor)');
|
||||
|
||||
// lines / boxes
|
||||
svg = svg.replace(svg_stroke_rgb_000, 'stroke:var(--theme-line, currentcolor)');
|
||||
|
||||
return svg;
|
||||
}
|
||||
|
Reference in New Issue
Block a user