mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
code block support, kind-of
This commit is contained in:
parent
9ee8096e33
commit
fbdd3f8971
@ -71,12 +71,30 @@ class Changelog:
|
|||||||
self.lines = fp.readlines()
|
self.lines = fp.readlines()
|
||||||
|
|
||||||
section = ''
|
section = ''
|
||||||
last_line = ''
|
|
||||||
in_block = False
|
in_block = False
|
||||||
|
in_code = False
|
||||||
|
|
||||||
# loop over lines in the file
|
# loop over lines in the file
|
||||||
for line_no, line in enumerate(self.lines):
|
for line_no, line in enumerate(self.lines):
|
||||||
if match := re.fullmatch(
|
if in_code:
|
||||||
|
if re.match(r'^```', line):
|
||||||
|
line = '```'
|
||||||
|
in_code = False
|
||||||
|
in_block = False
|
||||||
|
|
||||||
|
if len(self.versions) == 0:
|
||||||
|
self.header += line
|
||||||
|
else:
|
||||||
|
self.versions[-1].sections[section][-1] += line
|
||||||
|
|
||||||
|
elif re.match(r'^```', line):
|
||||||
|
in_code = True
|
||||||
|
if len(self.versions) == 0:
|
||||||
|
self.header += line
|
||||||
|
else:
|
||||||
|
self.versions[-1].sections[section].append(line)
|
||||||
|
|
||||||
|
elif match := re.fullmatch(
|
||||||
r'^##\s+(?P<name>\S*)(?:\s+-\s+(?P<date>\S+))?\s*?(?P<extra>.*?)\s*#*$', line):
|
r'^##\s+(?P<name>\S*)(?:\s+-\s+(?P<date>\S+))?\s*?(?P<extra>.*?)\s*#*$', line):
|
||||||
# this is a version header in the form '## Name (- date) (tags*) (#*)'
|
# this is a version header in the form '## Name (- date) (tags*) (#*)'
|
||||||
section = ''
|
section = ''
|
||||||
@ -119,8 +137,6 @@ class Changelog:
|
|||||||
self.versions[-1].sections[section].append(line.strip())
|
self.versions[-1].sections[section].append(line.strip())
|
||||||
in_block = True
|
in_block = True
|
||||||
|
|
||||||
last_line = line
|
|
||||||
|
|
||||||
# handle links
|
# handle links
|
||||||
for version in self.versions:
|
for version in self.versions:
|
||||||
if match := re.fullmatch(r'\[(.*)]', version.name):
|
if match := re.fullmatch(r'\[(.*)]', version.name):
|
||||||
|
Loading…
Reference in New Issue
Block a user