Commit 50f84c21 authored by Jakob Lerch's avatar Jakob Lerch
Browse files

fix(parser): match german date format

parent 2afa9e26
......@@ -36,6 +36,7 @@ def _match_to_date(match: re.Match[str]) -> dt.date:
re_date = re.compile(r"(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})")
re_date_de = re.compile(r"(?P<day>\d{1,2}).(?P<month>\d{1,2}).(?P<year>\d{4})")
def get_date(document: mistletoe.Document) -> Optional[dt.date]:
......@@ -50,11 +51,10 @@ def get_date(document: mistletoe.Document) -> Optional[dt.date]:
title = "".join(
map(renderer.render, flatten(heading, mistletoe.span_token.RawText))
)
match = re_date.search(title)
if not match:
continue
return _match_to_date(match)
for pattern in [re_date, re_date_de]:
if match := pattern.search(title):
return _match_to_date(match)
return None
......@@ -110,7 +110,8 @@ re_end_time = re.compile(
def get_end_time(document: mistletoe.Document) -> Optional[dt.time]:
renderer = mistletoe.BaseRenderer()
headings = flatten(document, (DokuWikiHeading, mistletoe.block_token.Heading))
headings = flatten(
document, (DokuWikiHeading, mistletoe.block_token.Heading))
for heading in headings:
title = "".join(
......@@ -171,7 +172,8 @@ def get_attendees(document: mistletoe.Document) -> Iterable[Attendee]:
if group:
attendees = " ".join(
map(renderer.render, flatten(span, mistletoe.span_token.RawText))
map(renderer.render, flatten(
span, mistletoe.span_token.RawText))
)
yield from parse_attendees(attendees, group=group)
continue
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment