markitdown 0.0.1__tar.gz
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.
- markitdown-0.0.1/.gitignore +166 -0
- markitdown-0.0.1/LICENSE +21 -0
- markitdown-0.0.1/PKG-INFO +219 -0
- markitdown-0.0.1/README.md +178 -0
- markitdown-0.0.1/pyproject.toml +87 -0
- markitdown-0.0.1/src/markitdown/__about__.py +4 -0
- markitdown-0.0.1/src/markitdown/__init__.py +11 -0
- markitdown-0.0.1/src/markitdown/__main__.py +111 -0
- markitdown-0.0.1/src/markitdown/_markitdown.py +1814 -0
- markitdown-0.0.1/src/markitdown/py.typed +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
.vscode
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py,cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
cover/
|
|
55
|
+
|
|
56
|
+
# Translations
|
|
57
|
+
*.mo
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
# Django stuff:
|
|
61
|
+
*.log
|
|
62
|
+
local_settings.py
|
|
63
|
+
db.sqlite3
|
|
64
|
+
db.sqlite3-journal
|
|
65
|
+
|
|
66
|
+
# Flask stuff:
|
|
67
|
+
instance/
|
|
68
|
+
.webassets-cache
|
|
69
|
+
|
|
70
|
+
# Scrapy stuff:
|
|
71
|
+
.scrapy
|
|
72
|
+
|
|
73
|
+
# Sphinx documentation
|
|
74
|
+
docs/_build/
|
|
75
|
+
|
|
76
|
+
# PyBuilder
|
|
77
|
+
.pybuilder/
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
89
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
90
|
+
# .python-version
|
|
91
|
+
|
|
92
|
+
# pipenv
|
|
93
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
94
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
95
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
96
|
+
# install all needed dependencies.
|
|
97
|
+
#Pipfile.lock
|
|
98
|
+
|
|
99
|
+
# poetry
|
|
100
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
101
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
102
|
+
# commonly ignored for libraries.
|
|
103
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
104
|
+
#poetry.lock
|
|
105
|
+
|
|
106
|
+
# pdm
|
|
107
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
108
|
+
#pdm.lock
|
|
109
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
110
|
+
# in version control.
|
|
111
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
112
|
+
.pdm.toml
|
|
113
|
+
.pdm-python
|
|
114
|
+
.pdm-build/
|
|
115
|
+
|
|
116
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
117
|
+
__pypackages__/
|
|
118
|
+
|
|
119
|
+
# Celery stuff
|
|
120
|
+
celerybeat-schedule
|
|
121
|
+
celerybeat.pid
|
|
122
|
+
|
|
123
|
+
# SageMath parsed files
|
|
124
|
+
*.sage.py
|
|
125
|
+
|
|
126
|
+
# Environments
|
|
127
|
+
.env
|
|
128
|
+
.venv
|
|
129
|
+
env/
|
|
130
|
+
venv/
|
|
131
|
+
ENV/
|
|
132
|
+
env.bak/
|
|
133
|
+
venv.bak/
|
|
134
|
+
|
|
135
|
+
# Spyder project settings
|
|
136
|
+
.spyderproject
|
|
137
|
+
.spyproject
|
|
138
|
+
|
|
139
|
+
# Rope project settings
|
|
140
|
+
.ropeproject
|
|
141
|
+
|
|
142
|
+
# mkdocs documentation
|
|
143
|
+
/site
|
|
144
|
+
|
|
145
|
+
# mypy
|
|
146
|
+
.mypy_cache/
|
|
147
|
+
.dmypy.json
|
|
148
|
+
dmypy.json
|
|
149
|
+
|
|
150
|
+
# Pyre type checker
|
|
151
|
+
.pyre/
|
|
152
|
+
|
|
153
|
+
# pytype static type analyzer
|
|
154
|
+
.pytype/
|
|
155
|
+
|
|
156
|
+
# Cython debug symbols
|
|
157
|
+
cython_debug/
|
|
158
|
+
|
|
159
|
+
# PyCharm
|
|
160
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
161
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
162
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
163
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
164
|
+
#.idea/
|
|
165
|
+
src/.DS_Store
|
|
166
|
+
.DS_Store
|
markitdown-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: markitdown
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Utility tool for converting various files to Markdown
|
|
5
|
+
Project-URL: Documentation, https://github.com/microsoft/markitdown#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/microsoft/markitdown/issues
|
|
7
|
+
Project-URL: Source, https://github.com/microsoft/markitdown
|
|
8
|
+
Author-email: Adam Fourney <adamfo@microsoft.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: azure-ai-documentintelligence
|
|
21
|
+
Requires-Dist: azure-identity
|
|
22
|
+
Requires-Dist: beautifulsoup4
|
|
23
|
+
Requires-Dist: charset-normalizer
|
|
24
|
+
Requires-Dist: mammoth
|
|
25
|
+
Requires-Dist: markdownify
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: olefile
|
|
28
|
+
Requires-Dist: openai
|
|
29
|
+
Requires-Dist: openpyxl
|
|
30
|
+
Requires-Dist: pandas
|
|
31
|
+
Requires-Dist: pathvalidate
|
|
32
|
+
Requires-Dist: pdfminer-six
|
|
33
|
+
Requires-Dist: puremagic
|
|
34
|
+
Requires-Dist: pydub
|
|
35
|
+
Requires-Dist: python-pptx
|
|
36
|
+
Requires-Dist: requests
|
|
37
|
+
Requires-Dist: speechrecognition
|
|
38
|
+
Requires-Dist: xlrd
|
|
39
|
+
Requires-Dist: youtube-transcript-api
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# MarkItDown
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/markitdown/)
|
|
45
|
+

