Compare commits

...

3 commits

Author SHA1 Message Date
7ee84470e9 Workaround module import 2024-10-01 22:58:45 +02:00
9255f77d93 UCWTeX: Optional section eject 2024-10-01 21:14:42 +02:00
a9f41eb83e UCWTeX: textasciitilde 2024-10-01 21:13:07 +02:00
2 changed files with 9 additions and 4 deletions

View file

@ -7,6 +7,10 @@
\it{}#1% \it{}#1%
}} }}
\def\textasciitilde{$\sim$}
\def\N{{\bb N}} \def\N{{\bb N}}
\def\R{{\bb R}} \def\R{{\bb R}}
\def\E{{\bb E}} \def\E{{\bb E}}
@ -20,9 +24,10 @@
\fncount=1 \fncount=1
\def\fnmark{$^{\the\fncount}$} \def\fnmark{$^{\the\fncount}$}
\def\fn#1{\footnote\fnmark{#1}\advance\fncount by 1} \def\fn#1{\footnote\fnmark{#1}\advance\fncount by 1}
\def\sectioneject{\vfil\supereject}
\def\section#1#2{ \def\section#1#2{
\vfil\supereject \sectioneject
\vbox{\settextsize{20}\bf #1\kern 1em\relax#2% \vskip 16pt\vbox{\settextsize{20}\bf #1\kern 1em\relax#2%
\addtoc\tocsection{#1}{}{#2}% \addtoc\tocsection{#1}{}{#2}%
}\nobreak\vskip 12pt }\nobreak\vskip 12pt
} }

View file

@ -228,12 +228,12 @@ class TransformProcessor(NOPProcessor):
importedDoc = import_md(open(filename, "r").read()) importedDoc = import_md(open(filename, "r").read())
self.transform(importedDoc.content) self.transform(importedDoc.content)
elif e.attributes["type"] == "module": elif e.attributes["type"] == "module":
matches = re.match(r"^(\w+)(?: as (\w+))?$", e.content[0].text[1:]) matches = re.match(r"^([\w\.]+)(?: as (\w+))?$", e.content[0].text[1:])
if not matches: if not matches:
raise SyntaxError(f"`{e.content[0].text[1:]}`: invalid syntax") raise SyntaxError(f"`{e.content[0].text[1:]}`: invalid syntax")
module = importlib.import_module(matches.group(1)) module = importlib.import_module(matches.group(1))
module_name = matches.group(1) if matches.group(2) is None else matches.group(2) module_name = matches.group(1) if matches.group(2) is None else matches.group(2)
self.context.add_commands_from_module(module, module_name) self.context.add_commands_from_module(module, "")
elif e.attributes["type"] == "metadata": elif e.attributes["type"] == "metadata":
filename = self.context.dir + "/" + e.content[0].text[1:] filename = self.context.dir + "/" + e.content[0].text[1:]
self.context.add_dep(filename) self.context.add_dep(filename)