markitdown-gc 0.3.6__tar.gz → 0.3.8__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_gc-0.3.6 → markitdown_gc-0.3.8}/PKG-INFO +9 -8
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/README.md +3 -1
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/pyproject.toml +8 -6
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/GUIDE.md +9 -5
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/__about__.py +1 -1
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/__init__.py +4 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/__main__.py +24 -3
- markitdown_gc-0.3.8/src/markitdown/_installation.py +43 -0
- markitdown_gc-0.3.8/src/markitdown/_libreoffice.py +252 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_markitdown.py +22 -24
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/__init__.py +2 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_audio_converter.py +3 -1
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_csv_converter.py +21 -4
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_docx_converter.py +10 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_exiftool.py +34 -3
- markitdown_gc-0.3.8/src/markitdown/converters/_libreoffice_converter.py +127 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_markdownify.py +37 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_pdf_converter.py +212 -2
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_transcribe_audio.py +5 -1
- markitdown_gc-0.3.8/src/markitdown/converters/_xls_table.py +246 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_xlsx_converter.py +39 -23
- markitdown_gc-0.3.8/src/markitdown/tools.py +178 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/.gitignore +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/LICENSE +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/ThirdPartyNotices.md +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_base_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_exceptions.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_hwp_media.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_media.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_stream_info.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_text.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/_uri_utils.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/__init__.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/_image.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/_xlsx_images.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/__init__.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/_images.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/math/__init__.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/math/latex_dict.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/math/omml.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converter_utils/docx/pre_process.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_bing_serp_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_cu_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_doc_intel_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_epub_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_html_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_hwp_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_image_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_ipynb_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_llm_caption.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_outlook_msg_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_plain_text_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_pptx_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_rss_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_wikipedia_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_youtube_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/converters/_zip_converter.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/ocr_triage.py +0 -0
- {markitdown_gc-0.3.6 → markitdown_gc-0.3.8}/src/markitdown/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: markitdown-gc
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.8
|
|
4
4
|
Summary: Utility tool for converting various files to Markdown
|
|
5
5
|
Project-URL: Documentation, https://github.com/greatgc-flow/markitdown-gc#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/greatgc-flow/markitdown-gc/issues
|
|
@@ -31,7 +31,7 @@ Requires-Dist: mammoth<2,>=1.12.2
|
|
|
31
31
|
Requires-Dist: markdownify
|
|
32
32
|
Requires-Dist: olefile
|
|
33
33
|
Requires-Dist: openpyxl
|
|
34
|
-
Requires-Dist: pandas
|
|
34
|
+
Requires-Dist: pandas<4
|
|
35
35
|
Requires-Dist: pdfminer-six>=20251230
|
|
36
36
|
Requires-Dist: pdfplumber>=0.11.9
|
|
37
37
|
Requires-Dist: python-pptx
|
|
@@ -46,17 +46,17 @@ Requires-Dist: lxml; extra == 'all'
|
|
|
46
46
|
Requires-Dist: mammoth<2,>=1.12.2; extra == 'all'
|
|
47
47
|
Requires-Dist: olefile; extra == 'all'
|
|
48
48
|
Requires-Dist: openpyxl; extra == 'all'
|
|
49
|
-
Requires-Dist: pandas; extra == 'all'
|
|
49
|
+
Requires-Dist: pandas<4; extra == 'all'
|
|
50
50
|
Requires-Dist: pdfminer-six>=20251230; extra == 'all'
|
|
51
51
|
Requires-Dist: pdfplumber>=0.11.9; extra == 'all'
|
|
52
52
|
Requires-Dist: pydub; extra == 'all'
|
|
53
53
|
Requires-Dist: python-pptx; extra == 'all'
|
|
54
|
-
Requires-Dist: speechrecognition; extra == 'all'
|
|
54
|
+
Requires-Dist: speechrecognition>=3.10.4; extra == 'all'
|
|
55
55
|
Requires-Dist: xlrd; extra == 'all'
|
|
56
56
|
Requires-Dist: youtube-transcript-api~=1.2.3; (python_full_version < '3.15') and extra == 'all'
|
|
57
57
|
Provides-Extra: audio-transcription
|
|
58
58
|
Requires-Dist: pydub; extra == 'audio-transcription'
|
|
59
|
-
Requires-Dist: speechrecognition; extra == 'audio-transcription'
|
|
59
|
+
Requires-Dist: speechrecognition>=3.10.4; extra == 'audio-transcription'
|
|
60
60
|
Provides-Extra: az-content-understanding
|
|
61
61
|
Requires-Dist: azure-ai-contentunderstanding>=1.2.0b1; extra == 'az-content-understanding'
|
|
62
62
|
Requires-Dist: azure-identity; extra == 'az-content-understanding'
|
|
@@ -76,11 +76,10 @@ Requires-Dist: pdfplumber>=0.11.9; extra == 'pdf'
|
|
|
76
76
|
Provides-Extra: pptx
|
|
77
77
|
Requires-Dist: python-pptx; extra == 'pptx'
|
|
78
78
|
Provides-Extra: xls
|
|
79
|
-
Requires-Dist: pandas; extra == 'xls'
|
|
80
79
|
Requires-Dist: xlrd; extra == 'xls'
|
|
81
80
|
Provides-Extra: xlsx
|
|
82
81
|
Requires-Dist: openpyxl; extra == 'xlsx'
|
|
83
|
-
Requires-Dist: pandas; extra == 'xlsx'
|
|
82
|
+
Requires-Dist: pandas<4; extra == 'xlsx'
|
|
84
83
|
Provides-Extra: youtube-transcription
|
|
85
84
|
Requires-Dist: youtube-transcript-api~=1.2.3; (python_full_version < '3.15') and extra == 'youtube-transcription'
|
|
86
85
|
Description-Content-Type: text/markdown
|
|
@@ -88,7 +87,9 @@ Description-Content-Type: text/markdown
|
|
|
88
87
|
# MarkItDown GC
|
|
89
88
|
|
|
90
89
|
> Unofficial fork of [Microsoft MarkItDown](https://github.com/microsoft/markitdown), maintained at [greatgc-flow/markitdown-gc](https://github.com/greatgc-flow/markitdown-gc). This fork is not affiliated with or endorsed by Microsoft.
|
|
91
|
-
> Install
|
|
90
|
+
> Install `markitdown-gc` in a dedicated virtual environment. Never co-install upstream `markitdown` or plugins that depend on it: both ship `markitdown/` and overwrite shared files. The CLI exits 1 on detected conflicts; library import warns once. Recreate mixed environments; see `markitdown-gc --guide install`.
|
|
91
|
+
|
|
92
|
+
Optional local LibreOffice converts legacy `.doc`, `.ppt`, `.rtf` and HWP < 5.0: enable `--libreoffice`, Python `MarkItDown(libreoffice_path="soffice")`, or `SOFFICE_PATH`. Output carries a LibreOffice version/source-extension comment with `fidelity=DERIVED`. See `--guide formats`, `--guide install` and `--guide errors`.
|
|
92
93
|
|
|
93
94
|
> [!TIP]
|
|
94
95
|
> MarkItDown is a Python package and command-line utility for converting various files to Markdown (e.g., for indexing, text analysis, etc).
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# MarkItDown GC
|
|
2
2
|
|
|
3
3
|
> Unofficial fork of [Microsoft MarkItDown](https://github.com/microsoft/markitdown), maintained at [greatgc-flow/markitdown-gc](https://github.com/greatgc-flow/markitdown-gc). This fork is not affiliated with or endorsed by Microsoft.
|
|
4
|
-
> Install
|
|
4
|
+
> Install `markitdown-gc` in a dedicated virtual environment. Never co-install upstream `markitdown` or plugins that depend on it: both ship `markitdown/` and overwrite shared files. The CLI exits 1 on detected conflicts; library import warns once. Recreate mixed environments; see `markitdown-gc --guide install`.
|
|
5
|
+
|
|
6
|
+
Optional local LibreOffice converts legacy `.doc`, `.ppt`, `.rtf` and HWP < 5.0: enable `--libreoffice`, Python `MarkItDown(libreoffice_path="soffice")`, or `SOFFICE_PATH`. Output carries a LibreOffice version/source-extension comment with `fidelity=DERIVED`. See `--guide formats`, `--guide install` and `--guide errors`.
|
|
5
7
|
|
|
6
8
|
> [!TIP]
|
|
7
9
|
> MarkItDown is a Python package and command-line utility for converting various files to Markdown (e.g., for indexing, text analysis, etc).
|
|
@@ -40,7 +40,9 @@ dependencies = [
|
|
|
40
40
|
"hwp-hwpx-parser>=1.0,<1.1",
|
|
41
41
|
"python-pptx",
|
|
42
42
|
"mammoth>=1.12.2,<2",
|
|
43
|
-
|
|
43
|
+
# pandas<4: XLSX still reads through pandas (openpyxl engine); XLS reads xlrd
|
|
44
|
+
# directly since #63. Lift the cap once XLSX is validated on pandas 4.
|
|
45
|
+
"pandas<4",
|
|
44
46
|
"openpyxl",
|
|
45
47
|
"xlrd",
|
|
46
48
|
"lxml",
|
|
@@ -55,7 +57,7 @@ all = [
|
|
|
55
57
|
"hwp-hwpx-parser>=1.0,<1.1",
|
|
56
58
|
"python-pptx",
|
|
57
59
|
"mammoth>=1.12.2,<2",
|
|
58
|
-
"pandas",
|
|
60
|
+
"pandas<4",
|
|
59
61
|
"openpyxl",
|
|
60
62
|
"xlrd",
|
|
61
63
|
"lxml",
|
|
@@ -63,7 +65,7 @@ all = [
|
|
|
63
65
|
"pdfplumber>=0.11.9",
|
|
64
66
|
"olefile",
|
|
65
67
|
"pydub",
|
|
66
|
-
"SpeechRecognition",
|
|
68
|
+
"SpeechRecognition>=3.10.4",
|
|
67
69
|
"youtube-transcript-api~=1.2.3; python_full_version < '3.15'",
|
|
68
70
|
"azure-ai-documentintelligence",
|
|
69
71
|
"azure-ai-contentunderstanding>=1.2.0b1",
|
|
@@ -72,11 +74,11 @@ all = [
|
|
|
72
74
|
pptx = ["python-pptx"]
|
|
73
75
|
hwp = ["hwp-hwpx-parser>=1.0,<1.1"]
|
|
74
76
|
docx = ["mammoth>=1.12.2,<2", "lxml"]
|
|
75
|
-
xlsx = ["pandas", "openpyxl"]
|
|
76
|
-
xls = ["
|
|
77
|
+
xlsx = ["pandas<4", "openpyxl"]
|
|
78
|
+
xls = ["xlrd"]
|
|
77
79
|
pdf = ["pdfminer.six>=20251230", "pdfplumber>=0.11.9"]
|
|
78
80
|
outlook = ["olefile"]
|
|
79
|
-
audio-transcription = ["pydub", "SpeechRecognition"]
|
|
81
|
+
audio-transcription = ["pydub", "SpeechRecognition>=3.10.4"]
|
|
80
82
|
youtube-transcription = ["youtube-transcript-api~=1.2.3; python_full_version < '3.15'"]
|
|
81
83
|
az-doc-intel = ["azure-ai-documentintelligence", "azure-identity"]
|
|
82
84
|
# >=1.2.0b1 required for to_llm_input() helper used by ContentUnderstandingConverter
|
|
@@ -17,12 +17,12 @@ Next steps:
|
|
|
17
17
|
|
|
18
18
|
## formats
|
|
19
19
|
What you actually get (text only, no layout fidelity):
|
|
20
|
-
- PDF: text per page; tables best-effort; scanned pages give NO text (see ocr).
|
|
21
|
-
- DOCX/PPTX: headings, lists, tables, alt text; images are `` or truncated `data:` refs (`--keep-data-uris` keeps them, huge). PPTX has `<!-- Slide number: N -->`.
|
|
22
|
-
- XLSX/XLS/CSV: one table per sheet. XLSX image extraction is opt-in.
|
|
23
|
-
-
|
|
20
|
+
- PDF: text per page; tables best-effort; lines matching bookmarks (outline) on their target page become `#` headings (not with the ocr plugin); scanned pages give NO text (see ocr).
|
|
21
|
+
- DOCX/PPTX: headings (DOCX Title/Subtitle → `#`/`##`), lists, tables, alt text; images are `` or truncated `data:` refs (`--keep-data-uris` keeps them, huge). PPTX has `<!-- Slide number: N -->`.
|
|
22
|
+
- XLSX/XLS/CSV/TSV: one table per sheet. XLSX image extraction is opt-in.
|
|
23
|
+
- HWP5/HWPX: text + pipe tables (merged cells flattened), images `[IMAGE]`, footnotes appended; encrypted files unsupported.
|
|
24
24
|
- HTML, EPUB, RSS, IPYNB, JSON/XML/text, ZIP (recursive), MSG: text/structure.
|
|
25
|
-
- Legacy .doc/.ppt/.rtf
|
|
25
|
+
- Legacy .doc/.ppt/.rtf and HWP < 5.0: opt in with `--libreoffice`, Python `MarkItDown(libreoffice_path="soffice")`, or `SOFFICE_PATH`. Requires local LibreOffice; otherwise unchanged/unsupported. Converts to DOCX/PPTX, then uses the native converter. Output starts `<!-- converted via LibreOffice X.Y from .doc; fidelity=DERIVED -->`: derived text, not native fidelity. Temporary input/output/profile are deleted; original input is unchanged.
|
|
26
26
|
For known CP949 Korean input use --charset cp949; automatic detection can silently misidentify short legacy-encoded text.
|
|
27
27
|
- Image: EXIF only if `exiftool` is installed, caption only with an LLM client; otherwise empty.
|
|
28
28
|
- Audio: metadata + transcript (`[audio-transcription]`, ffmpeg, network).
|
|
@@ -86,6 +86,8 @@ S3 verify with the other peer: re-read the image independently; check every page
|
|
|
86
86
|
S4 assemble: append `## OCR p3 (peer, model, date)` after the converted text; ledger ocr-work/manifest.json tracks pending/ocr_done/verified per id; no persistent cache; delete `ocr-work/` after verification.
|
|
87
87
|
|
|
88
88
|
## errors
|
|
89
|
+
- Conflicting installation: CLI exits 1; library import warns once. Use a fresh dedicated venv; shared files may already be overwritten.
|
|
90
|
+
- LibreOffice failure: check SOFFICE_PATH and input; timeout (default 60 seconds, Python `libreoffice_timeout=...`) kills the whole process tree, including soffice.bin. Failed pre-conversion raises FileConversionException.
|
|
89
91
|
- UnsupportedFormatException: no converter accepted the input (add `-x EXT` / `-m MIME`; on Python 3.15 hint-free stdin is unsupported).
|
|
90
92
|
- MissingDependencyException: install the extra named in the message (see install).
|
|
91
93
|
- FileConversionException: a converter accepted the file but failed (corrupt/encrypted); the message lists attempts.
|
|
@@ -96,11 +98,13 @@ S4 assemble: append `## OCR p3 (peer, model, date)` after the converted text; le
|
|
|
96
98
|
- Batch: loop in your own code, catch the three exceptions, log failures, continue.
|
|
97
99
|
|
|
98
100
|
## install
|
|
101
|
+
- Never co-install upstream `markitdown` or its plugins (which may depend on it) with `markitdown-gc`: both ship `markitdown/`. Use a dedicated venv: `python -m venv .venv-gc`, then `.venv-gc/Scripts/python -m pip install markitdown-gc` (Windows) or `.venv-gc/bin/python -m pip install markitdown-gc` (macOS/Linux). Recreate a mixed environment; uninstalling one package can delete the other's files.
|
|
99
102
|
- `pip install markitdown-gc` installs every document converter (pdf, docx, pptx, xlsx/xls, outlook, hwp/hwpx). Only `[audio-transcription]`, `[youtube-transcription]` and the Azure extras (`[az-doc-intel]`, `[az-content-understanding]`) are optional; `[all]` adds them. Per-format extras such as `[pdf]` still work as no-op aliases.
|
|
100
103
|
- Python 3.10-3.15. On 3.15 magika (content sniffing) and youtube transcripts are unavailable: always pass the extension or MIME type for stdin/bytes.
|
|
101
104
|
- Windows: set `PYTHONUTF8=1`; a short temp path avoids pip git-clone path-length errors.
|
|
102
105
|
- `-p/--use-plugins` enables plugins; `-d -e ENDPOINT` uses Azure Document Intelligence.
|
|
103
106
|
External programs (NOT installed by pip; optional, install only when needed; check with `exiftool -ver` / `ffmpeg -version`):
|
|
107
|
+
- LibreOffice: legacy .doc/.ppt/.rtf/HWP<5 only; OFF unless `--libreoffice`, `libreoffice_path`, or `SOFFICE_PATH` is set. `--libreoffice` uses SOFFICE_PATH or PATH. Install locally yourself; no automatic downloads/network services. Runs with an isolated profile, macros/link updates/update checks disabled. Windows `winget install TheDocumentFoundation.LibreOffice` | macOS `brew install --cask libreoffice` | Debian/Ubuntu `sudo apt install libreoffice`.
|
|
104
108
|
- exiftool (>= 12.24): adds EXIF/tag metadata lines for images and audio; without it conversion still works. Set `EXIFTOOL_PATH` if it is not on PATH.
|
|
105
109
|
Windows `winget install OliverBetz.ExifTool` | macOS `brew install exiftool` | Debian/Ubuntu `sudo apt install libimage-exiftool-perl`.
|
|
106
110
|
- ffmpeg: decodes audio for `[audio-transcription]` only. Windows `winget install Gyan.FFmpeg` | macOS `brew install ffmpeg` | Debian/Ubuntu `sudo apt install ffmpeg`.
|
|
@@ -30,6 +30,13 @@ def _require_input_or_pipe(parser, args):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
def main():
|
|
33
|
+
from ._installation import installation_conflict
|
|
34
|
+
|
|
35
|
+
conflict = installation_conflict()
|
|
36
|
+
if conflict:
|
|
37
|
+
sys.stderr.write(conflict + "\n")
|
|
38
|
+
sys.exit(1)
|
|
39
|
+
|
|
33
40
|
parser = argparse.ArgumentParser(
|
|
34
41
|
description="Convert various file formats to markdown.",
|
|
35
42
|
prog="markitdown-gc",
|
|
@@ -153,6 +160,12 @@ def main():
|
|
|
153
160
|
help="List installed 3rd-party plugins. Plugins are loaded when using the -p or --use-plugins option.",
|
|
154
161
|
)
|
|
155
162
|
|
|
163
|
+
parser.add_argument(
|
|
164
|
+
"--libreoffice",
|
|
165
|
+
action="store_true",
|
|
166
|
+
help="Enable local LibreOffice for legacy DOC/PPT/RTF/HWP<5 (SOFFICE_PATH or soffice on PATH).",
|
|
167
|
+
)
|
|
168
|
+
|
|
156
169
|
parser.add_argument(
|
|
157
170
|
"--keep-data-uris",
|
|
158
171
|
action="store_true",
|
|
@@ -221,6 +234,9 @@ def main():
|
|
|
221
234
|
args.cu_endpoint or os.environ.get("MARKITDOWN_CU_ENDPOINT") or None
|
|
222
235
|
)
|
|
223
236
|
media_options = {}
|
|
237
|
+
libreoffice_options = {}
|
|
238
|
+
if args.libreoffice:
|
|
239
|
+
libreoffice_options["libreoffice_path"] = os.getenv("SOFFICE_PATH") or "soffice"
|
|
224
240
|
if args.extract_media:
|
|
225
241
|
media_options = {
|
|
226
242
|
"extract_media": args.extract_media,
|
|
@@ -320,7 +336,9 @@ def main():
|
|
|
320
336
|
if fields:
|
|
321
337
|
docintel_kwargs["docintel_query_fields"] = fields
|
|
322
338
|
|
|
323
|
-
markitdown = MarkItDown(
|
|
339
|
+
markitdown = MarkItDown(
|
|
340
|
+
enable_plugins=args.use_plugins, **libreoffice_options, **docintel_kwargs
|
|
341
|
+
)
|
|
324
342
|
elif args.use_cu:
|
|
325
343
|
if args.cu_endpoint is None:
|
|
326
344
|
parser.error(
|
|
@@ -349,9 +367,11 @@ def main():
|
|
|
349
367
|
parser.error(f"Unknown file type: {name}")
|
|
350
368
|
cu_kwargs["cu_file_types"] = cu_types
|
|
351
369
|
|
|
352
|
-
markitdown = MarkItDown(
|
|
370
|
+
markitdown = MarkItDown(
|
|
371
|
+
enable_plugins=args.use_plugins, **libreoffice_options, **cu_kwargs
|
|
372
|
+
)
|
|
353
373
|
else:
|
|
354
|
-
markitdown = MarkItDown(enable_plugins=args.use_plugins)
|
|
374
|
+
markitdown = MarkItDown(enable_plugins=args.use_plugins, **libreoffice_options)
|
|
355
375
|
|
|
356
376
|
_require_input_or_pipe(parser, args)
|
|
357
377
|
|
|
@@ -412,6 +432,7 @@ def _check_exclusive(parser, args, flag, allowed):
|
|
|
412
432
|
("--list-plugins", args.list_plugins),
|
|
413
433
|
("--keep-data-uris", args.keep_data_uris),
|
|
414
434
|
("--extract-media", args.extract_media),
|
|
435
|
+
("--libreoffice", args.libreoffice),
|
|
415
436
|
("--endpoint", args.endpoint),
|
|
416
437
|
("--cu-endpoint", args.cu_endpoint),
|
|
417
438
|
("--cu-analyzer", args.cu_analyzer),
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Detect distributions which overwrite the shared markitdown package."""
|
|
2
|
+
|
|
3
|
+
from importlib import metadata
|
|
4
|
+
from typing import Optional
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
from .__about__ import __version__
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def installation_conflict() -> Optional[str]:
|
|
11
|
+
try:
|
|
12
|
+
installed = metadata.version("markitdown-gc")
|
|
13
|
+
except metadata.PackageNotFoundError:
|
|
14
|
+
return None # A source checkout without installed distribution metadata.
|
|
15
|
+
try:
|
|
16
|
+
upstream = metadata.version("markitdown")
|
|
17
|
+
except metadata.PackageNotFoundError:
|
|
18
|
+
upstream = None
|
|
19
|
+
if upstream is None and installed == __version__:
|
|
20
|
+
return None
|
|
21
|
+
reason = (
|
|
22
|
+
f"markitdown {upstream} and markitdown-gc {installed} are co-installed"
|
|
23
|
+
if upstream is not None
|
|
24
|
+
else f"markitdown-gc metadata version {installed} differs from loaded version {__version__}"
|
|
25
|
+
)
|
|
26
|
+
return (
|
|
27
|
+
f"Conflicting markitdown installation: {reason}. Shared package files may be overwritten. "
|
|
28
|
+
"Never co-install upstream markitdown or plugins that depend on it with markitdown-gc. "
|
|
29
|
+
"Use a dedicated virtual environment. Fix: python -m venv .venv-markitdown-gc; "
|
|
30
|
+
"then .venv-markitdown-gc/Scripts/python -m pip install markitdown-gc (Windows), "
|
|
31
|
+
"or .venv-markitdown-gc/bin/python -m pip install markitdown-gc (macOS/Linux)."
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_warned = False
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def warn_if_conflicting() -> None:
|
|
39
|
+
global _warned
|
|
40
|
+
message = installation_conflict()
|
|
41
|
+
if message and not _warned:
|
|
42
|
+
_warned = True
|
|
43
|
+
warnings.warn(message, RuntimeWarning, stacklevel=2)
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"""Local LibreOffice process isolation, ported from MarkItDown-Flow preconvert."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import re
|
|
6
|
+
import shutil
|
|
7
|
+
import signal
|
|
8
|
+
import subprocess
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
_ENV = frozenset(
|
|
12
|
+
"PATH SYSTEMROOT SYSTEMDRIVE COMSPEC WINDIR HOME USERPROFILE APPDATA LOCALAPPDATA "
|
|
13
|
+
"TEMP TMP LANG LC_ALL".split()
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _resolve(path):
|
|
18
|
+
executable = shutil.which(os.fspath(path))
|
|
19
|
+
if executable:
|
|
20
|
+
executable = str(Path(executable).absolute())
|
|
21
|
+
console = Path(executable).with_suffix(".com")
|
|
22
|
+
if (
|
|
23
|
+
os.name == "nt"
|
|
24
|
+
and Path(executable).name.lower() == "soffice.exe"
|
|
25
|
+
and console.is_file()
|
|
26
|
+
):
|
|
27
|
+
executable = str(console)
|
|
28
|
+
return executable
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _write_profile(profile):
|
|
32
|
+
(profile / "user").mkdir(parents=True)
|
|
33
|
+
(profile / "user/registrymodifications.xcu").write_text(
|
|
34
|
+
"""<?xml version="1.0" encoding="UTF-8"?>
|
|
35
|
+
<oor:items xmlns:oor="http://openoffice.org/2001/registry">
|
|
36
|
+
<item oor:path="/org.openoffice.Office.Common/Security/Scripting"><prop oor:name="MacroSecurityLevel" oor:op="fuse"><value>3</value></prop></item>
|
|
37
|
+
<item oor:path="/org.openoffice.Office.Common/Security/Scripting"><prop oor:name="DisableMacrosExecution" oor:op="fuse"><value>true</value></prop></item>
|
|
38
|
+
<item oor:path="/org.openoffice.Office.Common/Security/Scripting"><prop oor:name="DisableActiveContent" oor:op="fuse"><value>true</value></prop></item>
|
|
39
|
+
<item oor:path="/org.openoffice.Office.Common/Security/Scripting"><prop oor:name="BlockUntrustedRefererLinks" oor:op="fuse"><value>true</value></prop></item>
|
|
40
|
+
<item oor:path="/org.openoffice.Office.Writer/Content/Update"><prop oor:name="Link" oor:op="fuse"><value>2</value></prop></item>
|
|
41
|
+
<item oor:path="/org.openoffice.Office.Calc/Content/Update"><prop oor:name="Link" oor:op="fuse"><value>2</value></prop></item>
|
|
42
|
+
<item oor:path="/org.openoffice.Office.Impress/Content/Update"><prop oor:name="Link" oor:op="fuse"><value>2</value></prop></item>
|
|
43
|
+
<item oor:path="/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']"><prop oor:name="Enabled" oor:op="fuse"><value>false</value></prop></item>
|
|
44
|
+
</oor:items>""",
|
|
45
|
+
encoding="utf-8",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class _WindowsJob:
|
|
50
|
+
"""Contain descendants before the suspended launcher can create soffice.bin."""
|
|
51
|
+
|
|
52
|
+
def __init__(self):
|
|
53
|
+
import ctypes
|
|
54
|
+
from ctypes import wintypes
|
|
55
|
+
|
|
56
|
+
self.ctypes = ctypes
|
|
57
|
+
self.kernel = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
58
|
+
self.kernel.CreateJobObjectW.argtypes = [ctypes.c_void_p, wintypes.LPCWSTR]
|
|
59
|
+
self.kernel.CreateJobObjectW.restype = wintypes.HANDLE
|
|
60
|
+
self.kernel.SetInformationJobObject.argtypes = [
|
|
61
|
+
wintypes.HANDLE,
|
|
62
|
+
ctypes.c_int,
|
|
63
|
+
ctypes.c_void_p,
|
|
64
|
+
wintypes.DWORD,
|
|
65
|
+
]
|
|
66
|
+
self.kernel.AssignProcessToJobObject.argtypes = [
|
|
67
|
+
wintypes.HANDLE,
|
|
68
|
+
wintypes.HANDLE,
|
|
69
|
+
]
|
|
70
|
+
self.kernel.TerminateJobObject.argtypes = [wintypes.HANDLE, wintypes.UINT]
|
|
71
|
+
self.kernel.QueryInformationJobObject.argtypes = [
|
|
72
|
+
wintypes.HANDLE,
|
|
73
|
+
ctypes.c_int,
|
|
74
|
+
ctypes.c_void_p,
|
|
75
|
+
wintypes.DWORD,
|
|
76
|
+
ctypes.c_void_p,
|
|
77
|
+
]
|
|
78
|
+
self.kernel.CloseHandle.argtypes = [wintypes.HANDLE]
|
|
79
|
+
|
|
80
|
+
class Basic(ctypes.Structure):
|
|
81
|
+
_fields_ = [
|
|
82
|
+
("time_process", ctypes.c_int64),
|
|
83
|
+
("time_job", ctypes.c_int64),
|
|
84
|
+
("flags", wintypes.DWORD),
|
|
85
|
+
("min_ws", ctypes.c_size_t),
|
|
86
|
+
("max_ws", ctypes.c_size_t),
|
|
87
|
+
("active", wintypes.DWORD),
|
|
88
|
+
("affinity", ctypes.c_size_t),
|
|
89
|
+
("priority", wintypes.DWORD),
|
|
90
|
+
("scheduling", wintypes.DWORD),
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
class Extended(ctypes.Structure):
|
|
94
|
+
_fields_ = [
|
|
95
|
+
("basic", Basic),
|
|
96
|
+
("io", ctypes.c_uint64 * 6),
|
|
97
|
+
("process_memory", ctypes.c_size_t),
|
|
98
|
+
("job_memory", ctypes.c_size_t),
|
|
99
|
+
("peak_process", ctypes.c_size_t),
|
|
100
|
+
("peak_job", ctypes.c_size_t),
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
self.handle = self.kernel.CreateJobObjectW(None, None)
|
|
104
|
+
info = Extended()
|
|
105
|
+
info.basic.flags = 0x2000 # JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
|
|
106
|
+
if not self.handle or not self.kernel.SetInformationJobObject(
|
|
107
|
+
self.handle, 9, ctypes.byref(info), ctypes.sizeof(info)
|
|
108
|
+
):
|
|
109
|
+
self.close()
|
|
110
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
111
|
+
|
|
112
|
+
def attach(self, child):
|
|
113
|
+
if not self.kernel.AssignProcessToJobObject(self.handle, int(child._handle)):
|
|
114
|
+
raise self.ctypes.WinError(self.ctypes.get_last_error())
|
|
115
|
+
resume = self.ctypes.WinDLL("ntdll").NtResumeProcess
|
|
116
|
+
resume.argtypes = [self.ctypes.c_void_p]
|
|
117
|
+
resume.restype = self.ctypes.c_long
|
|
118
|
+
if resume(int(child._handle)) != 0:
|
|
119
|
+
raise OSError("Could not resume LibreOffice")
|
|
120
|
+
|
|
121
|
+
def kill(self):
|
|
122
|
+
if not self.kernel.TerminateJobObject(self.handle, 1):
|
|
123
|
+
raise self.ctypes.WinError(self.ctypes.get_last_error())
|
|
124
|
+
# Termination is asynchronous; descendants must release cwd/profile/logs
|
|
125
|
+
# before TemporaryDirectory can remove them on Windows.
|
|
126
|
+
accounting = (self.ctypes.c_byte * 48)()
|
|
127
|
+
deadline = time.monotonic() + 10
|
|
128
|
+
while True:
|
|
129
|
+
if not self.kernel.QueryInformationJobObject(
|
|
130
|
+
self.handle, 1, self.ctypes.byref(accounting), 48, None
|
|
131
|
+
):
|
|
132
|
+
raise self.ctypes.WinError(self.ctypes.get_last_error())
|
|
133
|
+
active = self.ctypes.c_uint32.from_buffer(accounting, 40).value
|
|
134
|
+
if not active:
|
|
135
|
+
return
|
|
136
|
+
if time.monotonic() >= deadline:
|
|
137
|
+
raise OSError("LibreOffice process tree did not terminate")
|
|
138
|
+
time.sleep(0.01)
|
|
139
|
+
|
|
140
|
+
def close(self):
|
|
141
|
+
if self.handle:
|
|
142
|
+
self.kernel.CloseHandle(self.handle)
|
|
143
|
+
self.handle = None
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _kill_tree(child: subprocess.Popen, job=None) -> None:
|
|
147
|
+
if os.name == "nt":
|
|
148
|
+
job.kill()
|
|
149
|
+
else:
|
|
150
|
+
try:
|
|
151
|
+
os.killpg(child.pid, signal.SIGKILL)
|
|
152
|
+
except ProcessLookupError:
|
|
153
|
+
pass
|
|
154
|
+
if child.poll() is None:
|
|
155
|
+
child.kill()
|
|
156
|
+
child.wait(timeout=10)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
_VERSION = re.compile(r"LibreOffice\s+(\d+(?:\.\d+)+)")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _command(executable: str, profile: Path) -> list[str]:
|
|
163
|
+
"""Headless soffice invocation bound to an isolated, hardened profile."""
|
|
164
|
+
return [
|
|
165
|
+
executable,
|
|
166
|
+
"-env:UserInstallation=" + profile.as_uri(),
|
|
167
|
+
"--headless",
|
|
168
|
+
"--norestore",
|
|
169
|
+
"--nodefault",
|
|
170
|
+
"--nofirststartwizard",
|
|
171
|
+
"--nolockcheck",
|
|
172
|
+
]
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _execute(args: list[str], *, cwd: Path, timeout_s: float, output: Path) -> str:
|
|
176
|
+
returncode, text = _run(
|
|
177
|
+
args, cwd=cwd, timeout_s=timeout_s, output=output, label="LibreOffice"
|
|
178
|
+
)
|
|
179
|
+
if returncode:
|
|
180
|
+
raise OSError("LibreOffice failed")
|
|
181
|
+
return text
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _run(
|
|
185
|
+
args: list[str], *, cwd: Path, timeout_s: float, output: Path, label: str
|
|
186
|
+
) -> tuple[int, str]:
|
|
187
|
+
try:
|
|
188
|
+
return _capture_status(
|
|
189
|
+
args, cwd=cwd, timeout_s=timeout_s, output=output, label=label
|
|
190
|
+
)
|
|
191
|
+
finally:
|
|
192
|
+
# Windows can signal process death just before closing its inherited
|
|
193
|
+
# file handles. Retry only this owned capture, with a bounded deadline.
|
|
194
|
+
deadline = time.monotonic() + 2
|
|
195
|
+
while True:
|
|
196
|
+
try:
|
|
197
|
+
output.unlink(missing_ok=True)
|
|
198
|
+
break
|
|
199
|
+
except PermissionError:
|
|
200
|
+
if time.monotonic() >= deadline:
|
|
201
|
+
raise
|
|
202
|
+
time.sleep(0.02)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _capture(args: list[str], *, cwd: Path, timeout_s: float, output: Path) -> str:
|
|
206
|
+
"""Pre-tools shape kept for existing callers: raise on a non-zero exit."""
|
|
207
|
+
returncode, text = _capture_status(
|
|
208
|
+
args, cwd=cwd, timeout_s=timeout_s, output=output, label="LibreOffice"
|
|
209
|
+
)
|
|
210
|
+
if returncode:
|
|
211
|
+
raise OSError("LibreOffice failed")
|
|
212
|
+
return text
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _capture_status(
|
|
216
|
+
args: list[str], *, cwd: Path, timeout_s: float, output: Path, label: str
|
|
217
|
+
) -> tuple[int, str]:
|
|
218
|
+
"""Bound both process lifetime and captured output without inherited pipe readers."""
|
|
219
|
+
with output.open("w+b") as stream:
|
|
220
|
+
job = _WindowsJob() if os.name == "nt" else None
|
|
221
|
+
try:
|
|
222
|
+
child = subprocess.Popen(
|
|
223
|
+
args,
|
|
224
|
+
cwd=cwd,
|
|
225
|
+
stdin=subprocess.DEVNULL,
|
|
226
|
+
stdout=stream,
|
|
227
|
+
stderr=stream,
|
|
228
|
+
env={k: v for k, v in os.environ.items() if k.upper() in _ENV},
|
|
229
|
+
start_new_session=os.name != "nt",
|
|
230
|
+
creationflags=0x08000004 if job else 0, # NO_WINDOW | SUSPENDED
|
|
231
|
+
)
|
|
232
|
+
try:
|
|
233
|
+
if job:
|
|
234
|
+
job.attach(child)
|
|
235
|
+
deadline = time.monotonic() + timeout_s
|
|
236
|
+
while child.poll() is None:
|
|
237
|
+
if time.monotonic() >= deadline or output.stat().st_size > 65536:
|
|
238
|
+
raise TimeoutError(f"{label} deadline/output limit exceeded")
|
|
239
|
+
time.sleep(0.02)
|
|
240
|
+
# A fast child can exit before any poll sees the file grow.
|
|
241
|
+
if output.stat().st_size > 65536:
|
|
242
|
+
raise TimeoutError(f"{label} deadline/output limit exceeded")
|
|
243
|
+
returncode = child.returncode
|
|
244
|
+
finally:
|
|
245
|
+
_kill_tree(child, job)
|
|
246
|
+
finally:
|
|
247
|
+
if job:
|
|
248
|
+
job.close()
|
|
249
|
+
if "child" in locals() and child.poll() is not None:
|
|
250
|
+
child._handle.Close()
|
|
251
|
+
stream.seek(0)
|
|
252
|
+
return returncode, stream.read(65536).decode("utf-8", errors="replace")
|
|
@@ -42,8 +42,10 @@ from .converters import (
|
|
|
42
42
|
ContentUnderstandingConverter,
|
|
43
43
|
CsvConverter,
|
|
44
44
|
HwpConverter,
|
|
45
|
+
LibreOfficeConverter,
|
|
45
46
|
)
|
|
46
47
|
|
|
48
|
+
from .converters._exiftool import _discover_exiftool
|
|
47
49
|
from ._base_converter import DocumentConverter, DocumentConverterResult
|
|
48
50
|
|
|
49
51
|
from ._exceptions import (
|
|
@@ -140,7 +142,11 @@ class ConverterRegistration:
|
|
|
140
142
|
|
|
141
143
|
class MarkItDown:
|
|
142
144
|
"""(In preview) An extremely simple text-based document reader, suitable for LLM use.
|
|
143
|
-
This reader will convert common file-types or webpages to Markdown.
|
|
145
|
+
This reader will convert common file-types or webpages to Markdown.
|
|
146
|
+
|
|
147
|
+
Set libreoffice_path (or SOFFICE_PATH) to opt into local legacy conversion.
|
|
148
|
+
libreoffice_timeout limits LibreOffice execution to 60 seconds by default.
|
|
149
|
+
"""
|
|
144
150
|
|
|
145
151
|
def __init__(
|
|
146
152
|
self,
|
|
@@ -204,29 +210,9 @@ class MarkItDown:
|
|
|
204
210
|
self._exiftool_path = kwargs.get("exiftool_path")
|
|
205
211
|
self._style_map = kwargs.get("style_map")
|
|
206
212
|
|
|
213
|
+
# EXIFTOOL_PATH, else exiftool on PATH in a well-known directory
|
|
207
214
|
if self._exiftool_path is None:
|
|
208
|
-
self._exiftool_path =
|
|
209
|
-
|
|
210
|
-
# Still none? Check well-known paths
|
|
211
|
-
if self._exiftool_path is None:
|
|
212
|
-
candidate = shutil.which("exiftool")
|
|
213
|
-
if candidate:
|
|
214
|
-
candidate = os.path.abspath(candidate)
|
|
215
|
-
if any(
|
|
216
|
-
d == os.path.dirname(candidate)
|
|
217
|
-
for d in [
|
|
218
|
-
"/usr/bin",
|
|
219
|
-
"/usr/local/bin",
|
|
220
|
-
"/opt",
|
|
221
|
-
"/opt/bin",
|
|
222
|
-
"/opt/local/bin",
|
|
223
|
-
"/opt/homebrew/bin",
|
|
224
|
-
"C:\\Windows\\System32",
|
|
225
|
-
"C:\\Program Files",
|
|
226
|
-
"C:\\Program Files (x86)",
|
|
227
|
-
]
|
|
228
|
-
):
|
|
229
|
-
self._exiftool_path = candidate
|
|
215
|
+
self._exiftool_path = _discover_exiftool()
|
|
230
216
|
|
|
231
217
|
# Register converters for successful browsing operations
|
|
232
218
|
# Later registrations are tried first / take higher priority than earlier registrations
|
|
@@ -256,6 +242,16 @@ class MarkItDown:
|
|
|
256
242
|
self.register_converter(EpubConverter())
|
|
257
243
|
self.register_converter(CsvConverter())
|
|
258
244
|
self.register_converter(HwpConverter())
|
|
245
|
+
libreoffice_path = kwargs.get("libreoffice_path") or os.getenv(
|
|
246
|
+
"SOFFICE_PATH"
|
|
247
|
+
)
|
|
248
|
+
if libreoffice_path:
|
|
249
|
+
self.register_converter(
|
|
250
|
+
LibreOfficeConverter(
|
|
251
|
+
libreoffice_path,
|
|
252
|
+
timeout=kwargs.get("libreoffice_timeout", 60),
|
|
253
|
+
)
|
|
254
|
+
)
|
|
259
255
|
|
|
260
256
|
# Register Document Intelligence converter at the top of the stack if endpoint is provided
|
|
261
257
|
docintel_endpoint = kwargs.get("docintel_endpoint")
|
|
@@ -701,7 +697,9 @@ class MarkItDown:
|
|
|
701
697
|
converter=converter, exc_info=sys.exc_info()
|
|
702
698
|
)
|
|
703
699
|
)
|
|
704
|
-
if kwargs.get("extract_media")
|
|
700
|
+
if kwargs.get("extract_media") or isinstance(
|
|
701
|
+
converter, LibreOfficeConverter
|
|
702
|
+
):
|
|
705
703
|
raise FileConversionException(attempts=failed_attempts)
|
|
706
704
|
finally:
|
|
707
705
|
file_stream.seek(cur_pos)
|
|
@@ -28,6 +28,7 @@ from ._cu_converter import (
|
|
|
28
28
|
from ._epub_converter import EpubConverter
|
|
29
29
|
from ._csv_converter import CsvConverter
|
|
30
30
|
from ._hwp_converter import HwpConverter
|
|
31
|
+
from ._libreoffice_converter import LibreOfficeConverter
|
|
31
32
|
|
|
32
33
|
__all__ = [
|
|
33
34
|
"PlainTextConverter",
|
|
@@ -53,4 +54,5 @@ __all__ = [
|
|
|
53
54
|
"EpubConverter",
|
|
54
55
|
"CsvConverter",
|
|
55
56
|
"HwpConverter",
|
|
57
|
+
"LibreOfficeConverter",
|
|
56
58
|
]
|
|
@@ -99,7 +99,9 @@ class AudioConverter(DocumentConverter):
|
|
|
99
99
|
)
|
|
100
100
|
if transcript:
|
|
101
101
|
md_content += "\n\n### Audio Transcript:\n" + transcript
|
|
102
|
-
except MissingDependencyException:
|
|
102
|
+
except (MissingDependencyException, OSError):
|
|
103
|
+
# OSError covers a missing ffmpeg/ffprobe (pydub launches them
|
|
104
|
+
# by name); keep the metadata and skip the transcript.
|
|
103
105
|
pass
|
|
104
106
|
|
|
105
107
|
# Return the result
|