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

Corrected printing of footnotes. Also, no more linebreaks at (pseudo)terminal...

Corrected printing of footnotes. Also, no more linebreaks at (pseudo)terminal width. This broke pipe table outputs
parent a6bd358c
No related branches found
No related tags found
1 merge request!1Restructuring and cleaning scripts for Mkdocs
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
""" """
import argparse, sys import argparse, sys
from rich import print
from markdownTools import analyseMarkdown, setLoggers from markdownTools import analyseMarkdown, setLoggers
def main() -> None: def main() -> None:
......
...@@ -215,6 +215,13 @@ class Footnote: ...@@ -215,6 +215,13 @@ class Footnote:
self.line = line self.line = line
""" The line of the footnote. """ """ The line of the footnote. """
def __str__(self) -> str:
return self.line.text
def __repr__(self) -> str:
return self.__str__()
class Document: class Document:
""" Represents the document object. """ """ Represents the document object. """
clauses:list[Clause] = [] clauses:list[Clause] = []
...@@ -386,7 +393,7 @@ class Document: ...@@ -386,7 +393,7 @@ class Document:
def __str__(self) -> str: def __str__(self) -> str:
""" Return the document as a string. """ """ Return the document as a string. """
return '\n'.join([ str(c) for c in self.clauses ]) return '\n'.join([ str(c) for c in self.clauses + self.footnotes ])
def __repr__(self) -> str: def __repr__(self) -> str:
...@@ -545,3 +552,47 @@ def analyseMarkdown(filename:Optional[str]=None, inLines:Optional[list[str]]=Non ...@@ -545,3 +552,47 @@ def analyseMarkdown(filename:Optional[str]=None, inLines:Optional[list[str]]=Non
return Document(outClauses, footnotes) return Document(outClauses, footnotes)
def main() -> None:
"""Hauptfunktion zur Verarbeitung von Markdown-Dateien über die Kommandozeile."""
import argparse
parser = argparse.ArgumentParser(description='Markdown-Dateien verarbeiten, um Gittertabellen zu konvertieren und andere Formatierungen zu handhaben')
parser.add_argument('eingabe', help='Eingabe-Markdown-Datei')
parser.add_argument('-v', '--verbose', action='store_true', help='Ausführliche Ausgabe aktivieren')
parser.add_argument('-vv', '--sehr-verbose', action='store_true', help='Sehr ausführliche Ausgabe aktivieren')
parser.add_argument('-i', '--ignoriere-titel', nargs='+', default=[], help='Liste der zu ignorierenden Titel')
parser.add_argument('-s', '--teilungs-ebene', type=int, default=1, help='Ebene, auf der das Dokument geteilt werden soll (Standard: 1)')
parser.add_argument('-f', '--ignoriere-erste', action='store_true', help='Inhalt bis zur ersten Überschrift ignorieren')
args = parser.parse_args()
# Verbositätsebenen setzen
global verbose, veryVerbose
verbose = args.verbose
veryVerbose = args.sehr_verbose
# Markdown-Datei verarbeiten
doc = analyseMarkdown(args.eingabe)
# Dokument teilen und verarbeiten
doc.splitMarkdownDocument(
ignoreTitles=args.ignoriere_titel,
splitLevel=args.teilungs_ebene,
ignoreUntilFirstHeading=args.ignoriere_erste
)
# Dokumentenelemente aktualisieren
doc.insertFootnotes()
doc.updateLinks()
doc.updateNotes()
# Verarbeitetes Dokument ausgeben
for clause in doc.clauses:
print(f"\n{'#' * clause.level} {clause.title}")
for line in clause.lines:
print(line.text, end='')
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment