Skip to content

Commit

Permalink
Bold property for timing structure elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpieters committed Jul 30, 2023
1 parent bfab002 commit d3e521f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions data/input/11_appendix_timing_structures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sections:
toc_entry: Timing Structure of The Corp's Turn
rules:
- timing_structure:
bold:
elements:
- text: Draw Phase
elements:
Expand Down Expand Up @@ -47,6 +48,7 @@ sections:
toc_entry: Timing Structure of The Runner's Turn
rules:
- timing_structure:
bold:
elements:
- text: Action Phase
elements:
Expand Down Expand Up @@ -75,6 +77,7 @@ sections:
toc_entry: Timing Structure of a Run
rules:
- timing_structure:
bold:
elements:
- text: Initiation Phase
elements:
Expand Down
3 changes: 2 additions & 1 deletion rules_doc_generator/input/yaml/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def parse_example(yaml_example: Any) -> Example:

def parse_timing_structure(yaml_timing_structure: Any) -> TimingStructureElement:
text = parse_with_default(yaml_timing_structure, 'text', None, parse_format_text_field)
bold = parse_boolean(yaml_timing_structure, 'bold')
elements = parse_subelements(yaml_timing_structure, 'elements', parse_timing_structure)
return TimingStructureElement(text, elements)
return TimingStructureElement(text, bold, elements)

def parse_subrule(yaml_sub_rule: Any = False) -> SubRule:
id = parse_id(yaml_sub_rule, 'rule')
Expand Down
18 changes: 14 additions & 4 deletions rules_doc_generator/model/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@dataclass
class TimingStructureElement:
text: FormatText | None
bold: bool
elements: list[TimingStructureElement]

def to_html_l1(self, id_map: RefDict) -> str:
Expand Down Expand Up @@ -35,8 +36,14 @@ def to_html(self, id_map: RefDict) -> str:
result += '</ol>'
return result

def to_latex_l1(self, id_map: RefDict) -> str:
result = f'\\1 \\textbf{{{self.text.to_latex(id_map)}}}\n'
def to_latex_l1(self, id_map: RefDict, bold: bool) -> str:
result = '\\1 '
if bold:
result += '\\textbf{'
result += self.text.to_latex(id_map)
if bold:
result += '}'
result += '\n'
for elem in self.elements:
result += elem.to_latex_l2(id_map)
return result
Expand All @@ -51,11 +58,14 @@ def to_latex_l3(self, id_map: RefDict) -> str:
return f' \\3 {self.text.to_latex(id_map)}\n'

def to_latex(self, id_map: RefDict) -> str:
result = '\setlist[enumerate,1]{label=\\textbf{\\arabic*)}}\n'
if self.bold:
result = '\setlist[enumerate,1]{label=\\textbf{\\arabic*)}}\n'
else:
result = '\setlist[enumerate,1]{label=\\arabic*)}\n'
result += '\setlist[enumerate,2]{label=\\alph*)}\n'
result += '\setlist[enumerate,3]{label=\\roman*)}\n'
for elem in self.elements:
result += elem.to_latex_l1(id_map)
result += elem.to_latex_l1(id_map, self.bold)
return result

@dataclass
Expand Down

0 comments on commit d3e521f

Please sign in to comment.