katex_parser/unicode/
config.rs1use std::rc::Rc;
2
3use crate::anvil::SpacingSpec;
4use crate::ast::StyleLevel;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8pub struct RenderConfig {
9 pub fraction_slash: String,
10 pub spacing: SpacingSpec,
11 pub line_style: LineStyle,
12}
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16#[derive(Default)]
17pub enum LineStyle {
18 Ascii,
19 #[default]
20 Unicode,
21}
22
23
24pub fn unicode_text_spacing() -> SpacingSpec {
27 SpacingSpec {
28 thick: " ".to_string(),
29 medium: " ".to_string(),
30 thin: " ".to_string(),
31 operator: " ".to_string(),
32 }
33}
34
35impl RenderConfig {
36 pub fn new() -> Self {
37 RenderConfig {
38 fraction_slash: "∕".to_string(),
39 spacing: unicode_text_spacing(),
40 line_style: LineStyle::Unicode,
41 }
42 }
43}
44
45impl Default for RenderConfig {
46 fn default() -> Self {
47 RenderConfig::new()
48 }
49}
50
51pub fn line_style_frac_bar(style: LineStyle) -> String {
53 match style {
54 LineStyle::Ascii => "-".to_string(),
55 LineStyle::Unicode => "─".to_string(),
56 }
57}
58
59#[derive(Clone)]
60pub(crate) struct RenderState {
61 pub style: StyleLevel,
62 pub in_display: bool,
63 pub in_tight: bool,
64 pub config: Rc<RenderConfig>,
65}