diff --git a/lib/asserts.typ b/lib/asserts.typ index 6bb54f0..b88d139 100644 --- a/lib/asserts.typ +++ b/lib/asserts.typ @@ -1,14 +1,14 @@ #import "@preview/oxifmt:0.2.0": strfmt -#let assert_dict(arg, var_name) = { +#let assert-dict(arg, var_name) = { assert.eq(type(arg),dictionary, message: strfmt("expected {} to be a dictionary, found {}",var_name, type(arg))); } /// fail if field is not a bf-field -#let assert_bf-field(field) = { - assert_dict(field, "field") +#let assert-bf-field(field) = { + assert-dict(field, "field") let bf-type = field.at("bf-type", default: none) assert.eq(bf-type, "bf-field", message: strfmt("expected bf-type of 'bf-field', found {}",bf-type)); let field-type = field.at("field-type", default: none) @@ -16,8 +16,8 @@ } /// fail if field is not a bf-field of type data-field -#let assert_data-field(field) = { - assert_bf-field(field); +#let assert-data-field(field) = { + assert-bf-field(field); let field-type = field.at("field-type", default: none) assert.eq(field-type, "data-field", message: strfmt("expected field-type == data-field, found {}",field-type)) let size = field.data.size; @@ -25,8 +25,8 @@ } /// fail if field is not a bf-field of type data-field -#let assert_note-field(field) = { - assert_bf-field(field); +#let assert-note-field(field) = { + assert-bf-field(field); // Check for correct field-type let field-type = field.at("field-type", default: none) assert.eq(field-type, "note-field", message: strfmt("expected field-type == note-field, found {}",field-type)) @@ -39,13 +39,13 @@ } /// fail if it does not match -#let assert_header-field(field) = { - assert_bf-field(field); +#let assert-header-field(field) = { + assert-bf-field(field); } /// fail if cell is not a bf-cell -#let assert_bf-cell(cell) = { - assert_dict(cell, "cell"); +#let assert-bf-cell(cell) = { + assert-dict(cell, "cell"); // Check bf-type let bf-type = cell.at("bf-type", default: none) assert.eq(bf-type, "bf-cell", message: strfmt("expected bf-type of 'bf-cell', found {}",bf-type)); diff --git a/lib/gen.typ b/lib/gen.typ index df93776..53ee00a 100644 --- a/lib/gen.typ +++ b/lib/gen.typ @@ -16,7 +16,7 @@ // collect metadata into an dictionary let bh = fields.find(f => is-header-field(f)) // check level indentation for annotations - let (pre_levels, post_levels) = _get_max_annotation_levels(fields.filter(f => is-note-field(f) )) + let (pre_levels, post_levels) = get-max-annotation-levels(fields.filter(f => is-note-field(f) )) assert_level_cols(pre_levels, args.side.left_cols, "left") assert_level_cols(post_levels, args.side.right_cols, "right") // check if msb value is valid @@ -111,7 +111,7 @@ // note fields for f in _fields.filter(f => is-note-field(f)) { let row = if (f.data.row == auto) { - let anchor = _get_index_of_next_data_field(f.field-index, _fields) + let anchor = get-index-of-next-data-field(f.field-index, _fields) let anchor_field = fields.find(f => f.field-index == anchor) int( if (meta.msb == left) { (meta.size - anchor_field.data.range.end)/bpr } else { anchor_field.data.range.start/bpr }) } else { @@ -332,7 +332,7 @@ let label_num = c.label.num context { style(styles => { - set text(if c.format.text-size == auto { _get_header_font_size() } else { c.format.text-size }) + set text(if c.format.text-size == auto { get-default-header-font-size() } else { c.format.text-size }) set align(center + bottom) let size = measure(label_text, styles).width stack(dir: ttb, spacing: 0pt, @@ -350,14 +350,14 @@ } else { { [ - #if (is-data-cell(c) and (_get_field_font_size() != auto)) { + #if (is-data-cell(c) and (get-default-field-font-size() != auto)) { [ - #set text(_get_field_font_size()); + #set text(get-default-field-font-size()); #c.label ] - } else if (is-note-cell(c) and (_get_note_font_size() != auto)) { + } else if (is-note-cell(c) and (get-default-note-font-size() != auto)) { [ - #set text(_get_note_font_size()); + #set text(get-default-note-font-size()); #c.label ] } else { c.label } @@ -382,8 +382,8 @@ /// produce the final output #let generate_table(meta, cells) = { let table = context { - let rows = if (meta.rows.main == auto) { _get_row_height() } else { meta.rows.main } - if (type(rows) == array) { rows = rows.map(r => if (r == auto) { _get_row_height() } else { r } )} + let rows = if (meta.rows.main == auto) { get-default-row-height() } else { meta.rows.main } + if (type(rows) == array) { rows = rows.map(r => if (r == auto) { get-default-row-height() } else { r } )} // somehow grid_header still needs to exists. let grid_header = if (meta.header != none) { @@ -420,8 +420,8 @@ ([/* top left*/], align(bottom, box( width: 100%, - fill: if (meta.header.fill != auto) { meta.header.fill } else { _get_header_background() }, - stroke: if (meta.header.stroke != auto) { meta.header.stroke } else { _get_header_border() }, + fill: if (meta.header.fill != auto) { meta.header.fill } else { get-default-header-background() }, + stroke: if (meta.header.stroke != auto) { meta.header.stroke } else { get-default-header-border() }, grid_header )), [/*top right*/],) diff --git a/lib/states.typ b/lib/states.typ index 65df47e..7059da7 100644 --- a/lib/states.typ +++ b/lib/states.typ @@ -26,26 +26,26 @@ } -#let _get_row_height() = { +#let get-default-row-height() = { default_row_height.get() } -#let _get_header_font_size() = { +#let get-default-header-font-size() = { default_header_font_size.get() } -#let _get_field_font_size() = { +#let get-default-field-font-size() = { default_field_font_size.get() } -#let _get_note_font_size() = { +#let get-default-note-font-size() = { default_note_font_size.get() } -#let _get_header_background() = { +#let get-default-header-background() = { default_header_background.get() } -#let _get_header_border() = { +#let get-default-header-border() = { default_header_border.get() } \ No newline at end of file diff --git a/lib/utils.typ b/lib/utils.typ index 92eabda..e631601 100644 --- a/lib/utils.typ +++ b/lib/utils.typ @@ -9,7 +9,7 @@ } #let _get_field_type(field) = { - assert_bf-field(field); + assert-bf-field(field); return field.at("field-type", default: none); } @@ -21,24 +21,24 @@ /// Check if a given field is a data-field #let is-data-field(field) = { - assert_bf-field(field); + assert-bf-field(field); field.at("field-type", default: none) == "data-field" } /// Check if a given field is a note-field #let is-note-field(field) = { - assert_bf-field(field); + assert-bf-field(field); field.at("field-type", default: none) == "note-field" } /// Check if a given field is a header-field #let is-header-field(field) = { - assert_bf-field(field); + assert-bf-field(field); field.at("field-type", default: none) == "header-field" } /// Return the index of the next data-field -#let _get_index_of_next_data_field(idx, fields) = { +#let get-index-of-next-data-field(idx, fields) = { let res = fields.sorted(key: f => f.field-index).find(f => f.field-index > idx and is-data-field(f)) if res != none { res.field-index } else { none } } @@ -54,11 +54,11 @@ } /// calculates the max annotation level for both sides -#let _get_max_annotation_levels(annotations) = { +#let get-max-annotation-levels(annotations) = { let left_max_level = -1 let right_max_level = -1 for field in annotations { - assert_bf-field(field) + assert-bf-field(field) let (side, level, ..) = field.data; if (side == left) { left_max_level = calc.max(left_max_level,level) @@ -109,7 +109,7 @@ } /// Return the current index of a field or cell -#let _get_index(f) = { +#let get-index(f) = { if is-bf-field(f) { return f.field-index } else if is-bf-cell(f) {