Metadata-Version: 2.3
Name: text2markdown
Version: 0.1.3
Summary: A Python library for intelligently converting text into Markdown.
Author: Isaacus
Author-email: Isaacus <support@isaacus.com>
Requires-Dist: isaacus
Requires-Python: >=3.10
Project-URL: Homepage, https://docs.isaacus.com/text2markdown
Project-URL: Documentation, https://github.com/isaacus-dev/text2markdown/blob/main/README.md
Project-URL: Issues, https://github.com/isaacus-dev/text2markdown/issues
Project-URL: Source, https://github.com/isaacus-dev/text2markdown
Description-Content-Type: text/markdown

# text2markdown 📝
**text2markdown** is a Python library for intelligently converting plain text into Markdown.

text2markdown is powered by the [Isaacus enrichment API](https://docs.isaacus.com/capabilities/enrichment), which converts unstructured documents into rich, highly structured knowledge graphs that can easily be transformed into Markdown.

In all, text2markdown is capable of:
- Identifying and formatting headings.
- Segmenting text into nested sections.
- Hyperlinking cross-references within texts to other sections.
- Italicizing cited documents.
- Italicizing defined terms. 
- Detecting and formatting block quotations.
- Striking through junk text.

## Setup 📦
text2markdown can be installed with `pip` (or `uv`):
```bash
pip install text2markdown
```

An [Isaacus API key](https://platform.isaacus.com/accounts/signup) is also required to use this library.

## Usage 👩‍💻
The code snippet below demonstrates how you might use `text2markdown()` to intelligently convert a short document into Markdown.
```python
from text2markdown import text2markdown

text = """\
The Smallest Document In The World
This is a generic document.

Section 1 - Background
One upon a time, there was a mayor who said:
We love Markdown so much that everyone should and must use it for everything.

Section 2 - Problem
The mayor's directive, as stated in Section 1, was sadly too difficult to enforce."""

output = text2markdown(text)
print(output)
```

The output should look something like this:
```markdown
# The Smallest Document In The World 

This is a generic document. 

## <a id="seg-1"></a>Section 1 - Background 

One upon a time, there was a mayor who said: 

> We love Markdown so much that everyone should and must use it for everything. 

## Section 2 - Problem 

The mayor's directive, as stated in [Section 1](#seg-1), was sadly too difficult to enforce.
```

An asynchronous version of `text2markdown()` is also available, supporting all of the same features and arguments as its synchronous equivalent. It can be used like so:
```python
from text2markdown import text2markdown_async

output = await text2markdown_async(text)
print(output)
```

All of the various capabilities of text2markdown can be toggled on or off using optional Boolean parameters, as shown below:
```python
from text2markdown import text2markdown

from isaacus import Isaacus

output = text2markdown(
    text,
    link_xrefs=True,
    strike_junk=True,
    block_quotes=True,
    escape_lists=True,
    italicize_refs=True,
    italicize_terms=True,
    enrichment_model="kanon-2-enricher",
    isaacus_client=Isaacus(),
)
print(output)
```

## License 📜
This library is licensed under the [MIT License](https://github.com/isaacus-dev/text2markdown/blob/main/LICENCE).
