Skip to content

Commit

Permalink
Fixed detection of markdown frontmatter blocks
Browse files Browse the repository at this point in the history
Implemented the smallest / safest fix I could think of,
when you're done processing / editing the first frontmatter
block skip the rest, don't look for more in the same file.

This issue would cause code blocks which had triple
dashes at the start of lines (like an RSA public key),
to get some funny looking metadata inserted into them.

Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
  • Loading branch information
olehermanse committed Mar 18, 2024
1 parent fcc11f5 commit c25f05c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions generator/_scripts/cfdoc_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ def processMetaData(file_path, config):

out_file = open(file_path, "w")
in_header = False
did_header = False
for line in lines:
if did_header:
out_file.write(line)
continue
if line.find("---") == 0:
in_header = not in_header
if not in_header: # write new tags before header is terminated
out_file.write("categories: [%s]\n" % category)
out_file.write("alias: %s.html\n" % alias)
did_header = True
if in_header: # skip hard-coded duplicates
if line.find("categories:") == 0:
continue
Expand Down

0 comments on commit c25f05c

Please sign in to comment.