Skip to content

Conversation

@mcdemarco
Copy link

It seems harmless to support all header levels. I had a third-level header in my markdown and the error I got was completely opaque:

Traceback (most recent call last):
  File "md_to_bgg.py", line 283, in <module>
    print(parse_and_render(input_file.read()))
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/__init__.py", line 112, in __call__
    return self.convert(text)
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/__init__.py", line 109, in convert
    return self.render(self.parse(text))
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/__init__.py", line 129, in render
    return r.render(parsed)
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/renderer.py", line 69, in render
    return self.render_children(element)
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/renderer.py", line 83, in render_children
    rendered = [self.render(child) for child in element.children]  # type: ignore
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/renderer.py", line 83, in <listcomp>
    rendered = [self.render(child) for child in element.children]  # type: ignore
  File "/Users/mcd/.pyenv/versions/3.6.15/lib/python3.6/site-packages/marko/renderer.py", line 68, in render
    return render_func(element)
  File "md_to_bgg.py", line 167, in render_heading
    size = {1: 24, 2: 18}[element.level]  # Maximum 2 levels!
KeyError: 3

Copy link
Owner

@lebigot lebigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

The last 2–3 levels do not really work because they are smaller than (or identical to) the default text on BoardGameGeek (which appears to be of size 12).

This can be seen with the following BGG Markup:

[size=14]14 size[/size]
Normal text

[size=12]12 size[/size]
Normal text

[size=10]10 size[/size]
Normal text

Supporting 6 levels would bring md_to_bgg closer to CommonMark, so it doesn't hurt to support them.

We just need to go from size 24 to size, say, 14 in 6 steps. This doesn't leave much liberty, leading for example to something like sizes 24, 22… 16, 14. The problem with this is that the most commonly used headers (level 1–2 or maybe 1–3) are not so easy to distinguish anymore, which is not so nice for users.

We could instead have levels 4–6 be in size 12 (normal text), maybe, with bold and italics used for distinguishing between them? Levels 1–3 would remain in sizes 24, 18 and 14.

Other options can be interesting too (like maybe 24, 20, 16, 14 and then 12 bold and 12 italics?

What do you think?

@mcdemarco
Copy link
Author

mcdemarco commented Apr 14, 2024

I went with the low sizes because I've seen it done before in markdown conversions. Yes, it was strange, but someone using a sixth-level header is probably used to seeing something strange. Stopping at a flat size is also a common solution.

In either case, I would also expect some added clarity from all headers being in bold. I didn't quite register that none of them were made boldface by the md_to_bgg.py script.

My main concern was avoiding the error; any reasonable behavior is fine by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants