* Fix typos and formatting in comments, docstrings, and markdown files
Comment/docstring typo fixes:
- _base_converter.py: fix 'steam_info' -> 'stream_info', missing 'on',
duplicated 'MUST be reset', 'advances' -> 'advance',
'used to in cases' -> 'used in cases', 'charset, set' -> 'charset, etc.'
- _markitdown.py: 'legaxy' -> 'legacy', 'User' -> 'Use' in DEPRECATED
docstring, second 'PRIORITY_SPECIFIC_FILE_FORMAT (== 10)' ->
'PRIORITY_GENERIC_FILE_FORMAT (== 10)', 'Plugins converters' ->
'Plugin converters'
- __main__.py: 'e.g,' -> 'e.g.,' in --charset help
- _exceptions.py: 'an a single' -> 'a single'
- _docx_converter.py, _epub_converter.py: 'e.g.m headings' ->
'e.g., headings'
- _epub_converter.py: remove stray closing triple-quote in comment
- _outlook_msg_converter.py: 'Brue force' -> 'Brute force'
- _markdownify.py: 'Javascript' -> 'JavaScript'
- _bing_serp_converter.py: remove stray '"' in Base64URL comment
- sample plugin _plugin.py: 'RTF file to in the simplest' ->
'RTF file in the simplest'; 'into an str using hte' ->
'into a str using the'
Markdown formatting fixes:
- README.md: 'Youtube URLs' -> 'YouTube URLs'
- markitdown-mcp/README.md: remove trailing tab characters after
```bash code fences; convert tab-indented JSON array elements to
8-space indentation for consistency
- markitdown-sample-plugin/README.md: 'Next, implement' -> 'First,
implement' for the initial step (no prior step exists); normalize
tab-indented lines inside Python code samples to 4/8-space
indentation; strip trailing spaces
* Fix typos found by codespell in tests and doc intel converter
Test files:
- test_sample_plugin.py: 'dirctly' -> 'directly'
- test_cli_vectors.py: 'readds' -> 'reads'
- test_module_misc.py: 'targted' -> 'targeted' (2 occurrences)
Source files:
- _doc_intel_converter.py: 'availiable' -> 'available' in docstring
Verified clean with:
codespell --skip='.git,test_files,ThirdPartyNotices.md,SECURITY.md,\
SUPPORT.md,CODE_OF_CONDUCT.md,latex_dict.py,omml.py,ocr_test_data,\
*.pdf,*.docx,*.pptx,*.xlsx,*.xls,*.png,*.jpg,*.jpeg,*.wav,*.mp3,\
*.mp4,*.zip,*.epub,*.msg,*.rtf' packages/ README.md
* fix DocumentConverter.PRIORITY_* references
* Quote install commands so they work in zsh; MarkItdown->MarkItDown
In zsh (default macOS shell since 2019, default on many Linux distros),
`[` and `]` are pathname-expansion metacharacters, so `pip install
markitdown[all]` fails with:
zsh: no matches found: markitdown[all]
The top-level README.md already uses the quoted form
(`pip install 'markitdown[all]'`) throughout. This commit brings the
package README and two user-facing dependency-missing error messages
into alignment with that convention, so users copy-pasting from PyPI
or from a raised MissingDependencyException get a command that works
in every mainstream shell.
- packages/markitdown/README.md: quote the PyPI install and the
editable-install-from-source example.
- _exceptions.py: quote the three `pip install` examples inside
MISSING_DEPENDENCY_MESSAGE (shown to end users when an optional
converter dep is missing).
- _transcribe_audio.py: quote the two `pip install` examples in
the raised MissingDependencyException text, and fix a lowercase
'MarkItdown' -> 'MarkItDown' product-name typo in the same string.
Bash/sh/dash treat quoted and unquoted forms identically, so this is
a strict improvement.
Independently proposed by community PRs #1172, #1577, #1602, and #2062
(all still open); fixes referenced issue #1574. Consolidating here to
resolve them in one place alongside the wider prose cleanup.
* Strip trailing whitespace from prose in top-level and package READMEs
Three stray single trailing spaces at end of prose lines:
- README.md (Security Considerations section):
* end of the 'MarkItDown performs I/O...' paragraph
* end of the 'Sanitize your inputs:' paragraph
- packages/markitdown/README.md:
* end of the [!TIP] callout description line
Some Markdown renderers (and Markdown Lint / Prettier / etc.) treat a
trailing double-space as an explicit line break, so accidental single
trailing spaces show up as diff noise on every unrelated edit. They
also make grep/regex line-ends less reliable.
Prose-only change, no rendering impact intended.
Proposed by community PR #1838 (only the whitespace part; that PR
also unrelated changes that blocked it from merging).
* Quote remaining install commands in _cu_converter and _doc_intel_converter
Final-audit pass caught three install-command hints missed by the
earlier commit (cc9202b), which had only picked up the sites listed
in community PR #2062. Same zsh/PowerShell glob-metacharacter bug,
same fix (single-quote the [extras]):
- _cu_converter.py module docstring:
"Install dependencies: ``pip install 'markitdown[az-content-understanding]'``"
- _cu_converter.py MissingDependencyException raised at __init__:
"E.g., `pip install 'markitdown[az-content-understanding]'`"
- _doc_intel_converter.py MissingDependencyException raised at __init__:
"E.g., `pip install 'markitdown[az-doc-intel]'`"
After this commit, no unquoted `pip install ...[extras]` remains
anywhere in READMEs, docstrings, comments, or user-visible error
messages. Consistent with the top-level README convention.
---------
Co-authored-by: afourney <adamfo@microsoft.com>
MarkItDown Sample Plugin
This project shows how to create a sample plugin for MarkItDown. The most important parts are as follows:
First, implement your custom DocumentConverter:
from typing import BinaryIO, Any
from markitdown import MarkItDown, DocumentConverter, DocumentConverterResult, StreamInfo, PRIORITY_SPECIFIC_FILE_FORMAT
class RtfConverter(DocumentConverter):
def __init__(
self, priority: float = PRIORITY_SPECIFIC_FILE_FORMAT
):
super().__init__(priority=priority)
def accepts(
self,
file_stream: BinaryIO,
stream_info: StreamInfo,
**kwargs: Any,
) -> bool:
# Implement logic to check if the file stream is an RTF file
# ...
raise NotImplementedError()
def convert(
self,
file_stream: BinaryIO,
stream_info: StreamInfo,
**kwargs: Any,
) -> DocumentConverterResult:
# Implement logic to convert the file stream to Markdown
# ...
raise NotImplementedError()
Next, make sure your package implements and exports the following:
# The version of the plugin interface that this plugin uses.
# The only supported version is 1 for now.
__plugin_interface_version__ = 1
# The main entrypoint for the plugin. This is called each time MarkItDown instances are created.
def register_converters(markitdown: MarkItDown, **kwargs):
"""
Called during construction of MarkItDown instances to register converters provided by plugins.
"""
# Simply create and attach an RtfConverter instance
markitdown.register_converter(RtfConverter())
Finally, create an entrypoint in the pyproject.toml file:
[project.entry-points."markitdown.plugin"]
sample_plugin = "markitdown_sample_plugin"
Here, the value of sample_plugin can be any key, but should ideally be the name of the plugin. The value is the fully qualified name of the package implementing the plugin.
Installation
To use the plugin with MarkItDown, it must be installed. To install the plugin from the current directory use:
pip install -e .
Once the plugin package is installed, verify that it is available to MarkItDown by running:
markitdown --list-plugins
To use the plugin for a conversion use the --use-plugins flag. For example, to convert an RTF file:
markitdown --use-plugins path-to-file.rtf
In Python, plugins can be enabled as follows:
from markitdown import MarkItDown
md = MarkItDown(enable_plugins=True)
result = md.convert("path-to-file.rtf")
print(result.text_content)
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.