mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
fix(datasheet): force minimum heading in info.md
This commit is contained in:
+6
-3
@@ -1,3 +1,4 @@
|
|||||||
|
import math
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
@@ -10,12 +11,14 @@ class HeadingsRenderer(MarkdownRenderer):
|
|||||||
def __init__(self, min_level: int):
|
def __init__(self, min_level: int):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.min_level = min_level
|
self.min_level = min_level
|
||||||
self.initial_level = float("inf")
|
self.initial_level = math.inf
|
||||||
|
|
||||||
def heading(self, token: Dict[str, Any], state: Any):
|
def heading(self, token: Dict[str, Any], state: Any):
|
||||||
if self.initial_level == float("inf"):
|
if self.initial_level == math.inf:
|
||||||
self.initial_level = token["attrs"]["level"]
|
self.initial_level = token["attrs"]["level"]
|
||||||
token["attrs"]["level"] += self.min_level - max(1, self.initial_level)
|
token["attrs"]["level"] = self.min_level + max(
|
||||||
|
token["attrs"]["level"] - self.initial_level, 0
|
||||||
|
)
|
||||||
return super().heading(token, state)
|
return super().heading(token, state)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user