robotframework-markitdown 0.2.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.
Files changed (47) hide show
  1. robotframework_markitdown-0.2.1/.gitattributes +4 -0
  2. robotframework_markitdown-0.2.1/.github/workflows/publish.yml +39 -0
  3. robotframework_markitdown-0.2.1/.gitignore +14 -0
  4. robotframework_markitdown-0.2.1/CHANGELOG.md +51 -0
  5. robotframework_markitdown-0.2.1/LICENSE +21 -0
  6. robotframework_markitdown-0.2.1/PKG-INFO +218 -0
  7. robotframework_markitdown-0.2.1/README.md +194 -0
  8. robotframework_markitdown-0.2.1/atest/docx.robot +33 -0
  9. robotframework_markitdown-0.2.1/atest/fixtures/contract_form_blank.pdf +81 -0
  10. robotframework_markitdown-0.2.1/atest/fixtures/contract_form_filled.pdf +81 -0
  11. robotframework_markitdown-0.2.1/atest/fixtures/contract_text_blank.pdf +66 -0
  12. robotframework_markitdown-0.2.1/atest/fixtures/contract_text_filled.pdf +66 -0
  13. robotframework_markitdown-0.2.1/atest/fixtures/deck.pptx +0 -0
  14. robotframework_markitdown-0.2.1/atest/fixtures/invoice.xlsx +0 -0
  15. robotframework_markitdown-0.2.1/atest/fixtures/page.html +12 -0
  16. robotframework_markitdown-0.2.1/atest/fixtures/table.docx +0 -0
  17. robotframework_markitdown-0.2.1/atest/html.robot +71 -0
  18. robotframework_markitdown-0.2.1/atest/pdf.robot +53 -0
  19. robotframework_markitdown-0.2.1/atest/pptx.robot +23 -0
  20. robotframework_markitdown-0.2.1/atest/resources/common.resource +9 -0
  21. robotframework_markitdown-0.2.1/atest/text_csv.robot +60 -0
  22. robotframework_markitdown-0.2.1/atest/xlsx.robot +31 -0
  23. robotframework_markitdown-0.2.1/docs/MarkItDownLibrary.html +484 -0
  24. robotframework_markitdown-0.2.1/docs/fonts/OFL.txt +103 -0
  25. robotframework_markitdown-0.2.1/docs/fonts/bricolage-grotesque.woff2 +0 -0
  26. robotframework_markitdown-0.2.1/docs/fonts/fragment-mono.woff2 +0 -0
  27. robotframework_markitdown-0.2.1/docs/index.html +360 -0
  28. robotframework_markitdown-0.2.1/pyproject.toml +57 -0
  29. robotframework_markitdown-0.2.1/requirements-dev.lock +940 -0
  30. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/__init__.py +3 -0
  31. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/acroform.py +15 -0
  32. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/detect.py +31 -0
  33. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/fields.py +54 -0
  34. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/guard.py +25 -0
  35. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/library.py +205 -0
  36. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/tables.py +111 -0
  37. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/text.py +81 -0
  38. robotframework_markitdown-0.2.1/src/MarkItDownLibrary/version.py +1 -0
  39. robotframework_markitdown-0.2.1/tools/make_fixtures.py +187 -0
  40. robotframework_markitdown-0.2.1/utest/fixtures/page.html +1 -0
  41. robotframework_markitdown-0.2.1/utest/test_assertions.py +118 -0
  42. robotframework_markitdown-0.2.1/utest/test_convert.py +118 -0
  43. robotframework_markitdown-0.2.1/utest/test_detect.py +49 -0
  44. robotframework_markitdown-0.2.1/utest/test_field_keywords.py +62 -0
  45. robotframework_markitdown-0.2.1/utest/test_fields.py +98 -0
  46. robotframework_markitdown-0.2.1/utest/test_tables.py +103 -0
  47. robotframework_markitdown-0.2.1/utest/test_text.py +58 -0
