From 0c1099022fcb747ad2a9e8e04bcd2992417ca8e9 Mon Sep 17 00:00:00 2001 From: AlphaJack Date: Thu, 31 Oct 2024 00:27:19 +0100 Subject: [PATCH] feat: added typst support --- tests/input/typst-simple.typ | 11 +++++++++++ tests/reference/typst-simple.typ | 23 +++++++++++++++++++++++ toc/toc.py | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/input/typst-simple.typ create mode 100644 tests/reference/typst-simple.typ diff --git a/tests/input/typst-simple.typ b/tests/input/typst-simple.typ new file mode 100644 index 0000000..7292ac2 --- /dev/null +++ b/tests/input/typst-simple.typ @@ -0,0 +1,11 @@ +// This is a minimal Typst document with multi-level headings and comments + += Document Title + +== Heading Level 2 + +=== Heading Level 3 + +==== Heading Level 4 + +=== Heading Level 3 \ No newline at end of file diff --git a/tests/reference/typst-simple.typ b/tests/reference/typst-simple.typ new file mode 100644 index 0000000..2b6ff25 --- /dev/null +++ b/tests/reference/typst-simple.typ @@ -0,0 +1,23 @@ +// ┌───────────────────────────────────────────────────────────────┐ +// │ Contents of typst-simple.typ │ +// ├───────────────────────────────────────────────────────────────┘ +// │ +// ├──┐Document Title +// │ └──┐Heading Level 2 +// │ ├──┐Heading Level 3 +// │ │ └── Heading Level 4 +// │ └── Heading Level 3 +// │ +// └─────────────────────────────────────────────────────────────── + +// This is a minimal Typst document with multi-level headings and comments + += Document Title + +== Heading Level 2 + +=== Heading Level 3 + +==== Heading Level 4 + +=== Heading Level 3 \ No newline at end of file diff --git a/toc/toc.py b/toc/toc.py index 591699b..d88db29 100644 --- a/toc/toc.py +++ b/toc/toc.py @@ -513,7 +513,7 @@ def _toc_body(self) -> list: _data = self._read_file() _lines = _data.splitlines() match self.extension: - case "ad" | "adoc" | "asc" | "asciidoc": + case "ad" | "adoc" | "asc" | "asciidoc" | "typ": _newtoc = self._process_increasing(_lines, "=") case "beancount": _newtoc = self._process_increasing(_lines, "*")