Merge pull request #12 from arne314/dev

V1.3.1
This commit is contained in:
arne314
2025-03-10 20:27:01 +01:00
committed by GitHub
6 changed files with 23 additions and 15 deletions

View File

@@ -61,9 +61,9 @@ return {
snip('sb', 'subset ', {}, math),
snip('sep', 'supset.eq ', {}, math),
snip('seb', 'subset.eq ', {}, math),
snip('nn', 'sect ', {}, math, 900),
snip('nn', 'inter ', {}, math, 900),
snip('uu', 'union ', {}, math, 900),
snip('bnn', 'sect.big ', {}, math),
snip('bnn', 'inter.big ', {}, math),
snip('buu', 'union.big ', {}, math),
snip('swo', 'without ', {}, math),

View File

@@ -4,7 +4,7 @@ build-backend = "pdm.backend"
[project]
name = "typstar"
version = "1.3.0"
version = "1.3.1"
description = "Neovim plugin for efficient note taking in Typst"
authors = [
{ name = "arne314" }

View File

@@ -9,20 +9,20 @@ class RecursiveConfigParser:
targets: set[str]
results: dict[str, dict[Path, str]]
def __init__(self, dir, targets):
def __init__(self, dir, targets, recursive=True):
self.dir = dir
self.targets = set(targets)
self.results = defaultdict(dict)
self._parse_recursive()
self._parse_dirs(recursive)
def _parse_recursive(self):
def _parse_dirs(self, recursive=True):
files = []
for target in self.targets:
files.extend(
glob(
f"{self.dir}/**/{target}", include_hidden=target.startswith("."), recursive=True
)
)
if recursive:
dir = f"{self.dir}/**/{target}"
else:
dir = f"{self.dir}/{target}"
files.extend(glob(dir, include_hidden=target.startswith("."), recursive=recursive))
for file in files:
file = Path(file)
if file.name in self.targets:

View File

@@ -126,7 +126,9 @@ class FlashcardParser:
f"Parsing flashcards in {scan_dir if single_file is None else single_file} ...",
flush=True,
)
configs = RecursiveConfigParser(root_dir, {".anki", ".anki.typ"})
configs = RecursiveConfigParser(
root_dir, {".anki", ".anki.typ"}, recursive=single_file is None
)
for file in glob(f"{scan_dir}/**/**.typ", recursive=True):
file = Path(file)

View File

@@ -1,6 +1,8 @@
import asyncio
import os
import random
import re
import sys
from pathlib import Path
from typing import List
@@ -18,7 +20,7 @@ default_preamble = """
class TypstCompilationError(ValueError):
pass
regex = re.compile(r"\nerror: ")
class TypstCompiler:
@@ -48,7 +50,11 @@ class TypstCompiler:
stdout, stderr = await proc.communicate()
os.remove(tmp_path)
if stderr:
raise TypstCompilationError(bytes.decode(stderr, encoding="utf-8"))
err = bytes.decode(stderr, encoding="utf-8")
if TypstCompilationError.regex.search("\n" + err):
raise TypstCompilationError(err)
else:
print(f"Typst compilation warning:\n{err}", file=sys.stderr, flush=True)
return stdout
async def _compile_flashcard(self, card: Flashcard):

2
uv.lock generated
View File

@@ -437,7 +437,7 @@ wheels = [
[[package]]
name = "typstar"
version = "1.2.0"
version = "1.3.1"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },