luci package¶
luci.cli module¶
luci.acromerge module¶
- luci.acromerge.format_acrodefs(acro_map: dict[str, str], command: str) str [source]¶
Format acrodefs into a single string for output.
- Parameters:
acro_map – Dictionary of short -> long definitions.
command – The base command to emit, e.g. “acro” or “acrodef”.
- Returns:
Formatted string of <command>{…} entries.
- luci.acromerge.merge_acrodef_files(file_paths: list[Path]) dict[str, tuple[str, str]] [source]¶
Merge multiple LaTeX acro/acrodef files into a deduplicated dictionary.
- Parameters:
file_paths – List of Path objects to LaTeX files.
- Returns:
Dictionary of short -> long definitions.
- luci.acromerge.merge_acronyms(files: list[Path], output: Path | None = None, command: str = 'acro')[source]¶
Extract and merge acronyms from multiple LaTeX files into a single file.
- luci.acromerge.parse_acrodefs_from_file(path: Path) dict[str, tuple[str, str]] [source]¶
Parse acro and acrodef entries from a LaTeX file, supporting the optional short-name form: acro{id}[short]{long}.
- Parameters:
path – Path to the LaTeX file.
- Returns:
Dictionary mapping id to (short, long) where short is optional.
luci.archive module¶
- luci.archive.archive(main: Path, output: Path | None = None, validate: bool = True, bbl: bool = False, bibstyle: BibStyle = BibStyle.bibtex)[source]¶
Create a zip archive of a LaTeX project by flattening inputs.
Flattens includes and strips paths from common commands to collect local dependencies next to the main file, then zips them. With –validate, runs tectonic on the archive to ensure it compiles; with –bbl, includes generated .bbl files after a build.
- luci.archive.flatten_latex(file_path: Path, commands_to_flatten=['documentclass', 'includegraphics', 'addbibresource', 'bibliography', 'RequirePackage', 'usepackage', 'InputIfFileExists', 'templatetype'], root: Path | None = None, scratch=None)[source]¶
Recursively flattens a LaTeX file by replacing input and include with actual content. Returns the flattened LaTeX as a string.
- luci.archive.replace_citeauthor_commands(latex_text: str, bib_files: Iterable[Path], max_names: int = 2) str [source]¶
Replace citeauthor and citeauthorcite commands with author text.
\citeauthor{foo}
-> “<authors for foo>”\citeauthorcite{foo}
-> “<authors for foo>cite{foo}”
When an entry has more than
max_names
authors, only the first last name is kept followed by “ et al.”. Otherwise, up tomax_names
last names are joined with “ and “.- Parameters:
latex_text – The flattened LaTeX text.
bib_files – Paths to .bib files referenced by the project.
max_names – Maximum number of last names to display before using et al.
- Returns:
Updated LaTeX text with citeauthor macros replaced.
- luci.archive.strip_paths_from_command(latex_text: str, command: str) tuple[str, dict[str, Path]] [source]¶
Replaces command{path/to/file} with command{file} using pathlib, and returns a list of (original path, updated line) replacements.
- Parameters:
latex_text – The LaTeX document as a string.
command – The command name without backslash, e.g., ‘includegraphics’.
- Returns:
Updated LaTeX text with paths stripped
List of (original path, updated line) for each replacement
- Return type:
A tuple
luci.bibtools module¶
- luci.bibtools.merge_and_dedupe(bibfiles: list[Path], output: Path = PosixPath('merged.bib'), mapping: Path = PosixPath('duplicate_keys.json'))[source]¶
Merge multiple BibTeX files and deduplicate using bibtex-tidy.
Writes the deduplicated BibTeX to –output and a JSON map of removed duplicate keys to kept keys to –mapping. Earlier files take precedence. Requires bibtex-tidy to be installed and on PATH.
- luci.bibtools.merge_bibtex_files(bibfiles: list[Path], merged_path: Path)[source]¶
Merge multiple BibTeX files into a single file (earlier takes precedence).