summaryrefslogtreecommitdiff
path: root/src/pyssg/md_parser.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-11-27 06:44:07 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-11-27 06:44:07 -0600
commit98bfded1b407431ad62642d7f029e4e5f3534c07 (patch)
tree8f38dd229fe54889d130eb0838c9c47619e96376 /src/pyssg/md_parser.py
parent9ea43f16d6440dce54ae7f78d46618d25e52f6ec (diff)
refactor code and fix type checks
still need to refactor more code before migrating to yaml config file
Diffstat (limited to 'src/pyssg/md_parser.py')
-rw-r--r--src/pyssg/md_parser.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/pyssg/md_parser.py b/src/pyssg/md_parser.py
index 759ead6..664532a 100644
--- a/src/pyssg/md_parser.py
+++ b/src/pyssg/md_parser.py
@@ -36,7 +36,9 @@ def _get_md_obj() -> Markdown:
log.debug('list of md extensions: (%s)',
', '.join([e if isinstance(e, str) else type(e).__name__
for e in exts]))
- return Markdown(extensions=exts, output_format='html5')
+ # for some reason, the d efinition for output_format doesn't include html5
+ # even though it is listed in the documentation, ignoring
+ return Markdown(extensions=exts, output_format='html5') # type: ignore
# page and file is basically a synonym here...
@@ -51,21 +53,14 @@ class MDParser:
self.db: Database = db
self.md: Markdown = _get_md_obj()
- self.all_files: list[Page] = None
+ self.all_files: list[Page] = []
# updated and modified are synonyms here
- self.updated_files: list[Page] = None
- self.all_tags: list[tuple[str]] = None
+ self.updated_files: list[Page] = []
+ self.all_tags: list[tuple[str, str]] = []
def parse_files(self) -> None:
log.debug('parsing all files')
- # initialize lists
- self.all_files = []
- self.updated_files = []
- self.all_tags = []
- # not used, not sure why i had this
- # all_tag_names: list[str] = []
-
for f in self.files:
log.debug('parsing file "%s"', f)
src_file: str = os.path.join(self.config.get('path', 'src'), f)
@@ -75,11 +70,12 @@ class MDParser:
log.debug('parsing md into html')
content: str = self.md.reset().convert(open(src_file).read())
+ # ignoring md.Meta type as it is not yet defined (because it is from an extension)
page: Page = Page(f,
self.db.e[f][0],
self.db.e[f][1],
content,
- self.md.Meta,
+ self.md.Meta, # type: ignore
self.config)
page.parse_metadata()