|
|
46
|
+
[](https://github.com/microsoft/autogen)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
MarkItDown is a utility for converting various files to Markdown (e.g., for indexing, text analysis, etc).
|
|
50
|
+
It supports:
|
|
51
|
+
- PDF
|
|
52
|
+
- PowerPoint
|
|
53
|
+
- Word
|
|
54
|
+
- Excel
|
|
55
|
+
- Images (EXIF metadata and OCR)
|
|
56
|
+
- Audio (EXIF metadata and speech transcription)
|
|
57
|
+
- HTML
|
|
58
|
+
- Text-based formats (CSV, JSON, XML)
|
|
59
|
+
- ZIP files (iterates over contents)
|
|
60
|
+
|
|
61
|
+
To install MarkItDown, use pip: `pip install markitdown`. Alternatively, you can install it from the source: `pip install -e .`
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### Command-Line
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
markitdown path-to-file.pdf > document.md
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or use `-o` to specify the output file:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
markitdown path-to-file.pdf -o document.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To use Document Intelligence conversion:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
markitdown path-to-file.pdf -o document.md -d -e "<document_intelligence_endpoint>"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
You can also pipe content:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cat path-to-file.pdf | markitdown
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
More information about how to set up an Azure Document Intelligence Resource can be found [here](https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/how-to-guides/create-document-intelligence-resource?view=doc-intel-4.0.0)
|
|
90
|
+
|
|
91
|
+
### Python API
|
|
92
|
+
|
|
93
|
+
Basic usage in Python:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from markitdown import MarkItDown
|
|
97
|
+
|
|
98
|
+
md = MarkItDown()
|
|
99
|
+
result = md.convert("test.xlsx")
|
|
100
|
+
print(result.text_content)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Document Intelligence conversion in Python:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from markitdown import MarkItDown
|
|
107
|
+
|
|
108
|
+
md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
|
|
109
|
+
result = md.convert("test.pdf")
|
|
110
|
+
print(result.text_content)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To use Large Language Models for image descriptions, provide `llm_client` and `llm_model`:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from markitdown import MarkItDown
|
|
117
|
+
from openai import OpenAI
|
|
118
|
+
|
|
119
|
+
client = OpenAI()
|
|
120
|
+
md = MarkItDown(llm_client=client, llm_model="gpt-4o")
|
|
121
|
+
result = md.convert("example.jpg")
|
|
122
|
+
print(result.text_content)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Docker
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
docker build -t markitdown:latest .
|
|
129
|
+
docker run --rm -i markitdown:latest < ~/your-file.pdf > output.md
|
|
130
|
+
```
|
|
131
|
+
<details>
|
|
132
|
+
|
|
133
|
+
<summary>Batch Processing Multiple Files</summary>
|
|
134
|
+
|
|
135
|
+
This example shows how to convert multiple files to markdown format in a single run. The script processes all supported files in a directory and creates corresponding markdown files.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
```python convert.py
|
|
139
|
+
from markitdown import MarkItDown
|
|
140
|
+
from openai import OpenAI
|
|
141
|
+
import os
|
|
142
|
+
client = OpenAI(api_key="your-api-key-here")
|
|
143
|
+
md = MarkItDown(llm_client=client, llm_model="gpt-4o-2024-11-20")
|
|
144
|
+
supported_extensions = ('.pptx', '.docx', '.pdf', '.jpg', '.jpeg', '.png')
|
|
145
|
+
files_to_convert = [f for f in os.listdir('.') if f.lower().endswith(supported_extensions)]
|
|
146
|
+
for file in files_to_convert:
|
|
147
|
+
print(f"\nConverting {file}...")
|
|
148
|
+
try:
|
|
149
|
+
md_file = os.path.splitext(file)[0] + '.md'
|
|
150
|
+
result = md.convert(file)
|
|
151
|
+
with open(md_file, 'w') as f:
|
|
152
|
+
f.write(result.text_content)
|
|
153
|
+
|
|
154
|
+
print(f"Successfully converted {file} to {md_file}")
|
|
155
|
+
except Exception as e:
|
|
156
|
+
print(f"Error converting {file}: {str(e)}")
|
|
157
|
+
|
|
158
|
+
print("\nAll conversions completed!")
|
|
159
|
+
```
|
|
160
|
+
2. Place the script in the same directory as your files
|
|
161
|
+
3. Install required packages: like openai
|
|
162
|
+
4. Run script ```bash python convert.py ```
|
|
163
|
+
|
|
164
|
+
Note that original files will remain unchanged and new markdown files are created with the same base name.
|
|
165
|
+
|
|
166
|
+
</details>
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
171
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
172
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
173
|
+
|
|
174
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
175
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
176
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
177
|
+
|
|
178
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
179
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
180
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
181
|
+
|
|
182
|
+
### How to Contribute
|
|
183
|
+
|
|
184
|
+
You can help by looking at issues or helping review PRs. Any issue or PR is welcome, but we have also marked some as 'open for contribution' and 'open for reviewing' to help facilitate community contributions. These are ofcourse just suggestions and you are welcome to contribute in any way you like.
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<div align="center">
|
|
188
|
+
|
|
189
|
+
| | All | Especially Needs Help from Community |
|
|
190
|
+
|-----------------------|------------------------------------------|------------------------------------------------------------------------------------------|
|
|
191
|
+
| **Issues** | [All Issues](https://github.com/microsoft/markitdown/issues) | [Issues open for contribution](https://github.com/microsoft/markitdown/issues?q=is%3Aissue+is%3Aopen+label%3A%22open+for+contribution%22) |
|
|
192
|
+
| **PRs** | [All PRs](https://github.com/microsoft/markitdown/pulls) | [PRs open for reviewing](https://github.com/microsoft/markitdown/pulls?q=is%3Apr+is%3Aopen+label%3A%22open+for+reviewing%22) |
|
|
193
|
+
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
### Running Tests and Checks
|
|
197
|
+
|
|
198
|
+
- Install `hatch` in your environment and run tests:
|
|
199
|
+
```sh
|
|
200
|
+
pip install hatch # Other ways of installing hatch: https://hatch.pypa.io/dev/install/
|
|
201
|
+
hatch shell
|
|
202
|
+
hatch test
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
(Alternative) Use the Devcontainer which has all the dependencies installed:
|
|
206
|
+
```sh
|
|
207
|
+
# Reopen the project in Devcontainer and run:
|
|
208
|
+
hatch test
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
- Run pre-commit checks before submitting a PR: `pre-commit run --all-files`
|
|
212
|
+
|
|
213
|
+
## Trademarks
|
|
214
|
+
|
|
215
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
216
|
+
trademarks or logos is subject to and must follow
|
|
217
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
218
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
219
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# MarkItDown
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/markitdown/)
|
|
4
|
+

|
|
5
|
+
[](https://github.com/microsoft/autogen)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
MarkItDown is a utility for converting various files to Markdown (e.g., for indexing, text analysis, etc).
|
|
9
|
+
It supports:
|
|
10
|
+
- PDF
|
|
11
|
+
- PowerPoint
|
|
12
|
+
- Word
|
|
13
|
+
- Excel
|
|
14
|
+
- Images (EXIF metadata and OCR)
|
|
15
|
+
- Audio (EXIF metadata and speech transcription)
|
|
16
|
+
- HTML
|
|
17
|
+
- Text-based formats (CSV, JSON, XML)
|
|
18
|
+
- ZIP files (iterates over contents)
|
|
19
|
+
|
|
20
|
+
To install MarkItDown, use pip: `pip install markitdown`. Alternatively, you can install it from the source: `pip install -e .`
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Command-Line
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
markitdown path-to-file.pdf > document.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or use `-o` to specify the output file:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
markitdown path-to-file.pdf -o document.md
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To use Document Intelligence conversion:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
markitdown path-to-file.pdf -o document.md -d -e "<document_intelligence_endpoint>"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
You can also pipe content:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cat path-to-file.pdf | markitdown
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
More information about how to set up an Azure Document Intelligence Resource can be found [here](https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/how-to-guides/create-document-intelligence-resource?view=doc-intel-4.0.0)
|
|
49
|
+
|
|
50
|
+
### Python API
|
|
51
|
+
|
|
52
|
+
Basic usage in Python:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from markitdown import MarkItDown
|
|
56
|
+
|
|
57
|
+
md = MarkItDown()
|
|
58
|
+
result = md.convert("test.xlsx")
|
|
59
|
+
print(result.text_content)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Document Intelligence conversion in Python:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from markitdown import MarkItDown
|
|
66
|
+
|
|
67
|
+
md = MarkItDown(docintel_endpoint="<document_intelligence_endpoint>")
|
|
68
|
+
result = md.convert("test.pdf")
|
|
69
|
+
print(result.text_content)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To use Large Language Models for image descriptions, provide `llm_client` and `llm_model`:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from markitdown import MarkItDown
|
|
76
|
+
from openai import OpenAI
|
|
77
|
+
|
|
78
|
+
client = OpenAI()
|
|
79
|
+
md = MarkItDown(llm_client=client, llm_model="gpt-4o")
|
|
80
|
+
result = md.convert("example.jpg")
|
|
81
|
+
print(result.text_content)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Docker
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
docker build -t markitdown:latest .
|
|
88
|
+
docker run --rm -i markitdown:latest < ~/your-file.pdf > output.md
|
|
89
|
+
```
|
|
90
|
+
<details>
|
|
91
|
+
|
|
92
|
+
<summary>Batch Processing Multiple Files</summary>
|
|
93
|
+
|
|
94
|
+
This example shows how to convert multiple files to markdown format in a single run. The script processes all supported files in a directory and creates corresponding markdown files.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
```python convert.py
|
|
98
|
+
from markitdown import MarkItDown
|
|
99
|
+
from openai import OpenAI
|
|
100
|
+
import os
|
|
101
|
+
client = OpenAI(api_key="your-api-key-here")
|
|
102
|
+
md = MarkItDown(llm_client=client, llm_model="gpt-4o-2024-11-20")
|
|
103
|
+
supported_extensions = ('.pptx', '.docx', '.pdf', '.jpg', '.jpeg', '.png')
|
|
104
|
+
files_to_convert = [f for f in os.listdir('.') if f.lower().endswith(supported_extensions)]
|
|
105
|
+
for file in files_to_convert:
|
|
106
|
+
print(f"\nConverting {file}...")
|
|
107
|
+
try:
|
|
108
|
+
md_file = os.path.splitext(file)[0] + '.md'
|
|
109
|
+
result = md.convert(file)
|
|
110
|
+
with open(md_file, 'w') as f:
|
|
111
|
+
f.write(result.text_content)
|
|
112
|
+
|
|
113
|
+
print(f"Successfully converted {file} to {md_file}")
|
|
114
|
+
except Exception as e:
|
|
115
|
+
print(f"Error converting {file}: {str(e)}")
|
|
116
|
+
|
|
117
|
+
print("\nAll conversions completed!")
|
|
118
|
+
```
|
|
119
|
+
2. Place the script in the same directory as your files
|
|
120
|
+
3. Install required packages: like openai
|
|
121
|
+
4. Run script ```bash python convert.py ```
|
|
122
|
+
|
|
123
|
+
Note that original files will remain unchanged and new markdown files are created with the same base name.
|
|
124
|
+
|
|
125
|
+
</details>
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
130
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
131
|
+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
|
|
132
|
+
|
|
133
|
+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
|
|
134
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
135
|
+
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
136
|
+
|
|
137
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
138
|
+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
139
|
+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
140
|
+
|
|
141
|
+
### How to Contribute
|
|
142
|
+
|
|
143
|
+
You can help by looking at issues or helping review PRs. Any issue or PR is welcome, but we have also marked some as 'open for contribution' and 'open for reviewing' to help facilitate community contributions. These are ofcourse just suggestions and you are welcome to contribute in any way you like.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<div align="center">
|
|
147
|
+
|
|
148
|
+
| | All | Especially Needs Help from Community |
|
|
149
|
+
|-----------------------|------------------------------------------|------------------------------------------------------------------------------------------|
|
|
150
|
+
| **Issues** | [All Issues](https://github.com/microsoft/markitdown/issues) | [Issues open for contribution](https://github.com/microsoft/markitdown/issues?q=is%3Aissue+is%3Aopen+label%3A%22open+for+contribution%22) |
|
|
151
|
+
| **PRs** | [All PRs](https://github.com/microsoft/markitdown/pulls) | [PRs open for reviewing](https://github.com/microsoft/markitdown/pulls?q=is%3Apr+is%3Aopen+label%3A%22open+for+reviewing%22) |
|
|
152
|
+
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
### Running Tests and Checks
|
|
156
|
+
|
|
157
|
+
- Install `hatch` in your environment and run tests:
|
|
158
|
+
```sh
|
|
159
|
+
pip install hatch # Other ways of installing hatch: https://hatch.pypa.io/dev/install/
|
|
160
|
+
hatch shell
|
|
161
|
+
hatch test
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
(Alternative) Use the Devcontainer which has all the dependencies installed:
|
|
165
|
+
```sh
|
|
166
|
+
# Reopen the project in Devcontainer and run:
|
|
167
|
+
hatch test
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- Run pre-commit checks before submitting a PR: `pre-commit run --all-files`
|
|
171
|
+
|
|
172
|
+
## Trademarks
|
|
173
|
+
|
|
174
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
175
|
+
trademarks or logos is subject to and must follow
|
|
176
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
|
|
177
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
178
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "markitdown"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = 'Utility tool for converting various files to Markdown'
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Adam Fourney", email = "adamfo@microsoft.com" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"beautifulsoup4",
|
|
28
|
+
"requests",
|
|
29
|
+
"mammoth",
|
|
30
|
+
"markdownify",
|
|
31
|
+
"numpy",
|
|
32
|
+
"python-pptx",
|
|
33
|
+
"pandas",
|
|
34
|
+
"openpyxl",
|
|
35
|
+
"xlrd",
|
|
36
|
+
"pdfminer.six",
|
|
37
|
+
"puremagic",
|
|
38
|
+
"pydub",
|
|
39
|
+
"olefile",
|
|
40
|
+
"youtube-transcript-api",
|
|
41
|
+
"SpeechRecognition",
|
|
42
|
+
"pathvalidate",
|
|
43
|
+
"charset-normalizer",
|
|
44
|
+
"openai",
|
|
45
|
+
"azure-ai-documentintelligence",
|
|
46
|
+
"azure-identity"
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Documentation = "https://github.com/microsoft/markitdown#readme"
|
|
51
|
+
Issues = "https://github.com/microsoft/markitdown/issues"
|
|
52
|
+
Source = "https://github.com/microsoft/markitdown"
|
|
53
|
+
|
|
54
|
+
[tool.hatch.version]
|
|
55
|
+
path = "src/markitdown/__about__.py"
|
|
56
|
+
|
|
57
|
+
[project.scripts]
|
|
58
|
+
markitdown = "markitdown.__main__:main"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.envs.types]
|
|
61
|
+
extra-dependencies = [
|
|
62
|
+
"mypy>=1.0.0",
|
|
63
|
+
]
|
|
64
|
+
[tool.hatch.envs.types.scripts]
|
|
65
|
+
check = "mypy --install-types --non-interactive {args:src/markitdown tests}"
|
|
66
|
+
|
|
67
|
+
[tool.coverage.run]
|
|
68
|
+
source_pkgs = ["markitdown", "tests"]
|
|
69
|
+
branch = true
|
|
70
|
+
parallel = true
|
|
71
|
+
omit = [
|
|
72
|
+
"src/markitdown/__about__.py",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.coverage.paths]
|
|
76
|
+
markitdown = ["src/markitdown", "*/markitdown/src/markitdown"]
|
|
77
|
+
tests = ["tests", "*/markitdown/tests"]
|
|
78
|
+
|
|
79
|
+
[tool.coverage.report]
|
|
80
|
+
exclude_lines = [
|
|
81
|
+
"no cov",
|
|
82
|
+
"if __name__ == .__main__.:",
|
|
83
|
+
"if TYPE_CHECKING:",
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
[tool.hatch.build.targets.sdist]
|
|
87
|
+
only-include = ["src/markitdown"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024-present Adam Fourney <adamfo@microsoft.com>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
from ._markitdown import MarkItDown, FileConversionException, UnsupportedFormatException
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"MarkItDown",
|
|
9
|
+
"FileConversionException",
|
|
10
|
+
"UnsupportedFormatException",
|
|
11
|
+
]
|