Creating of dirs in namespaces only when they're accessed (this is needed because until then, we don't know what $dir is. Also telling pandoc to strip comments.
This commit is contained in:
parent
a1c439c32e
commit
cd07b3abf8
2 changed files with 11 additions and 8 deletions
|
@ -38,11 +38,6 @@ class ImageProcessorNamespace:
|
||||||
self.lookup_dirs = lookup_dirs
|
self.lookup_dirs = lookup_dirs
|
||||||
self.web_path = web_path if web_path[-1] != "/" else web_path[:-1]
|
self.web_path = web_path if web_path[-1] != "/" else web_path[:-1]
|
||||||
self.include_src = include_src
|
self.include_src = include_src
|
||||||
if not os.path.exists(self.public_dir):
|
|
||||||
os.mkdir(self.public_dir)
|
|
||||||
if not os.path.exists(self.cache_dir):
|
|
||||||
os.mkdir(self.cache_dir)
|
|
||||||
|
|
||||||
|
|
||||||
class ImageProcessorSearcher:
|
class ImageProcessorSearcher:
|
||||||
def get_lookup_dirs(self) -> list[str]:
|
def get_lookup_dirs(self) -> list[str]:
|
||||||
|
@ -96,6 +91,8 @@ class ImageProcessorCacheSearcher(ImageProcessorSearcher):
|
||||||
|
|
||||||
def __init__(self, cache_dir: str):
|
def __init__(self, cache_dir: str):
|
||||||
self.cache_dir = cache_dir
|
self.cache_dir = cache_dir
|
||||||
|
if not os.path.exists(self.cache_dir):
|
||||||
|
os.makedirs(self.cache_dir, exist_ok=True)
|
||||||
|
|
||||||
def get_lookup_dirs(self) -> list[str]:
|
def get_lookup_dirs(self) -> list[str]:
|
||||||
return [self.cache_dir]
|
return [self.cache_dir]
|
||||||
|
@ -129,10 +126,16 @@ class ImageProcessorNamespaceSearcher(ImageProcessorSearcher):
|
||||||
return path.replace("$dir", self.rel_dir)
|
return path.replace("$dir", self.rel_dir)
|
||||||
|
|
||||||
def get_cache_dir(self) -> str:
|
def get_cache_dir(self) -> str:
|
||||||
return self.transform_path(self.namespace.cache_dir)
|
cache_dir = self.transform_path(self.namespace.cache_dir)
|
||||||
|
if not os.path.exists(cache_dir):
|
||||||
|
os.makedirs(cache_dir, exist_ok=True)
|
||||||
|
return cache_dir
|
||||||
|
|
||||||
def get_public_dir(self) -> str:
|
def get_public_dir(self) -> str:
|
||||||
return self.transform_path(self.namespace.public_dir)
|
public_dir = self.transform_path(self.namespace.public_dir)
|
||||||
|
if not os.path.exists(public_dir):
|
||||||
|
os.makedirs(public_dir, exist_ok=True)
|
||||||
|
return public_dir
|
||||||
|
|
||||||
def get_web_path(self) -> str:
|
def get_web_path(self) -> str:
|
||||||
return self.transform_path(self.namespace.web_path)
|
return self.transform_path(self.namespace.web_path)
|
||||||
|
|
|
@ -37,7 +37,7 @@ def parse_string(s: str) -> list[Union[Str, Space]]:
|
||||||
# we ever want to disable or enable some of panflute's markdown extensions,
|
# we ever want to disable or enable some of panflute's markdown extensions,
|
||||||
# this is the place to do it.
|
# this is the place to do it.
|
||||||
def import_md(s: str, standalone: bool=True) -> Union[Doc, list[Element]]:
|
def import_md(s: str, standalone: bool=True) -> Union[Doc, list[Element]]:
|
||||||
return convert_text(s, standalone=standalone, input_format="markdown-definition_lists-latex_macros")
|
return convert_text(s, standalone=standalone, input_format="markdown-definition_lists-latex_macros", extra_args=["--strip-comments"])
|
||||||
|
|
||||||
def import_md_list(s: str) -> list[Element]:
|
def import_md_list(s: str) -> list[Element]:
|
||||||
return import_md(s, standalone=False)
|
return import_md(s, standalone=False)
|
||||||
|
|
Loading…
Reference in a new issue