Metadata-Version: 2.4
Name: pytexmd
Version: 1.1
Summary: Translate LaTeX documents to Markdown/MyST and HTML, with CLI and Sphinx integration.
Author: Martin Pflaum
Author-email: Martin Pflaum <contact@martinpflaum.com>
Project-URL: Homepage, https://github.com/yourusername/pytexmd
Project-URL: Repository, https://github.com/yourusername/pytexmd
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.14
Description-Content-Type: text/markdown
Requires-Dist: sphinx
Requires-Dist: myst-parser
Requires-Dist: sphinx-proof
Requires-Dist: furo
Requires-Dist: regex
Dynamic: author
Dynamic: requires-python

# PyTeXmd

Pytexmd is a Python package designed to translate LaTeX documents to Markdown MyST and HTML. It provides utilities for filtering content, loading files, and integrating with Sphinx documentation. 

## Documentation

- **Full Documentation**: [pytexmd.readthedocs.io](https://pytexmd.readthedocs.io/en/latest/index.html)
- **GitHub Repository**: [github.com/martinpflaum/pytexmd](https://github.com/martinpflaum/pytexmd)

## Installation

To install the required dependencies for pytexmd, run:

```bash
pip install -r requirements.txt
```

you also need texlive https://www.tug.org/texlive/ and ghostscript https://ghostscript.com/releases/gsdnld.html

## Python Usage Example

If you want to use pytexmd from a Python script, make sure your script is in the same folder (or a subfolder) as the pytexmd package, or add pytexmd to your Python path. The following example can also be found in the examples folder:

```project = 'My Project'
copyright = '2025, Author'
author = 'Author'
release = '1.0'

extensions = ['myst_parser',
              "sphinx_proof"]

templates_path = ['_templates']
exclude_patterns = []



mathjax3_config = {
    "tex": {
        "macros": {
            "ltortoise": "\\unicode{x3014}",
            "rtortoise": "\\unicode{x3015}",
            "ltsbrak": ["\\mathopen{\\ltortoise\\mspace{1mu}}", 0],
            "rtsbrak": ["\\mathopen{\\mspace{1mu}\\rtortoise}", 0],
            "mathbbm": ["\\mathbb{#1}", 1],
            "widebar": ["\\overline{#1}", 1],
            "C": "\\mathbb{C}",
        }
    }
}

myst_enable_extensions = [
    "amsmath",
    "attrs_inline",
    "attrs_block",
    "colon_fence",
    "deflist",
    "dollarmath",
    "fieldlist",
    "html_admonition",
    "html_image",
    "replacements",
    "smartquotes",
    "strikethrough",
    "substitution",
    "tasklist",
]


prf_realtyp_to_countertyp = {
    "axiom": "theorem",
    "theorem": "theorem",
    "lemma": "theorem",
    "algorithm": "theorem",
    "definition": "theorem",
    "remark": "theorem",
    "conjecture": "theorem",
    "corollary": "theorem",
    "criterion": "theorem",
    "example": "theorem",
    "property": "theorem",
    "observation": "theorem",
    "proposition": "theorem",
    "assumption": "theorem",
    "notation": "theorem",
}

#math_number_all = True             # number *all* displayed equations
math_eqref_format = "({number})"   # how equation refs look

html_theme = 'furo'
html_static_path = ['_static']


#math_number_all = True             # number *all* displayed equations
math_eqref_format = "({number})"   # how equation refs look
numfig = True                      # enable section-prefixed numbering
math_numfig = True                 # apply section prefix to equations
numfig_secnum_depth = 2            # use # and ## levels (e.g. 1.2.3)

html_theme = 'furo'
html_static_path = ['_static']
# Custom theorem types (auto-generated by pytexmd)
import sphinx_proof.nodes
import sphinx_proof.proof_type
import sphinx_proof.directive
import sphinx_proof.domain
from docutils import nodes
from sphinx_proof.directive import ElementDirective

class theorem_and_definition_node(nodes.Admonition, nodes.Element):
    pass

class TheoremAndDefinitionDirective(ElementDirective):
    name = "theorem_and_definition"

class proposition_and_definition_node(nodes.Admonition, nodes.Element):
    pass

class PropositionAndDefinitionDirective(ElementDirective):
    name = "proposition_and_definition"

_CUSTOM_TYPES = {
    "theorem_and_definition": (theorem_and_definition_node, TheoremAndDefinitionDirective),
    "proposition_and_definition": (proposition_and_definition_node, PropositionAndDefinitionDirective),
}

for _name, (_node_cls, _directive_cls) in _CUSTOM_TYPES.items():
    sphinx_proof.nodes.NODE_TYPES[_name] = _node_cls
    sphinx_proof.proof_type.PROOF_TYPES[_name] = _directive_cls
    sphinx_proof.directive.DEFAULT_REALTYP_TO_COUNTERTYP[_name] = _name
    sphinx_proof.domain.ProofDomain.directives[_name] = _directive_cls
    prf_realtyp_to_countertyp[_name] = "theorem"

# Monkey-patch the 4 realtyp.title() calls in sphinx_proof.nodes so that
# underscored names like 'theorem_and_definition' render as
# 'Theorem And Definition' instead of 'Theorem_And_Definition'.
import sphinx_proof.nodes as _spn
import sphinx_proof as _sp
from sphinx.writers.latex import LaTeXTranslator as _LaTeXTranslator

def _depart_enumerable_node(self, node):
    countertyp = node.attributes.get("countertype", "")
    realtyp = node.attributes.get("realtype", "")
    display = realtyp.replace("_", " ").title()
    if isinstance(self, _LaTeXTranslator):
        number = _spn.get_node_number(self, node, countertyp)
        idx = _spn.list_rindex(self.body, _spn.latex_admonition_start) + 2
        self.body.insert(idx, f"{display} {number}")
        self.body.append(_spn.latex_admonition_end)
    else:
        number = _spn.get_node_number(self, node, countertyp)
        idx = self.body.index(f"{countertyp} {number} ")
        self.body[idx] = f"{_spn._(display)} {number} "
        self.body.append("</div>")

def _depart_unenumerable_node(self, node):
    realtyp = node.attributes.get("realtype", "")
    display = realtyp.replace("_", " ").title()
    node_id = node.attributes.get("ids", [""])[0]
    if isinstance(self, _LaTeXTranslator):
        idx = _spn.list_rindex(self.body, _spn.latex_admonition_start) + 2
        self.body.insert(idx, display)
        self.body.append(_spn.latex_admonition_end)
    else:
        search_str = f'<p class="admonition-title" id="{node_id}">'
        idx = _spn.list_rindex(self.body, search_str) + 1
        element = f'<span class="caption-number">{_spn._(display)} </span>'
        self.body.insert(idx, element)
        self.body.append("</div>")

# Patch both the nodes module AND sphinx_proof's __init__ namespace.
# sphinx_proof/__init__.py does `from .nodes import depart_enumerable_node`
# which binds the name in its own globals. Sphinx's setup() looks up the name
# there, so patching only sphinx_proof.nodes has no effect.
_spn.depart_enumerable_node = _depart_enumerable_node
_spn.depart_unenumerable_node = _depart_unenumerable_node
_sp.depart_enumerable_node = _depart_enumerable_node
_sp.depart_unenumerable_node = _depart_unenumerable_node

numfig_format = {
    "theorem_and_definition": "Theorem and Definition %s",
    "proposition_and_definition": "Proposition and Definition %s",
}
```


also in the file loader make sure that all .bib files are found also in folder mentioned in the \input thingies than concatenate these .bib file but eliminate duplicated entries also copy this thing to the created sphinx project also use of sphinxcontrib-bibtex
