Skip to content

Commit 1037d37

Browse files
committed
Use parseBoolistList so I'm not repeating behavior
1 parent af2c724 commit 1037d37

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

‎bikeshed/metadata.py‎

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,6 @@ def parseLinkedText(key: str, val: str, lineNum: str | int | None) -> list[tuple
783783
def parseMarkupShorthands(key: str, val: str, lineNum: str | int | None) -> config.BoolSet:
784784
# Format is comma-separated list of shorthand category followed by boolean.
785785
# Output is a boolset of the shorthand categories.
786-
# TODO: Just call parseBoolishList instead
787786
vals = [v.strip() for v in val.lower().split(",")]
788787
ret = config.BoolSet(default=False)
789788
validCategories = frozenset(
@@ -796,39 +795,21 @@ def parseMarkupShorthands(key: str, val: str, lineNum: str | int | None) -> conf
796795
"http",
797796
"idl",
798797
"macros-in-autolinks",
798+
"markdown",
799799
"markdown-block",
800800
"markdown-inline",
801801
"markdown-escapes",
802802
"markup",
803803
"repository-links",
804804
],
805805
)
806-
for v in vals:
807-
pieces = v.split()
808-
if len(pieces) != 2:
809-
m.die(
810-
f"Markup Shorthand metadata pieces are a shorthand category and a boolean. Got:\n{v}",
811-
lineNum=lineNum,
812-
)
813-
continue
814-
name, boolstring = pieces
815-
# markdown is an alias for markdown-inline.
816-
# TODO: convert all specs to use markdown-inline, and then turn markdown
817-
# into a shorthand for markdown-*.
818-
if name == "markdown":
819-
name = "markdown-inline"
820-
assert name in validCategories
821-
elif name not in validCategories:
822-
m.die(f"Unknown Markup Shorthand category '{name}'.", lineNum=lineNum)
823-
continue
824-
onoff = boolish(boolstring)
825-
if onoff is None:
826-
m.die(
827-
f"Markup Shorthand metadata pieces are a shorthand category and a boolean. Got:\n{v}",
828-
lineNum=lineNum,
829-
)
830-
continue
831-
ret[name] = onoff
806+
ret = parseBoolishList(key, val.lower(), lineNum=lineNum, default=False, validLabels=validCategories)
807+
# markdown is an alias for markdown-inline.
808+
# TODO: convert all specs to use markdown-inline, and then turn markdown
809+
# into a shorthand for markdown-*.
810+
if ret.hasExplicit("markdown") and "markdown" in ret:
811+
ret["markdown-inline"] = True
812+
del ret["markdown"]
832813
return ret
833814

834815

0 commit comments

Comments
 (0)