Browse Source

Pokus o opravu #33.

citace
Jan Černohorský 1 year ago
parent
commit
c1430069ab
  1. 4
      src/formatitko/context.py
  2. 10
      src/formatitko/formatitko.py

4
src/formatitko/context.py

@ -58,8 +58,8 @@ class Context:
if isinstance(module, ModuleType): if isinstance(module, ModuleType):
module = module.__dict__ module = module.__dict__
prefix = module_name+"." if module_name else "" prefix = module_name+"." if module_name else ""
for name, func in module: for name, func in module.items():
if isinstance(func, CommandCallable): if isinstance(func, Callable):
self.set_command(prefix+name, func) self.set_command(prefix+name, func)
def is_flag_set(self, flag: str): def is_flag_set(self, flag: str):

10
src/formatitko/formatitko.py

@ -33,7 +33,7 @@ def main():
# just connect to an existing one. For formátíking many files in a row. # just connect to an existing one. For formátíking many files in a row.
# Use panflute to parse the input MD file # Use panflute to parse the input MD file
doc1 = import_md(open(args.input_filename, "r").read()) #doc1 = import_md(open(args.input_filename, "r").read())
doc2 = import_md(open(args.input_filename, "r").read()) doc2 = import_md(open(args.input_filename, "r").read())
if args.debug: if args.debug:
@ -41,15 +41,15 @@ def main():
# The language metadatum is important, so it's read before transformation and # The language metadatum is important, so it's read before transformation and
# then attached to a group inside the Doc # then attached to a group inside the Doc
language = doc1.get_metadata("lang", None, True) #language = doc1.get_metadata("lang", None, True)
context = Context(doc1, args.input_filename) #context = Context(doc1, args.input_filename)
# Transform the document. This includes all the fancy formatting this software does. # Transform the document. This includes all the fancy formatting this software does.
doc1 = doc1.walk(transform, context) #doc1 = doc1.walk(transform, context)
# Now wrap the document contents in a group, which is able to pop its language # Now wrap the document contents in a group, which is able to pop its language
# setting out to TeX # setting out to TeX
doc1.content = [BlockGroup(*doc1.content, context=context, metadata={"lang":language})] #doc1.content = [BlockGroup(*doc1.content, context=context, metadata={"lang":language})]
doc2 = TransformProcessor(args.input_filename).transform(doc2) doc2 = TransformProcessor(args.input_filename).transform(doc2)

Loading…
Cancel
Save