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.add_bbl_file(archive: Path, main: str, deps: dict[str, Path])[source]
luci.archive.archive(main: Path, output: Path | None = None, validate: bool = True, bbl: bool = False)[source]
luci.archive.create_archive(archive: str, files: dict[str, Path])[source]
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.scan_latex_log(log_path: Path)[source]
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.archive.validate_archive(archive: Path, mainfile: str)[source]

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, deduplicate, and write output and removed key map. Earlier files take precedence.

This function takes a list of BibTeX files, merges them into a single file, and then uses bibtex-tidy to deduplicate the entries. The deduplicated BibTeX file is written to the specified output path. A JSON file containing a mapping of the removed duplicate keys to the keys that were kept is also generated.

Parameters:
  • bibfiles – A list of paths to the BibTeX files to merge.

  • output – The path to write the merged and deduplicated BibTeX file to.

  • mapping – The path to write the JSON file with the duplicate key mappings to.

luci.bibtools.merge_bibtex_files(bibfiles: list[Path], merged_path: Path)[source]

Merge multiple BibTeX files into a single file (earlier takes precedence).

luci.bibtools.run_bibtex_tidy_dedupe(input_bib: Path) tuple[str, dict[str, str]][source]

Run bibtex-tidy to deduplicate, returning (deduplicated text, old→new mapping).

luci.bibtools.strip_emojis(text: str) str[source]

Remove emoji characters from text.

luci.bibtools.update_citation(duplicate_keys: Path, files: list[Path])[source]

Update citations in LaTeX files based on duplicate key mappings from a JSON file.