Skip to content
Snippets Groups Projects
Commit 1391ee18 authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Add one empty line when writing out the clauses.

This prevents a problem with mkdocs that if the first line contains a colon (:) it is wrongly interpreted as a mkdocs configuration
parent 401284c8
No related branches found
No related tags found
No related merge requests found
...@@ -71,13 +71,15 @@ class Clause: ...@@ -71,13 +71,15 @@ class Clause:
self.lines.extend(clause.lines) self.lines.extend(clause.lines)
def asStringList(self) -> list[str]: def asStringList(self, paddings:int = 0) -> list[str]:
""" Return the clause as a list of strings. """ Return the clause as a list of strings.
Args:
paddings: The number of empty lines to add before the clause.
Returns: Returns:
The clause's lines as a list of strings. The clause's lines as a list of strings.
""" """
return [ l.text for l in self.lines ] return [ '\n' for _ in range(paddings) ] + [ l.text for l in self.lines ]
def __len__(self) -> int: def __len__(self) -> int:
...@@ -380,7 +382,11 @@ def writeClauses(outClauses:list[Clause], filename:str, navTitle:str) -> None: ...@@ -380,7 +382,11 @@ def writeClauses(outClauses:list[Clause], filename:str, navTitle:str) -> None:
if verbose: if verbose:
print(f'[dim]Writing "{f.clauseNumber}.md" - "{f.title}"') print(f'[dim]Writing "{f.clauseNumber}.md" - "{f.title}"')
with open(f'{os.path.dirname(filename)}/{navTitle}/{f.clauseNumber}.md', 'w') as file: with open(f'{os.path.dirname(filename)}/{navTitle}/{f.clauseNumber}.md', 'w') as file:
file.writelines(f.asStringList()) # Add one empty line before the clause. This is done to avoid
# a bug in MkDocs that does not display the first line of a clause
# if it contains a colon. It does not matter otherwise if the line
# is empty or not.
file.writelines(f.asStringList(1))
# write nav.yml file # write nav.yml file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment