mirror of
https://github.com/Ascyii/typstar.git
synced 2026-01-01 13:34:24 -05:00
@@ -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),
|
||||
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user