docstudio 0.2.0__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.
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: docstudio
3
+ Version: 0.2.0
4
+ Summary: Bidirectional, Markdown-centric document conversion: reverse (X->Markdown) like markitdown, plus high-fidelity forward export (Markdown->PDF/Word/LaTeX/EPUB/Excel) and optional VLM image recognition.
5
+ Project-URL: Homepage, https://github.com/Sudo-Biao/docstudio
6
+ Project-URL: Repository, https://github.com/Sudo-Biao/docstudio
7
+ Project-URL: Issues, https://github.com/Sudo-Biao/docstudio/issues
8
+ Author-email: biaoli <biaoli@swufe.edu.cn>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: conversion,document,docx,epub,latex,markdown,markitdown,ocr,pdf,vlm
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Office/Business
22
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: markdown>=3.5
25
+ Requires-Dist: markdownify>=0.11
26
+ Provides-Extra: all
27
+ Requires-Dist: ebooklib; extra == 'all'
28
+ Requires-Dist: mammoth; extra == 'all'
29
+ Requires-Dist: markitdown[all]; extra == 'all'
30
+ Requires-Dist: openpyxl; extra == 'all'
31
+ Requires-Dist: pdfminer-six; extra == 'all'
32
+ Requires-Dist: pillow; extra == 'all'
33
+ Requires-Dist: pymupdf; extra == 'all'
34
+ Requires-Dist: pypdf; extra == 'all'
35
+ Requires-Dist: pytesseract; extra == 'all'
36
+ Requires-Dist: python-docx; extra == 'all'
37
+ Requires-Dist: python-pptx; extra == 'all'
38
+ Requires-Dist: requests; extra == 'all'
39
+ Provides-Extra: llm
40
+ Requires-Dist: requests; extra == 'llm'
41
+ Provides-Extra: markitdown
42
+ Requires-Dist: markitdown[all]; extra == 'markitdown'
43
+ Provides-Extra: ocr
44
+ Requires-Dist: pillow; extra == 'ocr'
45
+ Requires-Dist: pymupdf; extra == 'ocr'
46
+ Requires-Dist: pytesseract; extra == 'ocr'
47
+ Provides-Extra: office
48
+ Requires-Dist: ebooklib; extra == 'office'
49
+ Requires-Dist: mammoth; extra == 'office'
50
+ Requires-Dist: openpyxl; extra == 'office'
51
+ Requires-Dist: python-docx; extra == 'office'
52
+ Requires-Dist: python-pptx; extra == 'office'
53
+ Provides-Extra: pdf
54
+ Requires-Dist: pdfminer-six; extra == 'pdf'
55
+ Requires-Dist: pypdf; extra == 'pdf'
56
+ Provides-Extra: pdf-chrome
57
+ Requires-Dist: playwright; extra == 'pdf-chrome'
58
+ Provides-Extra: pdf-weasy
59
+ Requires-Dist: weasyprint; extra == 'pdf-weasy'
60
+ Description-Content-Type: text/markdown
61
+
62
+ # DocumentStudio (Python)
63
+
64
+ A **bidirectional, Markdown-centric** document converter — a Python library and
65
+ CLI in the spirit of Microsoft's [`markitdown`](https://github.com/microsoft/markitdown),
66
+ but going **both ways**:
67
+
68
+ | Direction | Formats | Notes |
69
+ |-----------|---------|-------|
70
+ | **Reverse** `X → Markdown` | PDF, Word, PPT, Excel, EPUB, HTML, CSV/TSV, JSON, ZIP, images | like markitdown; can *delegate to* markitdown when installed |
71
+ | **Forward** `Markdown → X` | HTML, **PDF**, **Word (.docx)**, **LaTeX**, EPUB, Excel (.xlsx), text | high-fidelity export — the part markitdown does **not** do |
72
+ | **AI / VLM** | image & scanned-PDF recognition, "smart cleanup" | any OpenAI-compatible endpoint; vision model optional |
73
+ | **AI assistant** | polish, translate, summarise, expand, continue, grammar, formalise, titles, outline, fix-LaTeX, free-form | one-shot ops on a document |
74
+ | **Toolbox** | table of contents, merge PDFs, extract images | headless, no browser |
75
+ | **Templates** | academic, techdoc, minutes, readme, weekly, blog | ready-to-edit Markdown |
76
+
77
+ The design mirrors markitdown's: a small core, a converter **registry** that's open
78
+ for extension, and **optional dependency extras** so a minimal install still works.
79
+
80
+ ## Install
81
+
82
+ ```bash
83
+ pip install docstudio # core: csv/tsv/json/html + md→html/latex/text
84
+ pip install "docstudio[office]" # docx, pptx, xlsx, epub
85
+ pip install "docstudio[pdf]" # PDF text extraction (pdfminer.six)
86
+ pip install "docstudio[ocr]" # scanned-PDF / image OCR (PyMuPDF, pytesseract)
87
+ pip install "docstudio[llm]" # AI cleanup + VLM (requests)
88
+ pip install "docstudio[markitdown]" # reuse Microsoft markitdown for the reverse path
89
+ pip install "docstudio[all]"
90
+ ```
91
+
92
+ For **Markdown → PDF/DOCX/EPUB** with the best fidelity, install
93
+ [`pandoc`](https://pandoc.org) plus a TeX engine (`xelatex`):
94
+ ```bash
95
+ sudo apt install pandoc texlive-xetex texlive-latex-recommended fonts-noto-cjk
96
+ ```
97
+ PDF also has two pure-Python backends as fallbacks: `weasyprint`
98
+ (`docstudio[pdf-weasy]`) and headless-Chrome via `playwright`
99
+ (`docstudio[pdf-chrome]`, full KaTeX math).
100
+
101
+ ## Library
102
+
103
+ ```python
104
+ from docstudio import DocumentStudio
105
+ ds = DocumentStudio() # use_markitdown=True by default
106
+
107
+ # anything → Markdown
108
+ md = ds.to_markdown("report.pdf")
109
+ md = ds.to_markdown("slides.pptx")
110
+
111
+ # Markdown → anything (non-md inputs are auto-converted first)
112
+ ds.convert("paper.md", to="pdf", out="paper.pdf")
113
+ ds.convert("paper.md", to="docx", out="paper.docx")
114
+ ds.convert("scan.pdf", to="docx", out="scan.docx") # PDF → md → docx
115
+ ds.convert("table.png", to="xlsx", out="table.xlsx") # image → md → xlsx
116
+ ```
117
+
118
+ ### AI + Vision (VLM)
119
+
120
+ ```python
121
+ from docstudio import DocumentStudio
122
+ from docstudio.llm import LLM
123
+
124
+ llm = LLM(base_url="https://api.openai.com", api_key="sk-...",
125
+ model="gpt-4o-mini", vlm_model="gpt-4o")
126
+
127
+ print(LLM.fetch_models("https://api.openai.com", "sk-...")) # pick from the list
128
+
129
+ ds = DocumentStudio(llm=llm)
130
+ md = ds.to_markdown("photographed_table.jpg") # recognised by the vision model
131
+ md = ds.to_markdown("scanned_book.pdf") # page-by-page VLM when no text layer
132
+ md = llm.cleanup_markdown(rough_text) # turn messy OCR into clean Markdown
133
+ ```
134
+
135
+ ## AI assistant (operate on a document)
136
+
137
+ One-shot AI operations on Markdown/text — the *AI Assistant* from the web app.
138
+ Needs an `llm` (any OpenAI-compatible endpoint).
139
+
140
+ ```python
141
+ from docstudio import DocumentStudio
142
+ from docstudio.llm import LLM
143
+
144
+ # any OpenAI-compatible endpoint — OpenAI, DeepSeek, vLLM, Ollama, a gateway…
145
+ # you choose base_url + model; nothing is hard-coded to a provider
146
+ ds = DocumentStudio(llm=LLM(base_url="https://api.openai.com",
147
+ api_key="sk-...", model="gpt-4o-mini"))
148
+
149
+ ds.assist(md, action="polish") # 润色
150
+ ds.assist(md, action="to_en") # 翻译成英文(to_zh 反之)
151
+ ds.assist(md, action="summary") # 摘要
152
+ ds.assist(md, action="outline") # 生成大纲
153
+ ds.assist(md, instruction="把所有表格改成要点列表") # 自由指令
154
+
155
+ DocumentStudio.assist_actions()
156
+ # polish, to_en, to_zh, summary, expand, condense, continue,
157
+ # grammar, formal, titles, outline, fix_latex
158
+ ```
159
+
160
+ ## Toolbox
161
+
162
+ ```python
163
+ ds.generate_toc(md) # insert a Markdown table of contents
164
+ ds.merge_pdfs(["a.pdf", "b.pdf"], "all.pdf") # concatenate PDFs (needs pypdf)
165
+ ds.extract_images("report.pdf", "./imgs") # pull embedded images out (PDF/DOCX/PPTX/EPUB)
166
+ ```
167
+
168
+ ## Templates
169
+
170
+ Six ready-to-edit Markdown templates: `academic`, `techdoc`, `minutes`,
171
+ `readme`, `weekly`, `blog`.
172
+
173
+ ```python
174
+ ds.templates() # {slug: (title, description)}
175
+ body = ds.template("academic")
176
+ ```
177
+
178
+ ## CLI
179
+
180
+ ```bash
181
+ docstudio report.pdf # → report.md (prints to stdout)
182
+ docstudio report.pdf -o out.md
183
+ cat report.pdf | docstudio # stdin → stdout
184
+ docstudio paper.md --to pdf -o paper.pdf # Markdown → anything
185
+ docstudio scan.pdf --to docx # PDF → md → docx
186
+ docstudio photo.jpg --vlm-model gpt-4o --base-url https://api.openai.com --api-key sk-...
187
+ docstudio --list-formats
188
+
189
+ docstudio paper.md --toc -o paper.md # insert a table of contents
190
+ docstudio notes.md --assist polish --base-url https://api.openai.com --model gpt-4o-mini --api-key sk-... -o clean.md
191
+ docstudio notes.md --instruction "翻译成英文" --base-url https://api.openai.com --model gpt-4o-mini --api-key sk-... -o en.md
192
+ docstudio --merge a.pdf b.pdf -o all.pdf # merge PDFs
193
+ docstudio report.pdf --extract-images ./imgs # pull out images
194
+ docstudio --template academic # print a template
195
+ docstudio --list-templates
196
+ ```
197
+
198
+ ## Extending
199
+
200
+ Register your own converter — exactly how the built-ins are defined:
201
+
202
+ ```python
203
+ from docstudio.core import registry
204
+
205
+ @registry.ingester("rtf")
206
+ def rtf_to_md(source, ds=None, **opts):
207
+ ...
208
+ return markdown_text
209
+
210
+ @registry.exporter("rst")
211
+ def md_to_rst(md, out=None, ds=None, **opts):
212
+ ...
213
+ return out
214
+ ```
215
+
216
+ ## Relationship to markitdown
217
+
218
+ `markitdown` is excellent at `X → Markdown` for LLM pipelines. DocumentStudio
219
+ **reuses** it for that direction when present (`use_markitdown=True`), and adds the
220
+ missing half: turning Markdown back into polished, human-facing **PDF / Word /
221
+ LaTeX / EPUB / Excel**, plus a vision-model path for images and scanned PDFs.
222
+
223
+ MIT licensed.
@@ -0,0 +1,15 @@
1
+ docstudio/__init__.py,sha256=kVGwi7_703NTHmheC-wK-84ohgw9q57xy_YS1ZvoX1I,1683
2
+ docstudio/assistant.py,sha256=1ybE7YRdZqzub5FQKyDcNe9o7xfL8t_SAFiTP33tW_E,4260
3
+ docstudio/cli.py,sha256=DByz3ZO6tDGpDq1wYENpDIVEWN-Tu-x6Bqr18emVUVQ,6244
4
+ docstudio/core.py,sha256=LXJXe40QiTjqcbVg4b5BbWVdftoo3m9o-KgUROPwv6c,6985
5
+ docstudio/export.py,sha256=vtTZZ5SdDsthdl9fEVyRPdtzpNKHaWJeEP32axFVx-8,8184
6
+ docstudio/ingest.py,sha256=15dWoxO1911CRgHsB1qF41fSJnFmn_5mrofhGUIxPc0,7429
7
+ docstudio/latex.py,sha256=yre1Quqa9VIKSH1w7Bih0umgK4XJBhpcSbUhofKcSV0,4966
8
+ docstudio/llm.py,sha256=WIlB1586XjZNlg0meCCbmy_DHVdkng4EqIDgmIkUrCI,4997
9
+ docstudio/templates.py,sha256=ZxMwGITtHCvuAXrPb-XH9RlT74zASBEHTT4rpVhQPPc,3371
10
+ docstudio/tools.py,sha256=IbfPUMEgmvJUhalv17AzCsyAcIGksM7BVT5PikUHtH0,3873
11
+ docstudio-0.2.0.dist-info/METADATA,sha256=Dm-Uz_jJZEf9L-Zn9HBBLlEXlV9iP1kFk1PYSbKC0Uo,9074
12
+ docstudio-0.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
13
+ docstudio-0.2.0.dist-info/entry_points.txt,sha256=_mHuZtnxd71tNH1cIQsnY0-zM_xkDyojB4TXl661zBs,49
14
+ docstudio-0.2.0.dist-info/licenses/LICENSE,sha256=H8UokzgF-0yyokPYTdb8eEyqs2apQlLrGKAsNKT_yWo,1063
15
+ docstudio-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ docstudio = docstudio.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 biaoli
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.