all2md 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- all2md/__init__.py +303 -0
- all2md/__main__.py +13 -0
- all2md/_plaintext-exts.json +199 -0
- all2md/api.py +1095 -0
- all2md/ast/__init__.py +218 -0
- all2md/ast/builder.py +674 -0
- all2md/ast/nodes.py +2147 -0
- all2md/ast/sections.py +1095 -0
- all2md/ast/serialization.py +1018 -0
- all2md/ast/splitting.py +802 -0
- all2md/ast/transforms.py +1574 -0
- all2md/ast/utils.py +169 -0
- all2md/ast/visitors.py +1163 -0
- all2md/cli/__init__.py +320 -0
- all2md/cli/builder.py +2347 -0
- all2md/cli/commands/__init__.py +141 -0
- all2md/cli/commands/completion.py +479 -0
- all2md/cli/commands/config.py +505 -0
- all2md/cli/commands/diff.py +273 -0
- all2md/cli/commands/formats.py +500 -0
- all2md/cli/commands/generate_site.py +178 -0
- all2md/cli/commands/help.py +52 -0
- all2md/cli/commands/search.py +963 -0
- all2md/cli/commands/server.py +877 -0
- all2md/cli/commands/shared.py +542 -0
- all2md/cli/commands/themes/dark.html +210 -0
- all2md/cli/commands/themes/docs.html +283 -0
- all2md/cli/commands/themes/minimal.html +173 -0
- all2md/cli/commands/themes/newspaper.html +236 -0
- all2md/cli/commands/themes/sidebar.html +301 -0
- all2md/cli/commands/transforms.py +166 -0
- all2md/cli/commands/view.py +201 -0
- all2md/cli/config.py +484 -0
- all2md/cli/custom_actions.py +673 -0
- all2md/cli/help_formatter.py +825 -0
- all2md/cli/input_items.py +124 -0
- all2md/cli/output.py +84 -0
- all2md/cli/packaging.py +138 -0
- all2md/cli/presets.py +281 -0
- all2md/cli/processors.py +2902 -0
- all2md/cli/progress.py +317 -0
- all2md/cli/timing.py +308 -0
- all2md/cli/validation.py +187 -0
- all2md/cli/watch.py +362 -0
- all2md/constants.py +1270 -0
- all2md/converter_metadata.py +319 -0
- all2md/converter_registry.py +949 -0
- all2md/dependencies.py +729 -0
- all2md/diff/__init__.py +43 -0
- all2md/diff/renderers/__init__.py +41 -0
- all2md/diff/renderers/html.py +442 -0
- all2md/diff/renderers/json.py +200 -0
- all2md/diff/renderers/unified.py +113 -0
- all2md/diff/text_diff.py +565 -0
- all2md/exceptions.py +628 -0
- all2md/logging_utils.py +57 -0
- all2md/mcp/__init__.py +41 -0
- all2md/mcp/__main__.py +17 -0
- all2md/mcp/config.py +479 -0
- all2md/mcp/document_tools.py +431 -0
- all2md/mcp/schemas.py +211 -0
- all2md/mcp/security.py +347 -0
- all2md/mcp/server.py +316 -0
- all2md/mcp/tools.py +375 -0
- all2md/options/__init__.py +131 -0
- all2md/options/archive.py +169 -0
- all2md/options/asciidoc.py +240 -0
- all2md/options/ast_json.py +92 -0
- all2md/options/base.py +162 -0
- all2md/options/bbcode.py +116 -0
- all2md/options/chm.py +62 -0
- all2md/options/common.py +697 -0
- all2md/options/csv.py +329 -0
- all2md/options/docx.py +237 -0
- all2md/options/dokuwiki.py +188 -0
- all2md/options/eml.py +203 -0
- all2md/options/enex.py +183 -0
- all2md/options/epub.py +169 -0
- all2md/options/fb2.py +60 -0
- all2md/options/html.py +541 -0
- all2md/options/ini.py +108 -0
- all2md/options/ipynb.py +276 -0
- all2md/options/jinja.py +284 -0
- all2md/options/json.py +163 -0
- all2md/options/latex.py +206 -0
- all2md/options/markdown.py +701 -0
- all2md/options/mbox.py +132 -0
- all2md/options/mediawiki.py +195 -0
- all2md/options/mhtml.py +31 -0
- all2md/options/odp.py +209 -0
- all2md/options/ods.py +43 -0
- all2md/options/odt.py +183 -0
- all2md/options/openapi.py +156 -0
- all2md/options/org.py +246 -0
- all2md/options/outlook.py +150 -0
- all2md/options/pdf.py +695 -0
- all2md/options/plaintext.py +137 -0
- all2md/options/pptx.py +389 -0
- all2md/options/rst.py +218 -0
- all2md/options/rtf.py +86 -0
- all2md/options/search.py +200 -0
- all2md/options/sourcecode.py +69 -0
- all2md/options/textile.py +145 -0
- all2md/options/toml.py +147 -0
- all2md/options/webarchive.py +75 -0
- all2md/options/xlsx.py +29 -0
- all2md/options/yaml.py +164 -0
- all2md/options/zip.py +162 -0
- all2md/parsers/__init__.py +20 -0
- all2md/parsers/archive.py +1519 -0
- all2md/parsers/asciidoc.py +2003 -0
- all2md/parsers/ast_json.py +244 -0
- all2md/parsers/base.py +398 -0
- all2md/parsers/bbcode.py +1012 -0
- all2md/parsers/chm.py +470 -0
- all2md/parsers/csv.py +535 -0
- all2md/parsers/docx.py +1756 -0
- all2md/parsers/dokuwiki.py +1251 -0
- all2md/parsers/eml.py +1192 -0
- all2md/parsers/enex.py +674 -0
- all2md/parsers/epub.py +290 -0
- all2md/parsers/fb2.py +639 -0
- all2md/parsers/html.py +2286 -0
- all2md/parsers/ini.py +323 -0
- all2md/parsers/ipynb.py +752 -0
- all2md/parsers/json.py +554 -0
- all2md/parsers/latex.py +1061 -0
- all2md/parsers/markdown.py +1060 -0
- all2md/parsers/mbox.py +591 -0
- all2md/parsers/mediawiki.py +951 -0
- all2md/parsers/mhtml.py +242 -0
- all2md/parsers/odp.py +881 -0
- all2md/parsers/ods_spreadsheet.py +601 -0
- all2md/parsers/odt.py +659 -0
- all2md/parsers/openapi.py +972 -0
- all2md/parsers/org.py +1056 -0
- all2md/parsers/outlook.py +760 -0
- all2md/parsers/pdf.py +4116 -0
- all2md/parsers/plaintext.py +152 -0
- all2md/parsers/pptx.py +1561 -0
- all2md/parsers/rst.py +944 -0
- all2md/parsers/rtf.py +532 -0
- all2md/parsers/sourcecode.py +441 -0
- all2md/parsers/textile.py +210 -0
- all2md/parsers/toml.py +595 -0
- all2md/parsers/webarchive.py +396 -0
- all2md/parsers/xlsx.py +701 -0
- all2md/parsers/yaml.py +606 -0
- all2md/parsers/zip.py +954 -0
- all2md/progress.py +182 -0
- all2md/py.typed +0 -0
- all2md/renderers/__init__.py +72 -0
- all2md/renderers/_split_utils.py +236 -0
- all2md/renderers/asciidoc.py +1043 -0
- all2md/renderers/ast_json.py +114 -0
- all2md/renderers/base.py +332 -0
- all2md/renderers/csv.py +378 -0
- all2md/renderers/docx.py +1569 -0
- all2md/renderers/dokuwiki.py +845 -0
- all2md/renderers/epub.py +627 -0
- all2md/renderers/html.py +1366 -0
- all2md/renderers/ini.py +374 -0
- all2md/renderers/ipynb.py +515 -0
- all2md/renderers/jinja.py +707 -0
- all2md/renderers/json.py +482 -0
- all2md/renderers/latex.py +912 -0
- all2md/renderers/markdown.py +1665 -0
- all2md/renderers/mediawiki.py +797 -0
- all2md/renderers/odp.py +1304 -0
- all2md/renderers/odt.py +1445 -0
- all2md/renderers/org.py +1008 -0
- all2md/renderers/pdf.py +1264 -0
- all2md/renderers/plaintext.py +730 -0
- all2md/renderers/pptx.py +1365 -0
- all2md/renderers/rst.py +1032 -0
- all2md/renderers/rtf.py +581 -0
- all2md/renderers/textile.py +772 -0
- all2md/renderers/toml.py +492 -0
- all2md/renderers/yaml.py +490 -0
- all2md/search/__init__.py +62 -0
- all2md/search/bm25.py +147 -0
- all2md/search/chunking.py +194 -0
- all2md/search/hybrid.py +53 -0
- all2md/search/index.py +134 -0
- all2md/search/service.py +907 -0
- all2md/search/types.py +57 -0
- all2md/search/vector.py +243 -0
- all2md/transforms/__init__.py +149 -0
- all2md/transforms/_builtin_metadata.py +290 -0
- all2md/transforms/builtin.py +1421 -0
- all2md/transforms/hooks.py +553 -0
- all2md/transforms/metadata.py +566 -0
- all2md/transforms/options.py +285 -0
- all2md/transforms/pipeline.py +1253 -0
- all2md/transforms/registry.py +439 -0
- all2md/utils/__init__.py +27 -0
- all2md/utils/attachments.py +1158 -0
- all2md/utils/chart_helpers.py +136 -0
- all2md/utils/decorators.py +200 -0
- all2md/utils/encoding.py +358 -0
- all2md/utils/escape.py +465 -0
- all2md/utils/flavors.py +772 -0
- all2md/utils/footnotes.py +117 -0
- all2md/utils/html_sanitizer.py +808 -0
- all2md/utils/html_utils.py +86 -0
- all2md/utils/images.py +437 -0
- all2md/utils/input_sources.py +629 -0
- all2md/utils/inputs.py +528 -0
- all2md/utils/io_utils.py +140 -0
- all2md/utils/metadata.py +837 -0
- all2md/utils/network_security.py +709 -0
- all2md/utils/packages.py +66 -0
- all2md/utils/parser_helpers.py +593 -0
- all2md/utils/robots_txt.py +321 -0
- all2md/utils/security.py +1204 -0
- all2md/utils/spreadsheet.py +223 -0
- all2md/utils/static_site.py +765 -0
- all2md/utils/text.py +217 -0
- all2md-1.0.1.dist-info/METADATA +960 -0
- all2md-1.0.1.dist-info/RECORD +223 -0
- all2md-1.0.1.dist-info/WHEEL +4 -0
- all2md-1.0.1.dist-info/entry_points.txt +15 -0
- all2md-1.0.1.dist-info/licenses/LICENSE +21 -0
all2md/__init__.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"""all2md - A Python document conversion library for bidirectional transformation.
|
|
2
|
+
|
|
3
|
+
all2md provides a comprehensive solution for converting between various file formats
|
|
4
|
+
and Markdown. It supports PDF, Word (DOCX), PowerPoint (PPTX), HTML, email (EML),
|
|
5
|
+
Excel (XLSX), Jupyter Notebooks (IPYNB), EPUB e-books, images, and 200+ text file formats with
|
|
6
|
+
intelligent content extraction and formatting preservation.
|
|
7
|
+
|
|
8
|
+
The library uses a modular architecture where the main `to_markdown()` function
|
|
9
|
+
automatically detects file types and routes to appropriate specialized parsers.
|
|
10
|
+
Each converter module handles specific format requirements while maintaining
|
|
11
|
+
consistent Markdown output with support for tables, images, and complex formatting.
|
|
12
|
+
|
|
13
|
+
Key Features
|
|
14
|
+
------------
|
|
15
|
+
- Advanced PDF parsing with table detection using PyMuPDF
|
|
16
|
+
- Word document processing with formatting preservation
|
|
17
|
+
- PowerPoint slide-by-slide extraction
|
|
18
|
+
- HTML processing with configurable conversion options
|
|
19
|
+
- Email chain parsing with attachment handling
|
|
20
|
+
- Base64 image embedding support
|
|
21
|
+
- Support for 200+ plaintext file formats
|
|
22
|
+
- AST-based transformation pipeline for document manipulation
|
|
23
|
+
- Plugin system for custom transforms via entry points
|
|
24
|
+
|
|
25
|
+
Supported Formats
|
|
26
|
+
-----------------
|
|
27
|
+
- **Documents**: PDF, DOCX, PPTX, HTML, EML, EPUB
|
|
28
|
+
- **Notebooks**: IPYNB (Jupyter Notebooks)
|
|
29
|
+
- **Spreadsheets**: XLSX, CSV, TSV
|
|
30
|
+
- **Images**: PNG, JPEG, GIF (embedded as base64)
|
|
31
|
+
- **Text**: 200+ formats including code files, configs, markup
|
|
32
|
+
|
|
33
|
+
Requirements
|
|
34
|
+
------------
|
|
35
|
+
- Python 3.10+
|
|
36
|
+
- Optional dependencies loaded per format (PyMuPDF, python-docx, etc.)
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
Basic usage for file conversion:
|
|
41
|
+
|
|
42
|
+
>>> from all2md import to_markdown
|
|
43
|
+
>>> markdown_content = to_markdown('document.pdf')
|
|
44
|
+
>>> print(markdown_content)
|
|
45
|
+
|
|
46
|
+
Using AST transforms to manipulate documents:
|
|
47
|
+
|
|
48
|
+
>>> from all2md import to_markdown
|
|
49
|
+
>>> from all2md.transforms import RemoveImagesTransform, HeadingOffsetTransform
|
|
50
|
+
>>>
|
|
51
|
+
>>> # Apply transforms during conversion
|
|
52
|
+
>>> markdown = to_markdown(
|
|
53
|
+
... 'document.pdf',
|
|
54
|
+
... transforms=[
|
|
55
|
+
... RemoveImagesTransform(),
|
|
56
|
+
... HeadingOffsetTransform(offset=1)
|
|
57
|
+
... ]
|
|
58
|
+
... )
|
|
59
|
+
|
|
60
|
+
Working with the AST directly:
|
|
61
|
+
|
|
62
|
+
>>> from all2md import to_ast
|
|
63
|
+
>>> from all2md.transforms import render
|
|
64
|
+
>>>
|
|
65
|
+
>>> # Convert to AST
|
|
66
|
+
>>> doc = to_ast('document.pdf')
|
|
67
|
+
>>>
|
|
68
|
+
>>> # Apply transforms and render
|
|
69
|
+
>>> markdown = render(doc, transforms=['remove-images', 'heading-offset'])
|
|
70
|
+
|
|
71
|
+
See Also
|
|
72
|
+
--------
|
|
73
|
+
all2md.transforms : AST transformation system
|
|
74
|
+
all2md.ast : AST node definitions and utilities
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
# Copyright (c) 2025 Tom Villani, Ph.D.
|
|
79
|
+
|
|
80
|
+
# Check Python version before any imports
|
|
81
|
+
import sys
|
|
82
|
+
|
|
83
|
+
if sys.version_info < (3, 10):
|
|
84
|
+
raise ImportError(
|
|
85
|
+
"all2md requires Python 3.10 or later. "
|
|
86
|
+
f"You are using Python {sys.version_info.major}.{sys.version_info.minor}."
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
__version__ = "1.0.0"
|
|
90
|
+
|
|
91
|
+
from typing import TYPE_CHECKING, Any
|
|
92
|
+
|
|
93
|
+
if TYPE_CHECKING:
|
|
94
|
+
# Import heavy modules for type checking without runtime overhead
|
|
95
|
+
from all2md import ast, parsers, transforms # noqa: F401
|
|
96
|
+
from all2md.ast import Document # noqa: F401 - used in docstrings
|
|
97
|
+
|
|
98
|
+
# Import all option classes for type checking
|
|
99
|
+
from all2md.options.asciidoc import AsciiDocOptions, AsciiDocRendererOptions # noqa: F401
|
|
100
|
+
from all2md.options.chm import ChmOptions # noqa: F401
|
|
101
|
+
from all2md.options.csv import CsvOptions # noqa: F401
|
|
102
|
+
from all2md.options.docx import DocxOptions, DocxRendererOptions # noqa: F401
|
|
103
|
+
from all2md.options.eml import EmlOptions # noqa: F401
|
|
104
|
+
from all2md.options.epub import EpubOptions, EpubRendererOptions # noqa: F401
|
|
105
|
+
from all2md.options.html import HtmlOptions, HtmlRendererOptions # noqa: F401
|
|
106
|
+
from all2md.options.ipynb import IpynbOptions, IpynbRendererOptions # noqa: F401
|
|
107
|
+
from all2md.options.latex import LatexOptions, LatexRendererOptions # noqa: F401
|
|
108
|
+
from all2md.options.markdown import MarkdownParserOptions, MarkdownRendererOptions # noqa: F401
|
|
109
|
+
from all2md.options.mediawiki import MediaWikiOptions # noqa: F401
|
|
110
|
+
from all2md.options.mhtml import MhtmlOptions # noqa: F401
|
|
111
|
+
from all2md.options.odp import OdpOptions # noqa: F401
|
|
112
|
+
from all2md.options.ods import OdsSpreadsheetOptions # noqa: F401
|
|
113
|
+
from all2md.options.odt import OdtOptions # noqa: F401
|
|
114
|
+
from all2md.options.pdf import PdfOptions, PdfRendererOptions # noqa: F401
|
|
115
|
+
from all2md.options.plaintext import PlainTextOptions # noqa: F401
|
|
116
|
+
from all2md.options.pptx import PptxOptions, PptxRendererOptions # noqa: F401
|
|
117
|
+
from all2md.options.rst import RstParserOptions, RstRendererOptions # noqa: F401
|
|
118
|
+
from all2md.options.rtf import RtfOptions # noqa: F401
|
|
119
|
+
from all2md.options.sourcecode import SourceCodeOptions # noqa: F401
|
|
120
|
+
from all2md.options.xlsx import XlsxOptions # noqa: F401
|
|
121
|
+
from all2md.options.zip import ZipOptions # noqa: F401
|
|
122
|
+
from all2md.utils.input_sources import RemoteInputOptions # noqa: F401
|
|
123
|
+
|
|
124
|
+
from all2md.api import (
|
|
125
|
+
convert,
|
|
126
|
+
from_ast,
|
|
127
|
+
from_markdown,
|
|
128
|
+
to_ast,
|
|
129
|
+
to_markdown,
|
|
130
|
+
)
|
|
131
|
+
from all2md.constants import DocumentFormat
|
|
132
|
+
|
|
133
|
+
# Extensions lists moved to constants.py - keep references for backward compatibility
|
|
134
|
+
from all2md.converter_registry import registry
|
|
135
|
+
from all2md.exceptions import All2MdError, DependencyError, FormatError, ParsingError
|
|
136
|
+
|
|
137
|
+
# Keep only base and common option classes that are lightweight and frequently used
|
|
138
|
+
from all2md.options.base import BaseParserOptions, BaseRendererOptions
|
|
139
|
+
from all2md.options.common import LocalFileAccessOptions, NetworkFetchOptions
|
|
140
|
+
from all2md.progress import ProgressCallback, ProgressEvent
|
|
141
|
+
|
|
142
|
+
# Import parsers to trigger registration (must be eager, not lazy)
|
|
143
|
+
from . import parsers # noqa: F401
|
|
144
|
+
|
|
145
|
+
# Lazy loading for heavy modules - only imported when accessed
|
|
146
|
+
# This significantly improves CLI startup time by deferring AST and transforms
|
|
147
|
+
# Note: parsers must be imported eagerly to trigger auto-discovery
|
|
148
|
+
_lazy_modules = {
|
|
149
|
+
"ast": "all2md.ast",
|
|
150
|
+
"transforms": "all2md.transforms",
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Lazy loading for option classes - maps class name to (module_path, class_name)
|
|
154
|
+
_lazy_options = {
|
|
155
|
+
"AsciiDocOptions": ("all2md.options.asciidoc", "AsciiDocOptions"),
|
|
156
|
+
"AsciiDocRendererOptions": ("all2md.options.asciidoc", "AsciiDocRendererOptions"),
|
|
157
|
+
"ChmOptions": ("all2md.options.chm", "ChmOptions"),
|
|
158
|
+
"CsvOptions": ("all2md.options.csv", "CsvOptions"),
|
|
159
|
+
"DocxOptions": ("all2md.options.docx", "DocxOptions"),
|
|
160
|
+
"DocxRendererOptions": ("all2md.options.docx", "DocxRendererOptions"),
|
|
161
|
+
"EmlOptions": ("all2md.options.eml", "EmlOptions"),
|
|
162
|
+
"EpubOptions": ("all2md.options.epub", "EpubOptions"),
|
|
163
|
+
"EpubRendererOptions": ("all2md.options.epub", "EpubRendererOptions"),
|
|
164
|
+
"HtmlOptions": ("all2md.options.html", "HtmlOptions"),
|
|
165
|
+
"HtmlRendererOptions": ("all2md.options.html", "HtmlRendererOptions"),
|
|
166
|
+
"IpynbOptions": ("all2md.options.ipynb", "IpynbOptions"),
|
|
167
|
+
"IpynbRendererOptions": ("all2md.options.ipynb", "IpynbRendererOptions"),
|
|
168
|
+
"LatexOptions": ("all2md.options.latex", "LatexOptions"),
|
|
169
|
+
"LatexRendererOptions": ("all2md.options.latex", "LatexRendererOptions"),
|
|
170
|
+
"MarkdownParserOptions": ("all2md.options.markdown", "MarkdownParserOptions"),
|
|
171
|
+
"MarkdownRendererOptions": ("all2md.options.markdown", "MarkdownRendererOptions"),
|
|
172
|
+
"MediaWikiOptions": ("all2md.options.mediawiki", "MediaWikiOptions"),
|
|
173
|
+
"MhtmlOptions": ("all2md.options.mhtml", "MhtmlOptions"),
|
|
174
|
+
"OdpOptions": ("all2md.options.odp", "OdpOptions"),
|
|
175
|
+
"OdsSpreadsheetOptions": ("all2md.options.ods", "OdsSpreadsheetOptions"),
|
|
176
|
+
"OdtOptions": ("all2md.options.odt", "OdtOptions"),
|
|
177
|
+
"PdfOptions": ("all2md.options.pdf", "PdfOptions"),
|
|
178
|
+
"PdfRendererOptions": ("all2md.options.pdf", "PdfRendererOptions"),
|
|
179
|
+
"PlainTextOptions": ("all2md.options.plaintext", "PlainTextOptions"),
|
|
180
|
+
"PptxOptions": ("all2md.options.pptx", "PptxOptions"),
|
|
181
|
+
"PptxRendererOptions": ("all2md.options.pptx", "PptxRendererOptions"),
|
|
182
|
+
"RstParserOptions": ("all2md.options.rst", "RstParserOptions"),
|
|
183
|
+
"RstRendererOptions": ("all2md.options.rst", "RstRendererOptions"),
|
|
184
|
+
"RtfOptions": ("all2md.options.rtf", "RtfOptions"),
|
|
185
|
+
"SourceCodeOptions": ("all2md.options.sourcecode", "SourceCodeOptions"),
|
|
186
|
+
"XlsxOptions": ("all2md.options.xlsx", "XlsxOptions"),
|
|
187
|
+
"ZipOptions": ("all2md.options.zip", "ZipOptions"),
|
|
188
|
+
"RemoteInputOptions": ("all2md.utils.input_sources", "RemoteInputOptions"),
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# Options handling helpers
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
__all__ = [
|
|
195
|
+
"__version__",
|
|
196
|
+
"to_markdown",
|
|
197
|
+
"to_ast",
|
|
198
|
+
"from_ast",
|
|
199
|
+
"from_markdown",
|
|
200
|
+
"convert",
|
|
201
|
+
# Registry system
|
|
202
|
+
"registry",
|
|
203
|
+
# Type definitions
|
|
204
|
+
"DocumentFormat",
|
|
205
|
+
# Progress system
|
|
206
|
+
"ProgressCallback",
|
|
207
|
+
"ProgressEvent",
|
|
208
|
+
# Re-exported classes and exceptions for public API
|
|
209
|
+
"BaseRendererOptions",
|
|
210
|
+
"BaseParserOptions",
|
|
211
|
+
"NetworkFetchOptions",
|
|
212
|
+
"LocalFileAccessOptions",
|
|
213
|
+
"AsciiDocRendererOptions",
|
|
214
|
+
"AsciiDocOptions",
|
|
215
|
+
"ChmOptions",
|
|
216
|
+
"CsvOptions",
|
|
217
|
+
"DocxOptions",
|
|
218
|
+
"DocxRendererOptions",
|
|
219
|
+
"EmlOptions",
|
|
220
|
+
"EpubOptions",
|
|
221
|
+
"EpubRendererOptions",
|
|
222
|
+
"HtmlRendererOptions",
|
|
223
|
+
"HtmlOptions",
|
|
224
|
+
"IpynbOptions",
|
|
225
|
+
"IpynbRendererOptions",
|
|
226
|
+
"LatexRendererOptions",
|
|
227
|
+
"LatexOptions",
|
|
228
|
+
"MarkdownRendererOptions",
|
|
229
|
+
"MarkdownParserOptions",
|
|
230
|
+
"MediaWikiOptions",
|
|
231
|
+
"MhtmlOptions",
|
|
232
|
+
"OdpOptions",
|
|
233
|
+
"OdsSpreadsheetOptions",
|
|
234
|
+
"OdtOptions",
|
|
235
|
+
"PdfOptions",
|
|
236
|
+
"PdfRendererOptions",
|
|
237
|
+
"PptxOptions",
|
|
238
|
+
"PptxRendererOptions",
|
|
239
|
+
"RstParserOptions",
|
|
240
|
+
"RstRendererOptions",
|
|
241
|
+
"RtfOptions",
|
|
242
|
+
"SourceCodeOptions",
|
|
243
|
+
"PlainTextOptions",
|
|
244
|
+
"XlsxOptions",
|
|
245
|
+
"ZipOptions",
|
|
246
|
+
"RemoteInputOptions",
|
|
247
|
+
# Exceptions
|
|
248
|
+
"DependencyError",
|
|
249
|
+
"All2MdError",
|
|
250
|
+
"FormatError",
|
|
251
|
+
"ParsingError",
|
|
252
|
+
# AST module (for advanced users)
|
|
253
|
+
"ast",
|
|
254
|
+
# Transforms module (for AST transformations)
|
|
255
|
+
"transforms",
|
|
256
|
+
]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def __getattr__(name: str) -> Any:
|
|
260
|
+
"""Lazy load heavy modules and option classes on first access.
|
|
261
|
+
|
|
262
|
+
This function is called when an attribute is not found in the module namespace.
|
|
263
|
+
It allows us to defer importing heavy modules (ast, parsers, transforms) and
|
|
264
|
+
option classes until they are actually accessed, significantly improving CLI
|
|
265
|
+
startup time.
|
|
266
|
+
|
|
267
|
+
Parameters
|
|
268
|
+
----------
|
|
269
|
+
name : str
|
|
270
|
+
The name of the attribute being accessed
|
|
271
|
+
|
|
272
|
+
Returns
|
|
273
|
+
-------
|
|
274
|
+
Any
|
|
275
|
+
The requested module, class, or attribute
|
|
276
|
+
|
|
277
|
+
Raises
|
|
278
|
+
------
|
|
279
|
+
AttributeError
|
|
280
|
+
If the attribute is not found and is not a lazy-loadable item
|
|
281
|
+
|
|
282
|
+
"""
|
|
283
|
+
import importlib
|
|
284
|
+
|
|
285
|
+
# Check if it's a lazy-loaded module
|
|
286
|
+
if name in _lazy_modules:
|
|
287
|
+
# nosemgrep: python.lang.security.audit.non-literal-import.non-literal-import
|
|
288
|
+
module = importlib.import_module(_lazy_modules[name])
|
|
289
|
+
# Cache the module in this module's namespace for faster future access
|
|
290
|
+
globals()[name] = module
|
|
291
|
+
return module
|
|
292
|
+
|
|
293
|
+
# Check if it's a lazy-loaded option class
|
|
294
|
+
if name in _lazy_options:
|
|
295
|
+
module_path, class_name = _lazy_options[name]
|
|
296
|
+
# nosemgrep: python.lang.security.audit.non-literal-import.non-literal-import
|
|
297
|
+
module = importlib.import_module(module_path)
|
|
298
|
+
cls = getattr(module, class_name)
|
|
299
|
+
# Cache the class in this module's namespace for faster future access
|
|
300
|
+
globals()[name] = cls
|
|
301
|
+
return cls
|
|
302
|
+
|
|
303
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
all2md/__main__.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
[
|
|
2
|
+
".adoc",
|
|
3
|
+
".asciidoc",
|
|
4
|
+
".asm",
|
|
5
|
+
".asp",
|
|
6
|
+
".aspx",
|
|
7
|
+
".atom",
|
|
8
|
+
".awk",
|
|
9
|
+
".babelrc",
|
|
10
|
+
".bash",
|
|
11
|
+
".bat",
|
|
12
|
+
".bazel",
|
|
13
|
+
".bib",
|
|
14
|
+
".bzl",
|
|
15
|
+
".c",
|
|
16
|
+
".cfg",
|
|
17
|
+
".cjs",
|
|
18
|
+
".clj",
|
|
19
|
+
".cmake",
|
|
20
|
+
".cmd",
|
|
21
|
+
".coffee",
|
|
22
|
+
".conf",
|
|
23
|
+
".config",
|
|
24
|
+
".cpp",
|
|
25
|
+
".cs",
|
|
26
|
+
".csh",
|
|
27
|
+
".cshtml",
|
|
28
|
+
".cson",
|
|
29
|
+
".css",
|
|
30
|
+
".csv",
|
|
31
|
+
".cypher",
|
|
32
|
+
".d",
|
|
33
|
+
".dart",
|
|
34
|
+
".desktop",
|
|
35
|
+
".diff",
|
|
36
|
+
".dockerfile",
|
|
37
|
+
".dtd",
|
|
38
|
+
".editorconfig",
|
|
39
|
+
".ejs",
|
|
40
|
+
".el",
|
|
41
|
+
".elm",
|
|
42
|
+
".env",
|
|
43
|
+
".erb",
|
|
44
|
+
".erl",
|
|
45
|
+
".eslintignore",
|
|
46
|
+
".eslintrc",
|
|
47
|
+
".ex",
|
|
48
|
+
".exs",
|
|
49
|
+
".f",
|
|
50
|
+
".f90",
|
|
51
|
+
".f95",
|
|
52
|
+
".fish",
|
|
53
|
+
".for",
|
|
54
|
+
".fs",
|
|
55
|
+
".gemspec",
|
|
56
|
+
".geojson",
|
|
57
|
+
".gitattributes",
|
|
58
|
+
".gitignore",
|
|
59
|
+
".gn",
|
|
60
|
+
".go",
|
|
61
|
+
".gql",
|
|
62
|
+
".gradle",
|
|
63
|
+
".graphql",
|
|
64
|
+
".graphqlrc",
|
|
65
|
+
".groovy",
|
|
66
|
+
".gyp",
|
|
67
|
+
".h",
|
|
68
|
+
".haml",
|
|
69
|
+
".hbs",
|
|
70
|
+
".hcl",
|
|
71
|
+
".hjson",
|
|
72
|
+
".hpp",
|
|
73
|
+
".hrl",
|
|
74
|
+
".hs",
|
|
75
|
+
".htaccess",
|
|
76
|
+
".htm",
|
|
77
|
+
".html",
|
|
78
|
+
".htpasswd",
|
|
79
|
+
".ics",
|
|
80
|
+
".iml",
|
|
81
|
+
".inf",
|
|
82
|
+
".ini",
|
|
83
|
+
".ipynb",
|
|
84
|
+
".jade",
|
|
85
|
+
".java",
|
|
86
|
+
".jbuilder",
|
|
87
|
+
".jenkinsfile",
|
|
88
|
+
".jl",
|
|
89
|
+
".js",
|
|
90
|
+
".json5",
|
|
91
|
+
".jsonld",
|
|
92
|
+
".jsx",
|
|
93
|
+
".ksh",
|
|
94
|
+
".kt",
|
|
95
|
+
".kts",
|
|
96
|
+
".less",
|
|
97
|
+
".liquid",
|
|
98
|
+
".lisp",
|
|
99
|
+
".log",
|
|
100
|
+
".lua",
|
|
101
|
+
".m",
|
|
102
|
+
".mak",
|
|
103
|
+
".make",
|
|
104
|
+
".markdown",
|
|
105
|
+
".md",
|
|
106
|
+
".mdown",
|
|
107
|
+
".mdwn",
|
|
108
|
+
".mdx",
|
|
109
|
+
".mediawiki",
|
|
110
|
+
".mjs",
|
|
111
|
+
".mkd",
|
|
112
|
+
".mkdn",
|
|
113
|
+
".mm",
|
|
114
|
+
".mustache",
|
|
115
|
+
".nfo",
|
|
116
|
+
".nginx",
|
|
117
|
+
".nim",
|
|
118
|
+
".npmrc",
|
|
119
|
+
".nsi",
|
|
120
|
+
".nt",
|
|
121
|
+
".opml",
|
|
122
|
+
".org",
|
|
123
|
+
".p",
|
|
124
|
+
".pas",
|
|
125
|
+
".patch",
|
|
126
|
+
".php",
|
|
127
|
+
".pl",
|
|
128
|
+
".plist",
|
|
129
|
+
".pod",
|
|
130
|
+
".podspec",
|
|
131
|
+
".pp",
|
|
132
|
+
".prettierignore",
|
|
133
|
+
".prisma",
|
|
134
|
+
".pro",
|
|
135
|
+
".properties",
|
|
136
|
+
".proto",
|
|
137
|
+
".ps1",
|
|
138
|
+
".pug",
|
|
139
|
+
".py",
|
|
140
|
+
".pyx",
|
|
141
|
+
".r",
|
|
142
|
+
".rake",
|
|
143
|
+
".rb",
|
|
144
|
+
".rdoc",
|
|
145
|
+
".reg",
|
|
146
|
+
".rhtml",
|
|
147
|
+
".robots",
|
|
148
|
+
".rs",
|
|
149
|
+
".rss",
|
|
150
|
+
".rst",
|
|
151
|
+
".sas",
|
|
152
|
+
".sass",
|
|
153
|
+
".sbt",
|
|
154
|
+
".scala",
|
|
155
|
+
".scm",
|
|
156
|
+
".scss",
|
|
157
|
+
".sed",
|
|
158
|
+
".sgml",
|
|
159
|
+
".sh",
|
|
160
|
+
".shtml",
|
|
161
|
+
".sitemap",
|
|
162
|
+
".sql",
|
|
163
|
+
".styl",
|
|
164
|
+
".stylelintrc",
|
|
165
|
+
".svelte",
|
|
166
|
+
".svg",
|
|
167
|
+
".swift",
|
|
168
|
+
".tcl",
|
|
169
|
+
".tex",
|
|
170
|
+
".textile",
|
|
171
|
+
".tf",
|
|
172
|
+
".thor",
|
|
173
|
+
".toml",
|
|
174
|
+
".tpl",
|
|
175
|
+
".ts",
|
|
176
|
+
".tsv",
|
|
177
|
+
".tsx",
|
|
178
|
+
".ttl",
|
|
179
|
+
".twig",
|
|
180
|
+
".txt",
|
|
181
|
+
".v",
|
|
182
|
+
".vb",
|
|
183
|
+
".vbhtml",
|
|
184
|
+
".vcf",
|
|
185
|
+
".vhd",
|
|
186
|
+
".vim",
|
|
187
|
+
".vue",
|
|
188
|
+
".webmanifest",
|
|
189
|
+
".wiki",
|
|
190
|
+
".wsdl",
|
|
191
|
+
".wsgi",
|
|
192
|
+
".xaml",
|
|
193
|
+
".xhtml",
|
|
194
|
+
".xml",
|
|
195
|
+
".xsd",
|
|
196
|
+
".yaml",
|
|
197
|
+
".yml",
|
|
198
|
+
".zsh"
|
|
199
|
+
]
|