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('sb', 'subset ', {}, math),
snip('sep', 'supset.eq ', {}, math), snip('sep', 'supset.eq ', {}, math),
snip('seb', 'subset.eq ', {}, math), snip('seb', 'subset.eq ', {}, math),
snip('nn', 'sect ', {}, math, 900), snip('nn', 'inter ', {}, math, 900),
snip('uu', 'union ', {}, math, 900), snip('uu', 'union ', {}, math, 900),
snip('bnn', 'sect.big ', {}, math), snip('bnn', 'inter.big ', {}, math),
snip('buu', 'union.big ', {}, math), snip('buu', 'union.big ', {}, math),
snip('swo', 'without ', {}, math), snip('swo', 'without ', {}, math),

View File

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

View File

@@ -9,20 +9,20 @@ class RecursiveConfigParser:
targets: set[str] targets: set[str]
results: dict[str, dict[Path, str]] results: dict[str, dict[Path, str]]
def __init__(self, dir, targets): def __init__(self, dir, targets, recursive=True):
self.dir = dir self.dir = dir
self.targets = set(targets) self.targets = set(targets)
self.results = defaultdict(dict) self.results = defaultdict(dict)
self._parse_recursive() self._parse_dirs(recursive)
def _parse_recursive(self): def _parse_dirs(self, recursive=True):
files = [] files = []
for target in self.targets: for target in self.targets:
files.extend( if recursive:
glob( dir = f"{self.dir}/**/{target}"
f"{self.dir}/**/{target}", include_hidden=target.startswith("."), recursive=True else:
) dir = f"{self.dir}/{target}"
) files.extend(glob(dir, include_hidden=target.startswith("."), recursive=recursive))
for file in files: for file in files:
file = Path(file) file = Path(file)
if file.name in self.targets: 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} ...", f"Parsing flashcards in {scan_dir if single_file is None else single_file} ...",
flush=True, 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): for file in glob(f"{scan_dir}/**/**.typ", recursive=True):
file = Path(file) file = Path(file)

View File

@@ -1,6 +1,8 @@
import asyncio import asyncio
import os import os
import random import random
import re
import sys
from pathlib import Path from pathlib import Path
from typing import List from typing import List
@@ -18,7 +20,7 @@ default_preamble = """
class TypstCompilationError(ValueError): class TypstCompilationError(ValueError):
pass regex = re.compile(r"\nerror: ")
class TypstCompiler: class TypstCompiler:
@@ -48,7 +50,11 @@ class TypstCompiler:
stdout, stderr = await proc.communicate() stdout, stderr = await proc.communicate()
os.remove(tmp_path) os.remove(tmp_path)
if stderr: 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 return stdout
async def _compile_flashcard(self, card: Flashcard): async def _compile_flashcard(self, card: Flashcard):

2
uv.lock generated
View File

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