@@ -0,0 +1,4 @@
1
+ *.pdf binary
2
+ *.docx binary
3
+ *.xlsx binary
4
+ *.pptx binary
@@ -0,0 +1,39 @@
1
+ name: publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
15
+ with:
16
+ persist-credentials: false
17
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0
18
+ with:
19
+ python-version: "3.13"
20
+ - run: python -m pip install build twine
21
+ - run: python -m build
22
+ - run: python -m twine check dist/*
23
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
24
+ with:
25
+ name: dist
26
+ path: dist/
27
+
28
+ publish:
29
+ needs: build
30
+ runs-on: ubuntu-latest
31
+ environment: pypi
32
+ permissions:
33
+ id-token: write
34
+ steps:
35
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
36
+ with:
37
+ name: dist
38
+ path: dist/
39
+ - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ build/
6
+ dist/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .coverage
10
+ htmlcov/
11
+ output.xml
12
+ log.html
13
+ report.html
14
+ results/
@@ -0,0 +1,51 @@
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.2.1 - 2026-12-06
7
+
8
+ ### Changed
9
+
10
+ - Conversion of `.pdf`, `.docx`, `.xlsx` and `.pptx` files trusts the file
11
+ extension and skips MarkItDown's content sniffing. Small PDFs convert in
12
+ about 2 ms instead of about 7 ms. A file with a wrong extension for these
13
+ formats is no longer re-identified. This swaps a private MarkItDown
14
+ attribute, so recheck it on each MarkItDown upgrade.
15
+
16
+ ### Added
17
+
18
+ - README sections "Why use it" and "Measurements", and the project site in
19
+ `docs/`.
20
+
21
+ ## 0.2.0 - 2026-12-06
22
+
23
+ ### Added
24
+
25
+ - `Set Pdf Limits`, which sets the PDF character limits of MarkItDown 0.1.10.
26
+ - `occurrence` argument of `Get Field Value`, for a label that repeats.
27
+
28
+ ### Changed
29
+
30
+ - MarkItDown is pinned to 0.1.10 (was 0.1.9). Its PDF budgets now apply: a PDF
31
+ over a limit fails with a resource limit error.
32
+ - The pinned dependencies are updated and re-vetted; see `PLAN.md` section 5.
33
+ - Development status is Alpha.
34
+
35
+ ## 0.1.0 - 2026-11-20
36
+
37
+ ### Added
38
+
39
+ - Convert keywords, `Convert File To Markdown` and `Convert Bytes To Markdown`,
40
+ that run offline with a size cap.
41
+ - Text assertions: `Markdown Should Contain`, `Markdown Should Not Contain` and
42
+ `Markdown Should Match Regexp`.
43
+ - Table keywords: `Get Tables From Markdown`, `Get Table From Markdown` and
44
+ `Get Table Cell`.
45
+ - Sheet keywords for XLSX: `Get Sheet Names` and `Get Sheet As Table`.
46
+ - Field keywords: `Get Field Value`, `Field Should Be` and `Field Should Be Blank`,
47
+ with an opt-in next-line rule.
48
+ - `Pdf Field Should Be Blank`, which reads AcroForm values through the optional
49
+ pypdf reader (`acroform` extra) and falls back to the converted text.
50
+ - `Set Converter Options` for the size cap and data URI handling.
51
+ - Libdoc HTML keyword docs in `docs/`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ai94iq
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,218 @@
1
+ Metadata-Version: 2.5
2
+ Name: robotframework-markitdown
3
+ Version: 0.2.1
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.14
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: <3.15,>=3.10
19
+ Requires-Dist: markitdown[docx,pdf,pptx,xlsx]==0.1.10
20
+ Requires-Dist: robotframework==7.5.1
21
+ Provides-Extra: acroform
22
+ Requires-Dist: pypdf==7.2.0; extra == 'acroform'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # robotframework-markitdown
26
+
27
+ Robot Framework keywords that read PDF, DOCX, XLSX, PPTX and HTML files as
28
+ Markdown, then check their text, tables and field values. Conversion uses
29
+ Microsoft MarkItDown and runs offline.
30
+
31
+ A test can download a contract PDF and check that its "Total Amount" field is
32
+ blank. It can also read a spreadsheet sheet as rows and check the totals.
33
+
34
+ The package is not on PyPI yet. Install it from GitHub, as shown below.
35
+
36
+ ## Contents
37
+
38
+ - [Requirements](#requirements)
39
+ - [Install](#install)
40
+ - [Quick example](#quick-example)
41
+ - [Keywords](#keywords)
42
+ - [Offline and size limits](#offline-and-size-limits)
43
+ - [Field lookup](#field-lookup)
44
+ - [PDF form fields](#pdf-form-fields)
45
+ - [Why use it](#why-use-it)
46
+ - [Measurements](#measurements)
47
+ - [Development](#development)
48
+ - [License](#license)
49
+
50
+ ## Requirements
51
+
52
+ - Python 3.10 to 3.14.
53
+ - Robot Framework 7.5.1 and MarkItDown 0.1.10. pip installs both.
54
+
55
+ ## Install
56
+
57
+ ```sh
58
+ pip install git+https://github.com/ai94iq/robotframework-markitdown@v0.2.0
59
+ ```
60
+
61
+ For AcroForm (fillable PDF) field values, install the `acroform` extra. It adds
62
+ pypdf:
63
+
64
+ ```sh
65
+ pip install "robotframework-markitdown[acroform] @ git+https://github.com/ai94iq/robotframework-markitdown@v0.2.0"
66
+ ```
67
+
68
+ Import the library in a suite:
69
+
70
+ ```robotframework
71
+ *** Settings ***
72
+ Library MarkItDownLibrary
73
+ ```
74
+
75
+ ## Quick example
76
+
77
+ ```robotframework
78
+ *** Settings ***
79
+ Library RequestsLibrary
80
+ Library MarkItDownLibrary
81
+
82
+ *** Test Cases ***
83
+ New Contract Has No Total Amount
84
+ ${resp}= GET On Session api /contracts/${id}/pdf
85
+ ${md}= Convert Bytes To Markdown ${resp.content} .pdf
86
+ Markdown Should Contain ${md} Onboarding Contract
87
+ Field Should Be Blank ${md} Total Amount
88
+
89
+ Invoice Sheet Totals
90
+ ${rows}= Get Sheet As Table ${OUTPUT DIR}/invoice.xlsx Summary
91
+ Should Be Equal ${rows}[0][Total] 0
92
+ ```
93
+
94
+ ## Keywords
95
+
96
+ | Keyword | What it does |
97
+ |---|---|
98
+ | Convert File To Markdown | Converts a local file and returns the Markdown. |
99
+ | Convert Bytes To Markdown | Converts bytes, such as a response body, using an extension as the format hint. |
100
+ | Markdown Should Contain | Passes when the text is in the Markdown. Case and whitespace rules are options. |
101
+ | Markdown Should Not Contain | Passes when the text is not in the Markdown. |
102
+ | Markdown Should Match Regexp | Passes when a multiline regular expression matches. Returns the match. |
103
+ | Get Tables From Markdown | Returns every pipe table as rows of cells. |
104
+ | Get Table From Markdown | Returns one table as rows keyed by its header. |
105
+ | Get Table Cell | Returns one cell by body row number and column name or number. |
106
+ | Get Field Value | Returns the value of a labelled field. Returns an empty string when blank. |
107
+ | Field Should Be | Passes when a labelled field has the expected value. |
108
+ | Field Should Be Blank | Passes when a labelled field is found and empty. |
109
+ | Pdf Field Should Be Blank | Checks a PDF form field, or the converted text when there is no form field. |
110
+ | Get Sheet Names | Returns the sheet names of an XLSX file in workbook order. |
111
+ | Get Sheet As Table | Returns one XLSX sheet as rows keyed by header. |
112
+ | Set Converter Options | Sets the size cap and whether data URIs are kept. |
113
+ | Set Pdf Limits | Sets the PDF character limits that MarkItDown enforces. |
114
+
115
+ Full keyword docs:
116
+ [MarkItDownLibrary.html](https://github.com/ai94iq/robotframework-markitdown/blob/main/docs/MarkItDownLibrary.html)
117
+
118
+ ## Offline and size limits
119
+
120
+ - Only local files and bytes are converted. A path that starts with `file:`,
121
+ `http:`, `https:` or `data:` is refused.
122
+ - Plugins, LLM and Azure features are off. Only the built-in converters run.
123
+ - Each document is checked against a size cap before conversion. The default cap
124
+ is 50 MB. `Set Converter Options` changes it.
125
+ - Embedded data URIs are dropped from the output unless `keep_data_uris` is set.
126
+ - A PDF over a character limit fails with a resource limit error. The defaults
127
+ are 100,000 characters a page, 2,000,000 in total and 10,000,000 in the output.
128
+ `Set Pdf Limits` changes them; a call with no arguments restores the defaults.
129
+ - Images convert to text only when the `exiftool` program is installed and on
130
+ `PATH` (or named in `EXIFTOOL_PATH`). Without it an image converts to an empty
131
+ string. The library does not install ExifTool.
132
+ - Unit tests block network calls while they convert files.
133
+
134
+ ## Field lookup
135
+
136
+ `Get Field Value`, `Field Should Be` and `Field Should Be Blank` find a label in
137
+ this order:
138
+
139
+ 1. A table row whose first cell is the label. The value is the second cell.
140
+ 2. A line that starts with the label and the separator (`:` by default). The
141
+ value is the text after the separator.
142
+ 3. Only with `next_line=True`: a line that is the label alone. The value is the
143
+ next non-empty line. If that line ends with the separator, or the label is
144
+ the last line, the value is blank.
145
+
146
+ When a label repeats, `occurrence` picks the nth match (from 1) in the same
147
+ order of rules. An `occurrence` past the last match fails and names the count.
148
+
149
+ A label that is not found fails the test and shows the closest lines. A label
150
+ that is found with no value returns `""`.
151
+
152
+ ## PDF form fields
153
+
154
+ `Pdf Field Should Be Blank` first looks for an AcroForm field with that name,
155
+ when pypdf is installed. If the field is there, its value is checked. Otherwise
156
+ the check runs on the converted text, with the field lookup rules above. Without
157
+ pypdf, the text check always runs.
158
+
159
+ ## Why use it
160
+
161
+ - One import gives a test the file reading and the checks: convert a PDF,
162
+ DOCX, XLSX, PPTX or HTML file, then check text, tables and labelled fields.
163
+ - `Pdf Field Should Be Blank` reads the AcroForm field value first. A plain
164
+ text read of a filled form can miss that value (see the measurements).
165
+ - `Get Sheet As Table` returns an XLSX sheet as rows keyed by header.
166
+ - Failures show the closest lines, so a missing label is easy to find.
167
+ - Local files and bytes only; no network, plugin, LLM or Azure call.
168
+
169
+ ## Measurements
170
+
171
+ Each number comes from a run on 2026-12-06 (Windows, Python 3.13, MarkItDown
172
+ 0.1.10, pypdf 7.2.0). "Plain read" is pypdf `extract_text` over all pages.
173
+ Median of 30 runs per fixture; 3 for the two IRS forms.
174
+
175
+ | Check | Plain read | This library |
176
+ |---|---|---|
177
+ | Blank or filled, 4 fixtures in `atest/fixtures` | 3 of 4 | 4 of 4 |
178
+ | `contract_form_filled.pdf` (field value 250) | reads blank | reads filled |
179
+ | Conversion time, one-line fixtures | 0.52-0.53 ms | 2.11-2.20 ms |
180
+ | Conversion time, IRS W-9 (6 pages) | 55 ms | 2861 ms (4327 ms before the extension shortcut) |
181
+ | Conversion time, IRS W-4 (5 pages) | 148 ms | 6912 ms (7942 ms before) |
182
+
183
+ What this supports: on a form whose value lives in a field, the plain read
184
+ says blank and the library reads the value.
185
+
186
+ What it does not show:
187
+
188
+ - No size win. On the one-line fixtures the Markdown is 1 to 2 characters
189
+ longer than the plain text.
190
+ - No speed win. The library is about 4 times slower per small file and much
191
+ slower on larger forms. Tokens and model calls were not measured, and the two forms have no
192
+ known field values beyond the ones the test wrote.
193
+ - Four fixtures and two public forms are a small sample.
194
+
195
+ For `.pdf`, `.docx`, `.xlsx` and `.pptx` files the library trusts the file
196
+ extension and skips MarkItDown's content sniffing. A file with a wrong
197
+ extension for these formats is not re-identified. Other extensions are still
198
+ sniffed. This relies on a private MarkItDown attribute, so it is re-checked on
199
+ each MarkItDown upgrade.
200
+
201
+ ## Development
202
+
203
+ ```sh
204
+ uv pip install -e .[acroform]
205
+ python -m pytest
206
+ robot atest
207
+ pyright
208
+ python -m robot.libdoc MarkItDownLibrary docs/MarkItDownLibrary.html
209
+ ```
210
+
211
+ - `pytest` runs the unit tests in `utest/`.
212
+ - `robot atest` runs the acceptance suites in `atest/`.
213
+ - `pyright` checks `src`, `utest` and `tools` in strict mode.
214
+ - The last command rebuilds the keyword docs in `docs/`.
215
+
216
+ ## License
217
+
218
+ MIT.
@@ -0,0 +1,194 @@
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
+ A test can download a contract PDF and check that its "Total Amount" field is
8
+ blank. It can also read a spreadsheet sheet as rows and check the totals.
9
+
10
+ The package is not on PyPI yet. Install it from GitHub, as shown below.
11
+
12
+ ## Contents
13
+
14
+ - [Requirements](#requirements)
15
+ - [Install](#install)
16
+ - [Quick example](#quick-example)
17
+ - [Keywords](#keywords)
18
+ - [Offline and size limits](#offline-and-size-limits)
19
+ - [Field lookup](#field-lookup)
20
+ - [PDF form fields](#pdf-form-fields)
21
+ - [Why use it](#why-use-it)
22
+ - [Measurements](#measurements)
23
+ - [Development](#development)
24
+ - [License](#license)
25
+
26
+ ## Requirements
27
+
28
+ - Python 3.10 to 3.14.
29
+ - Robot Framework 7.5.1 and MarkItDown 0.1.10. pip installs both.
30
+
31
+ ## Install
32
+
33
+ ```sh
34
+ pip install git+https://github.com/ai94iq/robotframework-markitdown@v0.2.0
35
+ ```
36
+
37
+ For AcroForm (fillable PDF) field values, install the `acroform` extra. It adds
38
+ pypdf:
39
+
40
+ ```sh
41
+ pip install "robotframework-markitdown[acroform] @ git+https://github.com/ai94iq/robotframework-markitdown@v0.2.0"
42
+ ```
43
+
44
+ Import the library in a suite:
45
+
46
+ ```robotframework
47
+ *** Settings ***
48
+ Library MarkItDownLibrary
49
+ ```
50
+
51
+ ## Quick example
52
+
53
+ ```robotframework
54
+ *** Settings ***
55
+ Library RequestsLibrary
56
+ Library MarkItDownLibrary
57
+
58
+ *** Test Cases ***
59
+ New Contract Has No Total Amount
60
+ ${resp}= GET On Session api /contracts/${id}/pdf
61
+ ${md}= Convert Bytes To Markdown ${resp.content} .pdf
62
+ Markdown Should Contain ${md} Onboarding Contract
63
+ Field Should Be Blank ${md} Total Amount
64
+
65
+ Invoice Sheet Totals
66
+ ${rows}= Get Sheet As Table ${OUTPUT DIR}/invoice.xlsx Summary
67
+ Should Be Equal ${rows}[0][Total] 0
68
+ ```
69
+
70
+ ## Keywords
71
+
72
+ | Keyword | What it does |
73
+ |---|---|
74
+ | Convert File To Markdown | Converts a local file and returns the Markdown. |
75
+ | Convert Bytes To Markdown | Converts bytes, such as a response body, using an extension as the format hint. |
76
+ | Markdown Should Contain | Passes when the text is in the Markdown. Case and whitespace rules are options. |
77
+ | Markdown Should Not Contain | Passes when the text is not in the Markdown. |
78
+ | Markdown Should Match Regexp | Passes when a multiline regular expression matches. Returns the match. |
79
+ | Get Tables From Markdown | Returns every pipe table as rows of cells. |
80
+ | Get Table From Markdown | Returns one table as rows keyed by its header. |
81
+ | Get Table Cell | Returns one cell by body row number and column name or number. |
82
+ | Get Field Value | Returns the value of a labelled field. Returns an empty string when blank. |
83
+ | Field Should Be | Passes when a labelled field has the expected value. |
84
+ | Field Should Be Blank | Passes when a labelled field is found and empty. |
85
+ | Pdf Field Should Be Blank | Checks a PDF form field, or the converted text when there is no form field. |
86
+ | Get Sheet Names | Returns the sheet names of an XLSX file in workbook order. |
87
+ | Get Sheet As Table | Returns one XLSX sheet as rows keyed by header. |
88
+ | Set Converter Options | Sets the size cap and whether data URIs are kept. |
89
+ | Set Pdf Limits | Sets the PDF character limits that MarkItDown enforces. |
90
+
91
+ Full keyword docs:
92
+ [MarkItDownLibrary.html](https://github.com/ai94iq/robotframework-markitdown/blob/main/docs/MarkItDownLibrary.html)
93
+
94
+ ## Offline and size limits
95
+
96
+ - Only local files and bytes are converted. A path that starts with `file:`,
97
+ `http:`, `https:` or `data:` is refused.
98
+ - Plugins, LLM and Azure features are off. Only the built-in converters run.
99
+ - Each document is checked against a size cap before conversion. The default cap
100
+ is 50 MB. `Set Converter Options` changes it.
101
+ - Embedded data URIs are dropped from the output unless `keep_data_uris` is set.
102
+ - A PDF over a character limit fails with a resource limit error. The defaults
103
+ are 100,000 characters a page, 2,000,000 in total and 10,000,000 in the output.
104
+ `Set Pdf Limits` changes them; a call with no arguments restores the defaults.
105
+ - Images convert to text only when the `exiftool` program is installed and on
106
+ `PATH` (or named in `EXIFTOOL_PATH`). Without it an image converts to an empty
107
+ string. The library does not install ExifTool.
108
+ - Unit tests block network calls while they convert files.
109
+
110
+ ## Field lookup
111
+
112
+ `Get Field Value`, `Field Should Be` and `Field Should Be Blank` find a label in
113
+ this order:
114
+
115
+ 1. A table row whose first cell is the label. The value is the second cell.
116
+ 2. A line that starts with the label and the separator (`:` by default). The
117
+ value is the text after the separator.
118
+ 3. Only with `next_line=True`: a line that is the label alone. The value is the
119
+ next non-empty line. If that line ends with the separator, or the label is
120
+ the last line, the value is blank.
121
+
122
+ When a label repeats, `occurrence` picks the nth match (from 1) in the same
123
+ order of rules. An `occurrence` past the last match fails and names the count.
124
+
125
+ A label that is not found fails the test and shows the closest lines. A label
126
+ that is found with no value returns `""`.
127
+
128
+ ## PDF form fields
129
+
130
+ `Pdf Field Should Be Blank` first looks for an AcroForm field with that name,
131
+ when pypdf is installed. If the field is there, its value is checked. Otherwise
132
+ the check runs on the converted text, with the field lookup rules above. Without
133
+ pypdf, the text check always runs.
134
+
135
+ ## Why use it
136
+
137
+ - One import gives a test the file reading and the checks: convert a PDF,
138
+ DOCX, XLSX, PPTX or HTML file, then check text, tables and labelled fields.
139
+ - `Pdf Field Should Be Blank` reads the AcroForm field value first. A plain
140
+ text read of a filled form can miss that value (see the measurements).
141
+ - `Get Sheet As Table` returns an XLSX sheet as rows keyed by header.
142
+ - Failures show the closest lines, so a missing label is easy to find.
143
+ - Local files and bytes only; no network, plugin, LLM or Azure call.
144
+
145
+ ## Measurements
146
+
147
+ Each number comes from a run on 2026-12-06 (Windows, Python 3.13, MarkItDown
148
+ 0.1.10, pypdf 7.2.0). "Plain read" is pypdf `extract_text` over all pages.
149
+ Median of 30 runs per fixture; 3 for the two IRS forms.
150
+
151
+ | Check | Plain read | This library |
152
+ |---|---|---|
153
+ | Blank or filled, 4 fixtures in `atest/fixtures` | 3 of 4 | 4 of 4 |
154
+ | `contract_form_filled.pdf` (field value 250) | reads blank | reads filled |
155
+ | Conversion time, one-line fixtures | 0.52-0.53 ms | 2.11-2.20 ms |
156
+ | Conversion time, IRS W-9 (6 pages) | 55 ms | 2861 ms (4327 ms before the extension shortcut) |
157
+ | Conversion time, IRS W-4 (5 pages) | 148 ms | 6912 ms (7942 ms before) |
158
+
159
+ What this supports: on a form whose value lives in a field, the plain read
160
+ says blank and the library reads the value.
161
+
162
+ What it does not show:
163
+
164
+ - No size win. On the one-line fixtures the Markdown is 1 to 2 characters
165
+ longer than the plain text.
166
+ - No speed win. The library is about 4 times slower per small file and much
167
+ slower on larger forms. Tokens and model calls were not measured, and the two forms have no
168
+ known field values beyond the ones the test wrote.
169
+ - Four fixtures and two public forms are a small sample.
170
+
171
+ For `.pdf`, `.docx`, `.xlsx` and `.pptx` files the library trusts the file
172
+ extension and skips MarkItDown's content sniffing. A file with a wrong
173
+ extension for these formats is not re-identified. Other extensions are still
174
+ sniffed. This relies on a private MarkItDown attribute, so it is re-checked on
175
+ each MarkItDown upgrade.
176
+
177
+ ## Development
178
+
179
+ ```sh
180
+ uv pip install -e .[acroform]
181
+ python -m pytest
182
+ robot atest
183
+ pyright
184
+ python -m robot.libdoc MarkItDownLibrary docs/MarkItDownLibrary.html
185
+ ```
186
+
187
+ - `pytest` runs the unit tests in `utest/`.
188
+ - `robot atest` runs the acceptance suites in `atest/`.
189
+ - `pyright` checks `src`, `utest` and `tools` in strict mode.
190
+ - The last command rebuilds the keyword docs in `docs/`.
191
+
192
+ ## License
193
+
194
+ MIT.
@@ -0,0 +1,33 @@
1
+ *** Settings ***
2
+ Documentation DOCX conversion: paragraphs and a table without a header row.
3
+ Resource resources/common.resource
4
+ Suite Setup Convert Docx Fixture
5
+
6
+
7
+ *** Test Cases ***
8
+ Paragraph Text Converts
9
+ Markdown Should Contain ${DOC} Reference: ORD-7
10
+
11
+ Empty Header Row Is Kept In Raw Tables
12
+ ${tables} Get Tables From Markdown ${DOC}
13
+ Length Should Be ${tables} 1
14
+ VAR @{expected} Product Qty Price
15
+ Lists Should Be Equal ${tables}[0][1] ${expected}
16
+
17
+ First Non Empty Row Serves As Header
18
+ ${cell} Get Table Cell ${DOC} 0 2
19
+ Should Be Equal ${cell} 3.50
20
+
21
+ Empty Cell Reads As Empty String
22
+ ${cell} Get Table Cell ${DOC} 1 1
23
+ Should Be Empty ${cell}
24
+
25
+ Column Number Past The End Fails
26
+ Run Keyword And Expect Error EQUALS:Column '3' not found, columns are ['Product', 'Qty', 'Price']
27
+ ... Get Table Cell ${DOC} 0 3
28
+
29
+
30
+ *** Keywords ***
31
+ Convert Docx Fixture
32
+ ${markdown} Convert File To Markdown ${FIXTURES}${/}table.docx
33
+ VAR ${DOC} ${markdown} scope=SUITE
@@ -0,0 +1,81 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ <<
5
+ /Producer (pypdf)
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ <<
10
+ /Type /Pages
11
+ /Count 1
12
+ /Kids [ 4 0 R ]
13
+ >>
14
+ endobj
15
+ 3 0 obj
16
+ <<
17
+ /Type /Catalog
18
+ /Pages 2 0 R
19
+ /AcroForm <<
20
+ /Fields [ 7 0 R ]
21
+ >>
22
+ >>
23
+ endobj
24
+ 4 0 obj
25
+ <<
26
+ /Type /Page
27
+ /Resources <<
28
+ /Font <<
29
+ /F1 5 0 R
30
+ >>
31
+ >>
32
+ /MediaBox [ 0.0 0.0 300 200 ]
33
+ /Parent 2 0 R
34
+ /Contents 6 0 R
35
+ /Annots [ 7 0 R ]
36
+ >>
37
+ endobj
38
+ 5 0 obj
39
+ <<
40
+ /Type /Font
41
+ /Subtype /Type1
42
+ /BaseFont /Helvetica
43
+ >>
44
+ endobj
45
+ 6 0 obj
46
+ <<
47
+ /Length 43
48
+ >>
49
+ stream
50
+ BT /F1 12 Tf 20 150 Td (Total Amount) Tj ET
51
+ endstream
52
+ endobj
53
+ 7 0 obj
54
+ <<
55
+ /Type /Annot
56
+ /Subtype /Widget
57
+ /FT /Tx
58
+ /T (Total Amount)
59
+ /V ()
60
+ /Rect [ 120 140 280 160 ]
61
+ >>
62
+ endobj
63
+ xref
64
+ 0 8
65
+ 0000000000 65535 f
66
+ 0000000015 00000 n
67
+ 0000000054 00000 n
68
+ 0000000113 00000 n
69
+ 0000000196 00000 n
70
+ 0000000346 00000 n
71
+ 0000000416 00000 n
72
+ 0000000509 00000 n
73
+ trailer
74
+ <<
75
+ /Size 8
76
+ /Root 3 0 R
77
+ /Info 1 0 R
78
+ >>
79
+ startxref
80
+ 618
81
+ %%EOF