robotframework-markitdown 0.2.1__tar.gz → 0.3.0__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.
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/.github/workflows/publish.yml +19 -0
- robotframework_markitdown-0.3.0/CHANGELOG.md +91 -0
- robotframework_markitdown-0.3.0/PKG-INFO +202 -0
- robotframework_markitdown-0.3.0/README.md +174 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/docs/MarkItDownLibrary.html +1 -1
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/docs/index.html +18 -15
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/pyproject.toml +4 -0
- robotframework_markitdown-0.3.0/src/MarkItDownLibrary/acroform.py +75 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/detect.py +15 -4
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/fields.py +40 -9
- robotframework_markitdown-0.3.0/src/MarkItDownLibrary/guard.py +68 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/library.py +115 -29
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/tables.py +24 -2
- robotframework_markitdown-0.3.0/src/MarkItDownLibrary/version.py +1 -0
- robotframework_markitdown-0.3.0/utest/test_acroform.py +182 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_convert.py +55 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_detect.py +31 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_field_keywords.py +30 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_fields.py +42 -0
- robotframework_markitdown-0.3.0/utest/test_guard.py +59 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_tables.py +10 -0
- robotframework_markitdown-0.2.1/CHANGELOG.md +0 -51
- robotframework_markitdown-0.2.1/PKG-INFO +0 -218
- robotframework_markitdown-0.2.1/README.md +0 -194
- robotframework_markitdown-0.2.1/src/MarkItDownLibrary/acroform.py +0 -15
- robotframework_markitdown-0.2.1/src/MarkItDownLibrary/guard.py +0 -25
- robotframework_markitdown-0.2.1/src/MarkItDownLibrary/version.py +0 -1
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/.gitattributes +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/.gitignore +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/LICENSE +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/docx.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/contract_form_blank.pdf +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/contract_form_filled.pdf +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/contract_text_blank.pdf +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/contract_text_filled.pdf +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/deck.pptx +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/invoice.xlsx +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/page.html +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/fixtures/table.docx +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/html.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/pdf.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/pptx.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/resources/common.resource +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/text_csv.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/atest/xlsx.robot +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/docs/fonts/OFL.txt +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/docs/fonts/bricolage-grotesque.woff2 +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/docs/fonts/fragment-mono.woff2 +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/requirements-dev.lock +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/__init__.py +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/src/MarkItDownLibrary/text.py +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/tools/make_fixtures.py +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/fixtures/page.html +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_assertions.py +0 -0
- {robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/utest/test_text.py +0 -0
{robotframework_markitdown-0.2.1 → robotframework_markitdown-0.3.0}/.github/workflows/publish.yml
RENAMED
|
@@ -8,7 +8,26 @@ permissions:
|
|
|
8
8
|
contents: read
|
|
9
9
|
|
|
10
10
|
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
19
|
+
with:
|
|
20
|
+
persist-credentials: false
|
|
21
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
- run: python -m pip install --upgrade pip
|
|
25
|
+
- run: python -m pip install ".[acroform]" --group dev
|
|
26
|
+
- run: python -m pytest
|
|
27
|
+
- run: python -m robot atest
|
|
28
|
+
|
|
11
29
|
build:
|
|
30
|
+
needs: test
|
|
12
31
|
runs-on: ubuntu-latest
|
|
13
32
|
steps:
|
|
14
33
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## 0.3.0 - 2026-12-06
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- `Field Should Be Blank` and `Field Should Be` take `occurrence`. All three
|
|
11
|
+
field keywords take `ignore_case`; an empty `separator` is refused.
|
|
12
|
+
- Failure messages cut long found values at 120 characters.
|
|
13
|
+
- Table parsing is cached per document and about 3 times faster uncached; a
|
|
14
|
+
repeated `Get Table Cell` on a 437 KB table went from 54 ms to 0.05 ms.
|
|
15
|
+
- A size cap above 128 MiB lifts MarkItDown's PDF input limit too.
|
|
16
|
+
- `Get Sheet Names` and `Get Sheet As Table` accept only `.xlsx` and `.xls`.
|
|
17
|
+
- Python 3.10 to 3.13 classifiers, and a test run on Python 3.10 to 3.14 in the
|
|
18
|
+
release workflow before publishing.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `Get Pdf Field Names`, `Get Pdf Field Value` and `Pdf Field Should Be`.
|
|
23
|
+
- With `next_line=True`, a `Label:` line with nothing after it takes the next
|
|
24
|
+
non-empty line, so a value on the following line no longer reads as blank.
|
|
25
|
+
- `Pdf Field Should Be Blank` reads a checkbox that is off, a missing value and
|
|
26
|
+
a value of spaces as blank, finds nested fields by qualified or leaf name,
|
|
27
|
+
and warns when it falls back to the converted text. Encrypted or unreadable
|
|
28
|
+
PDFs fail with a `ValueError`.
|
|
29
|
+
- Network paths, any `scheme://` string and Office files that expand past 10
|
|
30
|
+
times the size cap are refused. A `.pdf`, `.docx`, `.xlsx` or `.pptx` whose
|
|
31
|
+
bytes are not that format fails with a clear message.
|
|
32
|
+
- A table with repeated column names keeps every column, as `Name`, `Name_2`.
|
|
33
|
+
- `Convert Bytes To Markdown` trims and lower-cases the extension and refuses an
|
|
34
|
+
empty one. The sniffing switch is per conversion context and fails with a
|
|
35
|
+
clear message if MarkItDown drops its detector.
|
|
36
|
+
- The README dev setup installs the dev group, and README and the site state the
|
|
37
|
+
URI, size and field rules.
|
|
38
|
+
|
|
39
|
+
## 0.2.2 - 2026-12-06
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- The README installs from PyPI and is shorter. The PyPI page shows it.
|
|
44
|
+
- `PLAN.md` records the sniffing shortcut and the Python 3.10 to 3.14 range.
|
|
45
|
+
|
|
46
|
+
## 0.2.1 - 2026-12-06
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Conversion of `.pdf`, `.docx`, `.xlsx` and `.pptx` files trusts the file
|
|
51
|
+
extension and skips MarkItDown's content sniffing. Small PDFs convert in
|
|
52
|
+
about 2 ms instead of about 7 ms. A file with a wrong extension for these
|
|
53
|
+
formats is no longer re-identified. This swaps a private MarkItDown
|
|
54
|
+
attribute, so recheck it on each MarkItDown upgrade.
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- README sections "Why use it" and "Measurements", and the project site in
|
|
59
|
+
`docs/`.
|
|
60
|
+
|
|
61
|
+
## 0.2.0 - 2026-12-06
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
- `Set Pdf Limits`, which sets the PDF character limits of MarkItDown 0.1.10.
|
|
66
|
+
- `occurrence` argument of `Get Field Value`, for a label that repeats.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
|
|
70
|
+
- MarkItDown is pinned to 0.1.10 (was 0.1.9). Its PDF budgets now apply: a PDF
|
|
71
|
+
over a limit fails with a resource limit error.
|
|
72
|
+
- The pinned dependencies are updated and re-vetted; see `PLAN.md` section 5.
|
|
73
|
+
- Development status is Alpha.
|
|
74
|
+
|
|
75
|
+
## 0.1.0 - 2026-11-20
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- Convert keywords, `Convert File To Markdown` and `Convert Bytes To Markdown`,
|
|
80
|
+
that run offline with a size cap.
|
|
81
|
+
- Text assertions: `Markdown Should Contain`, `Markdown Should Not Contain` and
|
|
82
|
+
`Markdown Should Match Regexp`.
|
|
83
|
+
- Table keywords: `Get Tables From Markdown`, `Get Table From Markdown` and
|
|
84
|
+
`Get Table Cell`.
|
|
85
|
+
- Sheet keywords for XLSX: `Get Sheet Names` and `Get Sheet As Table`.
|
|
86
|
+
- Field keywords: `Get Field Value`, `Field Should Be` and `Field Should Be Blank`,
|
|
87
|
+
with an opt-in next-line rule.
|
|
88
|
+
- `Pdf Field Should Be Blank`, which reads AcroForm values through the optional
|
|
89
|
+
pypdf reader (`acroform` extra) and falls back to the converted text.
|
|
90
|
+
- `Set Converter Options` for the size cap and data URI handling.
|
|
91
|
+
- Libdoc HTML keyword docs in `docs/`.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: robotframework-markitdown
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Robot Framework library that converts documents to Markdown with MarkItDown, offline, and checks their text
|
|
5
|
+
Project-URL: Source, https://github.com/ai94iq/robotframework-markitdown
|
|
6
|
+
Project-URL: Issues, https://github.com/ai94iq/robotframework-markitdown/issues
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: docx,markdown,markitdown,pdf,robotframework,testing,xlsx
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Framework :: Robot Framework
|
|
12
|
+
Classifier: Framework :: Robot Framework :: Library
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Requires-Python: <3.15,>=3.10
|
|
23
|
+
Requires-Dist: markitdown[docx,pdf,pptx,xlsx]==0.1.10
|
|
24
|
+
Requires-Dist: robotframework==7.5.1
|
|
25
|
+
Provides-Extra: acroform
|
|
26
|
+
Requires-Dist: pypdf==7.2.0; extra == 'acroform'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# robotframework-markitdown
|
|
30
|
+
|
|
31
|
+
Robot Framework keywords that read PDF, DOCX, XLSX, PPTX and HTML files as
|
|
32
|
+
Markdown, then check their text, tables and field values. Conversion uses
|
|
33
|
+
Microsoft MarkItDown and runs offline.
|
|
34
|
+
|
|
35
|
+
Project site: <https://ai94iq.github.io/robotframework-markitdown/>
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Requires Python 3.10 to 3.14. pip installs Robot Framework 7.5.1 and
|
|
40
|
+
MarkItDown 0.1.10.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pip install robotframework-markitdown
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For AcroForm (fillable PDF) field values, add the `acroform` extra, which
|
|
47
|
+
installs pypdf:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
pip install "robotframework-markitdown[acroform]"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Package page: <https://pypi.org/project/robotframework-markitdown/>
|
|
54
|
+
|
|
55
|
+
## Example
|
|
56
|
+
|
|
57
|
+
```robotframework
|
|
58
|
+
*** Settings ***
|
|
59
|
+
Library RequestsLibrary
|
|
60
|
+
Library MarkItDownLibrary
|
|
61
|
+
|
|
62
|
+
*** Test Cases ***
|
|
63
|
+
New Contract Has No Total Amount
|
|
64
|
+
${resp}= GET On Session api /contracts/${id}/pdf
|
|
65
|
+
${md}= Convert Bytes To Markdown ${resp.content} .pdf
|
|
66
|
+
Markdown Should Contain ${md} Onboarding Contract
|
|
67
|
+
Field Should Be Blank ${md} Total Amount
|
|
68
|
+
|
|
69
|
+
Invoice Sheet Totals
|
|
70
|
+
${rows}= Get Sheet As Table ${OUTPUT DIR}/invoice.xlsx Summary
|
|
71
|
+
Should Be Equal ${rows}[0][Total] 0
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Keywords
|
|
75
|
+
|
|
76
|
+
| Keyword | What it does |
|
|
77
|
+
|---|---|
|
|
78
|
+
| Convert File To Markdown | Converts a local file and returns the Markdown. |
|
|
79
|
+
| Convert Bytes To Markdown | Converts bytes, such as a response body. |
|
|
80
|
+
| Markdown Should Contain | Passes when the text is in the Markdown. |
|
|
81
|
+
| Markdown Should Not Contain | Passes when the text is not in the Markdown. |
|
|
82
|
+
| Markdown Should Match Regexp | Passes when a multiline regexp matches. |
|
|
83
|
+
| Get Tables From Markdown | Returns every pipe table as rows of cells. |
|
|
84
|
+
| Get Table From Markdown | Returns one table as rows keyed by its header. |
|
|
85
|
+
| Get Table Cell | Returns one cell by row number and column. |
|
|
86
|
+
| Get Field Value | Returns a labelled field's value, or `""` when blank. |
|
|
87
|
+
| Field Should Be | Passes when a labelled field has the expected value. |
|
|
88
|
+
| Field Should Be Blank | Passes when a labelled field is found and empty. |
|
|
89
|
+
| Pdf Field Should Be Blank | Checks a PDF form field, or the text when there is none. |
|
|
90
|
+
| Get Pdf Field Names | Returns the names of a PDF's form fields. |
|
|
91
|
+
| Get Pdf Field Value | Returns one PDF form field's value. |
|
|
92
|
+
| Pdf Field Should Be | Passes when a PDF form field has the expected value. |
|
|
93
|
+
| Get Sheet Names | Returns the XLSX sheet names in workbook order. |
|
|
94
|
+
| Get Sheet As Table | Returns one XLSX sheet as rows keyed by header. |
|
|
95
|
+
| Set Converter Options | Sets the size cap and whether data URIs are kept. |
|
|
96
|
+
| Set Pdf Limits | Sets the PDF character limits MarkItDown enforces. |
|
|
97
|
+
|
|
98
|
+
Full keyword docs:
|
|
99
|
+
[MarkItDownLibrary.html](https://github.com/ai94iq/robotframework-markitdown/blob/main/docs/MarkItDownLibrary.html)
|
|
100
|
+
|
|
101
|
+
## Offline and limits
|
|
102
|
+
|
|
103
|
+
- Only local files and bytes are converted, through MarkItDown's file and
|
|
104
|
+
stream entry points. String paths that are URIs (`file:`, `http:`, `https:`,
|
|
105
|
+
`data:`, or any `scheme://`) and network paths (`\\host\share`, `//host`)
|
|
106
|
+
are refused; any other path must be an existing regular file.
|
|
107
|
+
- Plugins, LLM and Azure features are off.
|
|
108
|
+
- The default size cap is 50,000,000 bytes; `Set Converter Options` changes it.
|
|
109
|
+
Each call replaces both its settings. Office files (`.docx`, `.xlsx`,
|
|
110
|
+
`.pptx`) that expand past 10 times the cap are refused. Other limits come
|
|
111
|
+
from MarkItDown.
|
|
112
|
+
- Any other format that MarkItDown's built-in converters read also converts,
|
|
113
|
+
such as `.csv`, `.txt` and `.zip`; the `Get Sheet` keywords accept only
|
|
114
|
+
`.xlsx` and `.xls`. A cap above MarkItDown's own 128 MiB PDF input limit
|
|
115
|
+
raises that limit too. XLSX cells that pandas writes as `NaN` or `12.0` are
|
|
116
|
+
cleaned only by the `Get Sheet` keywords, not by the field keywords.
|
|
117
|
+
- Embedded data URIs are dropped unless `keep_data_uris` is set.
|
|
118
|
+
- A PDF over a character limit fails with a resource limit error. Defaults:
|
|
119
|
+
100,000 characters a page, 2,000,000 in total, 10,000,000 in the output.
|
|
120
|
+
`Set Pdf Limits` changes them; a call with no arguments restores them.
|
|
121
|
+
- Images convert only when `exiftool` is on `PATH` or named in
|
|
122
|
+
`EXIFTOOL_PATH`; otherwise they convert to an empty string.
|
|
123
|
+
- For `.pdf`, `.docx`, `.xlsx` and `.pptx` the library trusts the file
|
|
124
|
+
extension and skips MarkItDown's content sniffing. A file with a wrong
|
|
125
|
+
extension for these formats fails with a message that it is not a PDF or
|
|
126
|
+
not an Office file. This swaps a private MarkItDown attribute, so recheck it
|
|
127
|
+
on each MarkItDown upgrade.
|
|
128
|
+
|
|
129
|
+
## Field lookup
|
|
130
|
+
|
|
131
|
+
`Get Field Value`, `Field Should Be` and `Field Should Be Blank` find a label in
|
|
132
|
+
this order:
|
|
133
|
+
|
|
134
|
+
1. A table row whose first cell is the label; the value is the second cell.
|
|
135
|
+
2. A line that starts with the label and the separator (`:` by default); the
|
|
136
|
+
value is the text after it.
|
|
137
|
+
3. Only with `next_line=True`: a line that is the label alone; the value is the
|
|
138
|
+
next non-empty line, or blank if that line ends with the separator or the
|
|
139
|
+
label is last.
|
|
140
|
+
|
|
141
|
+
With `next_line=True`, `Label:` with nothing after it on its line also takes
|
|
142
|
+
the next non-empty line, unless that line ends with the separator.
|
|
143
|
+
Labels match exactly, including case, unless `ignore_case=True`. An empty
|
|
144
|
+
`separator` is refused. A value that ends with the separator reads as another
|
|
145
|
+
label in `next_line` mode. Failure messages cut long values at 120 characters.
|
|
146
|
+
|
|
147
|
+
`occurrence` picks the nth match (from 1) when a label repeats, on
|
|
148
|
+
`Get Field Value`, `Field Should Be` and `Field Should Be Blank`; matches are
|
|
149
|
+
counted within the first lookup step that finds any. Past the last match it
|
|
150
|
+
fails and names the count. A label that is not found fails and shows
|
|
151
|
+
the closest lines.
|
|
152
|
+
|
|
153
|
+
`Get Pdf Field Names`, `Get Pdf Field Value` and `Pdf Field Should Be` read the
|
|
154
|
+
form directly and need the `acroform` extra; a missing extra or a PDF without a
|
|
155
|
+
form fails with a message that says so.
|
|
156
|
+
|
|
157
|
+
`Pdf Field Should Be Blank` first looks for an AcroForm field with that name
|
|
158
|
+
(needs pypdf): the qualified name (`form1.Total`) or the leaf name when one
|
|
159
|
+
field has it. A checkbox or radio that is off, a missing value and a value of
|
|
160
|
+
spaces read as blank. If no field matches, or without pypdf, the check runs on
|
|
161
|
+
the converted text with the rules above and a warning says so; a text layer
|
|
162
|
+
can read blank where the form holds a value. An encrypted or unreadable PDF
|
|
163
|
+
fails with a `ValueError` naming the file.
|
|
164
|
+
|
|
165
|
+
## Measurements
|
|
166
|
+
|
|
167
|
+
Every number is from a run on 2026-12-06 (Windows, Python 3.13, MarkItDown
|
|
168
|
+
0.1.10, pypdf 7.2.0). The plain read is pypdf `extract_text` over all pages.
|
|
169
|
+
Medians of 30 runs for the fixtures and 3 for the IRS forms.
|
|
170
|
+
|
|
171
|
+
| Check | Plain read | This library |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| Blank or filled, 4 fixtures in `atest/fixtures` | 3 of 4 | 4 of 4 |
|
|
174
|
+
| `contract_form_filled.pdf` (field value 250) | reads blank | reads filled |
|
|
175
|
+
| Conversion time, one-line fixtures | 0.52-0.53 ms | 2.11-2.20 ms |
|
|
176
|
+
| Conversion time, IRS W-9 (6 pages) | 55 ms | 2861 ms |
|
|
177
|
+
| Conversion time, IRS W-4 (5 pages) | 148 ms | 6912 ms |
|
|
178
|
+
|
|
179
|
+
The measurements support one claim: when a value lives in a form field, the
|
|
180
|
+
plain read can say blank and the library reads the value. They do not show a
|
|
181
|
+
size win (the Markdown is 1 to 2 characters longer on the one-line files) or a
|
|
182
|
+
speed win (the library is about 4 times slower on small files and much slower
|
|
183
|
+
on forms). Tokens were not measured. Four fixtures and two forms are a small
|
|
184
|
+
sample, and the forms have no known values beyond the one the test wrote.
|
|
185
|
+
|
|
186
|
+
## Development
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
uv pip install -e ".[acroform]" --group dev
|
|
190
|
+
python -m pytest
|
|
191
|
+
robot atest
|
|
192
|
+
pyright
|
|
193
|
+
python -m robot.libdoc MarkItDownLibrary docs/MarkItDownLibrary.html
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The release workflow runs the tests on Python 3.10 to 3.14 before it publishes.
|
|
197
|
+
`pytest` runs `utest/`, `robot atest` runs `atest/`, `pyright` checks `src`,
|
|
198
|
+
`utest` and `tools` in strict mode, and the last command rebuilds `docs/`.
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
MIT.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# robotframework-markitdown
|
|
2
|
+
|
|
3
|
+
Robot Framework keywords that read PDF, DOCX, XLSX, PPTX and HTML files as
|
|
4
|
+
Markdown, then check their text, tables and field values. Conversion uses
|
|
5
|
+
Microsoft MarkItDown and runs offline.
|
|
6
|
+
|
|
7
|
+
Project site: <https://ai94iq.github.io/robotframework-markitdown/>
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Requires Python 3.10 to 3.14. pip installs Robot Framework 7.5.1 and
|
|
12
|
+
MarkItDown 0.1.10.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install robotframework-markitdown
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For AcroForm (fillable PDF) field values, add the `acroform` extra, which
|
|
19
|
+
installs pypdf:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install "robotframework-markitdown[acroform]"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Package page: <https://pypi.org/project/robotframework-markitdown/>
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
```robotframework
|
|
30
|
+
*** Settings ***
|
|
31
|
+
Library RequestsLibrary
|
|
32
|
+
Library MarkItDownLibrary
|
|
33
|
+
|
|
34
|
+
*** Test Cases ***
|
|
35
|
+
New Contract Has No Total Amount
|
|
36
|
+
${resp}= GET On Session api /contracts/${id}/pdf
|
|
37
|
+
${md}= Convert Bytes To Markdown ${resp.content} .pdf
|
|
38
|
+
Markdown Should Contain ${md} Onboarding Contract
|
|
39
|
+
Field Should Be Blank ${md} Total Amount
|
|
40
|
+
|
|
41
|
+
Invoice Sheet Totals
|
|
42
|
+
${rows}= Get Sheet As Table ${OUTPUT DIR}/invoice.xlsx Summary
|
|
43
|
+
Should Be Equal ${rows}[0][Total] 0
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Keywords
|
|
47
|
+
|
|
48
|
+
| Keyword | What it does |
|
|
49
|
+
|---|---|
|
|
50
|
+
| Convert File To Markdown | Converts a local file and returns the Markdown. |
|
|
51
|
+
| Convert Bytes To Markdown | Converts bytes, such as a response body. |
|
|
52
|
+
| Markdown Should Contain | Passes when the text is in the Markdown. |
|
|
53
|
+
| Markdown Should Not Contain | Passes when the text is not in the Markdown. |
|
|
54
|
+
| Markdown Should Match Regexp | Passes when a multiline regexp matches. |
|
|
55
|
+
| Get Tables From Markdown | Returns every pipe table as rows of cells. |
|
|
56
|
+
| Get Table From Markdown | Returns one table as rows keyed by its header. |
|
|
57
|
+
| Get Table Cell | Returns one cell by row number and column. |
|
|
58
|
+
| Get Field Value | Returns a labelled field's value, or `""` when blank. |
|
|
59
|
+
| Field Should Be | Passes when a labelled field has the expected value. |
|
|
60
|
+
| Field Should Be Blank | Passes when a labelled field is found and empty. |
|
|
61
|
+
| Pdf Field Should Be Blank | Checks a PDF form field, or the text when there is none. |
|
|
62
|
+
| Get Pdf Field Names | Returns the names of a PDF's form fields. |
|
|
63
|
+
| Get Pdf Field Value | Returns one PDF form field's value. |
|
|
64
|
+
| Pdf Field Should Be | Passes when a PDF form field has the expected value. |
|
|
65
|
+
| Get Sheet Names | Returns the XLSX sheet names in workbook order. |
|
|
66
|
+
| Get Sheet As Table | Returns one XLSX sheet as rows keyed by header. |
|
|
67
|
+
| Set Converter Options | Sets the size cap and whether data URIs are kept. |
|
|
68
|
+
| Set Pdf Limits | Sets the PDF character limits MarkItDown enforces. |
|
|
69
|
+
|
|
70
|
+
Full keyword docs:
|
|
71
|
+
[MarkItDownLibrary.html](https://github.com/ai94iq/robotframework-markitdown/blob/main/docs/MarkItDownLibrary.html)
|
|
72
|
+
|
|
73
|
+
## Offline and limits
|
|
74
|
+
|
|
75
|
+
- Only local files and bytes are converted, through MarkItDown's file and
|
|
76
|
+
stream entry points. String paths that are URIs (`file:`, `http:`, `https:`,
|
|
77
|
+
`data:`, or any `scheme://`) and network paths (`\\host\share`, `//host`)
|
|
78
|
+
are refused; any other path must be an existing regular file.
|
|
79
|
+
- Plugins, LLM and Azure features are off.
|
|
80
|
+
- The default size cap is 50,000,000 bytes; `Set Converter Options` changes it.
|
|
81
|
+
Each call replaces both its settings. Office files (`.docx`, `.xlsx`,
|
|
82
|
+
`.pptx`) that expand past 10 times the cap are refused. Other limits come
|
|
83
|
+
from MarkItDown.
|
|
84
|
+
- Any other format that MarkItDown's built-in converters read also converts,
|
|
85
|
+
such as `.csv`, `.txt` and `.zip`; the `Get Sheet` keywords accept only
|
|
86
|
+
`.xlsx` and `.xls`. A cap above MarkItDown's own 128 MiB PDF input limit
|
|
87
|
+
raises that limit too. XLSX cells that pandas writes as `NaN` or `12.0` are
|
|
88
|
+
cleaned only by the `Get Sheet` keywords, not by the field keywords.
|
|
89
|
+
- Embedded data URIs are dropped unless `keep_data_uris` is set.
|
|
90
|
+
- A PDF over a character limit fails with a resource limit error. Defaults:
|
|
91
|
+
100,000 characters a page, 2,000,000 in total, 10,000,000 in the output.
|
|
92
|
+
`Set Pdf Limits` changes them; a call with no arguments restores them.
|
|
93
|
+
- Images convert only when `exiftool` is on `PATH` or named in
|
|
94
|
+
`EXIFTOOL_PATH`; otherwise they convert to an empty string.
|
|
95
|
+
- For `.pdf`, `.docx`, `.xlsx` and `.pptx` the library trusts the file
|
|
96
|
+
extension and skips MarkItDown's content sniffing. A file with a wrong
|
|
97
|
+
extension for these formats fails with a message that it is not a PDF or
|
|
98
|
+
not an Office file. This swaps a private MarkItDown attribute, so recheck it
|
|
99
|
+
on each MarkItDown upgrade.
|
|
100
|
+
|
|
101
|
+
## Field lookup
|
|
102
|
+
|
|
103
|
+
`Get Field Value`, `Field Should Be` and `Field Should Be Blank` find a label in
|
|
104
|
+
this order:
|
|
105
|
+
|
|
106
|
+
1. A table row whose first cell is the label; the value is the second cell.
|
|
107
|
+
2. A line that starts with the label and the separator (`:` by default); the
|
|
108
|
+
value is the text after it.
|
|
109
|
+
3. Only with `next_line=True`: a line that is the label alone; the value is the
|
|
110
|
+
next non-empty line, or blank if that line ends with the separator or the
|
|
111
|
+
label is last.
|
|
112
|
+
|
|
113
|
+
With `next_line=True`, `Label:` with nothing after it on its line also takes
|
|
114
|
+
the next non-empty line, unless that line ends with the separator.
|
|
115
|
+
Labels match exactly, including case, unless `ignore_case=True`. An empty
|
|
116
|
+
`separator` is refused. A value that ends with the separator reads as another
|
|
117
|
+
label in `next_line` mode. Failure messages cut long values at 120 characters.
|
|
118
|
+
|
|
119
|
+
`occurrence` picks the nth match (from 1) when a label repeats, on
|
|
120
|
+
`Get Field Value`, `Field Should Be` and `Field Should Be Blank`; matches are
|
|
121
|
+
counted within the first lookup step that finds any. Past the last match it
|
|
122
|
+
fails and names the count. A label that is not found fails and shows
|
|
123
|
+
the closest lines.
|
|
124
|
+
|
|
125
|
+
`Get Pdf Field Names`, `Get Pdf Field Value` and `Pdf Field Should Be` read the
|
|
126
|
+
form directly and need the `acroform` extra; a missing extra or a PDF without a
|
|
127
|
+
form fails with a message that says so.
|
|
128
|
+
|
|
129
|
+
`Pdf Field Should Be Blank` first looks for an AcroForm field with that name
|
|
130
|
+
(needs pypdf): the qualified name (`form1.Total`) or the leaf name when one
|
|
131
|
+
field has it. A checkbox or radio that is off, a missing value and a value of
|
|
132
|
+
spaces read as blank. If no field matches, or without pypdf, the check runs on
|
|
133
|
+
the converted text with the rules above and a warning says so; a text layer
|
|
134
|
+
can read blank where the form holds a value. An encrypted or unreadable PDF
|
|
135
|
+
fails with a `ValueError` naming the file.
|
|
136
|
+
|
|
137
|
+
## Measurements
|
|
138
|
+
|
|
139
|
+
Every number is from a run on 2026-12-06 (Windows, Python 3.13, MarkItDown
|
|
140
|
+
0.1.10, pypdf 7.2.0). The plain read is pypdf `extract_text` over all pages.
|
|
141
|
+
Medians of 30 runs for the fixtures and 3 for the IRS forms.
|
|
142
|
+
|
|
143
|
+
| Check | Plain read | This library |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| Blank or filled, 4 fixtures in `atest/fixtures` | 3 of 4 | 4 of 4 |
|
|
146
|
+
| `contract_form_filled.pdf` (field value 250) | reads blank | reads filled |
|
|
147
|
+
| Conversion time, one-line fixtures | 0.52-0.53 ms | 2.11-2.20 ms |
|
|
148
|
+
| Conversion time, IRS W-9 (6 pages) | 55 ms | 2861 ms |
|
|
149
|
+
| Conversion time, IRS W-4 (5 pages) | 148 ms | 6912 ms |
|
|
150
|
+
|
|
151
|
+
The measurements support one claim: when a value lives in a form field, the
|
|
152
|
+
plain read can say blank and the library reads the value. They do not show a
|
|
153
|
+
size win (the Markdown is 1 to 2 characters longer on the one-line files) or a
|
|
154
|
+
speed win (the library is about 4 times slower on small files and much slower
|
|
155
|
+
on forms). Tokens were not measured. Four fixtures and two forms are a small
|
|
156
|
+
sample, and the forms have no known values beyond the one the test wrote.
|
|
157
|
+
|
|
158
|
+
## Development
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
uv pip install -e ".[acroform]" --group dev
|
|
162
|
+
python -m pytest
|
|
163
|
+
robot atest
|
|
164
|
+
pyright
|
|
165
|
+
python -m robot.libdoc MarkItDownLibrary docs/MarkItDownLibrary.html
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The release workflow runs the tests on Python 3.10 to 3.14 before it publishes.
|
|
169
|
+
`pytest` runs `utest/`, `robot atest` runs `atest/`, `pyright` checks `src`,
|
|
170
|
+
`utest` and `tools` in strict mode, and the last command rebuilds `docs/`.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT.
|