1
0

feat: add some extractor

This commit is contained in:
2026-06-13 09:50:58 +08:00
parent 6d611f172f
commit 45e00dfec2
2 changed files with 27 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
from typing import cast
from pylatexenc.latexwalker import LatexNode, LatexMacroNode
from .common import Extractor from .common import Extractor
class AustExtractor(Extractor): class AustExtractor(Extractor):
@@ -5,4 +7,14 @@ class AustExtractor(Extractor):
def __init__(self) -> None: def __init__(self) -> None:
pass pass
def extract_include_command(self, node: LatexNode) -> str | None:
if not isinstance(node, LatexMacroNode):
return None
macro_name = cast(str, node.macroname)
match macro_name:
case 'include' | 'input':
# TODO: handle include command
return None
case _:
return None

View File

@@ -1,7 +1,21 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from pylatexenc.latexwalker import LatexNode, LatexMacroNode
class Extractor(ABC): class Extractor(ABC):
pass """
An abstract base class for all extractors.
Extractors are used to extract information from LaTeX nodes.
"""
@abstractmethod
def extract_include_command(self, node: LatexNode) -> str | None:
"""
Extract the include command from a LaTeX node.
:param node: The LaTeX node to extract the include command from.
:return: The path to the include file, otherwise None.
"""
pass