Metadata-Version: 2.4
Name: tex2markdown
Version: 0.2.2
Summary: Source-preserving LaTeX-to-Markdown for scientific papers
Project-URL: Homepage, https://github.com/jiosephlee/tex2markdown
Project-URL: Repository, https://github.com/jiosephlee/tex2markdown
Project-URL: Issues, https://github.com/jiosephlee/tex2markdown/issues
Author-email: Joseph Lee <jiosephlee@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: arxiv,latex,markdown,scientific-papers,tex
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup :: LaTeX
Requires-Python: >=3.10
Requires-Dist: pylatexenc<3,>=2.10
Requires-Dist: pypandoc-binary<2,>=1.17
Description-Content-Type: text/markdown

# tex2markdown

`tex2markdown` converts a LaTeX document or project to one Markdown string. It
preserves LaTeX math and fragile formal content, converts suitable data tables,
expands local inputs and macros, and removes figures, captions, image commands,
and bibliographies.

The package is self-contained and has no runtime dependencies.

## Install

```bash
pip install tex2markdown
```

## Python API

Convert one in-memory document:

```python
from tex2markdown import convert

markdown = convert(r"""
\documentclass{article}
\title{A Small Example}
\begin{document}
\maketitle
\section{Result}
The value is $x^2$.
\end{document}
""")
```

Strings passed to `convert()` are always interpreted as LaTeX source, never as
file paths. For a file or a multi-file project, use `convert_path()`:

```python
from tex2markdown import convert_path

markdown = convert_path("paper.tex")
markdown = convert_path("project/")
markdown = convert_path("project/", main_file="main.tex")
```

A directory is scanned recursively. Hidden and version-control paths, common
binary formats, non-UTF-8 files, and files larger than 20 MB are skipped. The
main TeX document is selected automatically unless `main_file` is supplied.
Nested `\input` and `\include` files and referenced local style macros are
expanded before conversion.

Both functions return `str`. Titles and abstracts come only from LaTeX source;
documents without a title use `# Untitled`. The `\today` command is preserved
literally, so repeated conversion is deterministic.

## Command line

```bash
tex2markdown paper.tex
tex2markdown paper.tex -o paper.md
tex2markdown project/ --main-file main.tex
cat paper.tex | tex2markdown -
```

Markdown is written to standard output unless `-o` is supplied. Standard input
and individual files do not accept `--main-file`.

## Errors

Conversion failures derive from `tex2markdown.ConversionError`. More specific
types are available for invalid filesystem input, unsupported formats, and main
source selection: `InputError`, `UnsupportedFormatError`, and
`SourceSelectionError`.

## Development

```bash
uv sync
uv run pytest
uv run ruff check .
uv build
```

## License

Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
