Metadata-Version: 2.4
Name: text-region-parser
Version: 0.1.1
Summary: Parse regions in your Markdown/text files!
Author-email: Jag_k <30597878+jag-k@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2024 Jag_k
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENCE
Keywords: files,generation,markdown,parser,parsing,text,tools,txt,utils
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Documentation
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Requires-Dist: typing-extensions; python_version < '3.10'
Description-Content-Type: text/markdown

# text-region-parser

*Parse regions in your Markdown/text files!*

[![PyPI - Project version](https://img.shields.io/pypi/v/text-region-parser?logo=pypi)](https://pypi.org/p/text-region-parser/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/pydantic-settings-export)](https://pypi.org/p/text-region-parser/)
[![Pepy - Total Downloads](https://img.shields.io/pepy/dt/text-region-parser)](https://pypi.org/p/text-region-parser/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/text-region-parser)](https://pypi.org/p/text-region-parser/)
[![PyPI - License](https://img.shields.io/pypi/l/text-region-parser)](https://github.com/jag-k/text-region-parser/blob/main/LICENCE)


You can dynamically parse and update regions in your Markdown/text files like this:

```makrdown
Description of the project

<!-- region:name argument=value -->
This is a region with autogenerated content
<!-- endregion:name -->

End of the file
```

## Installation

```bash
pip install text-region-parser
# or
uv add text-region-parser
# or
poetry add text-region-parser
```

# Usage

```python
from pathlib import Path
from typing import TypedDict

from text_region_parser import RegionConstructor


class ScopeOptions(TypedDict):
    name: str
    level: str


constructor = RegionConstructor()

@constructor.add_parser("scope", options_type=ScopeOptions)
def create_scope_content(options: ScopeOptions) -> str:
    """Create region `scope` with options."""
    return f"Scope: {options['name']} with level {options['level']}"


# Parse the content.
file_path = Path("README.md")
constructor.update_files_data(file_path)
print(file_path.read_text())
```

## License

[MIT](https://github.com/jag-k/pydantic-settings-export/blob/main/LICENCE)
