Compare commits

...

2 Commits

Author SHA1 Message Date
chienyuanchang f6dbfc575e 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
2026-07-14 16:33:41 -07:00
chienyuanchang 6439057593 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
2026-07-14 16:25:31 -07:00
17 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ MarkItDown currently supports the conversion from:
- HTML
- Text-based formats (CSV, JSON, XML)
- ZIP files (iterates over contents)
- Youtube URLs
- YouTube URLs
- EPubs
- ... and more!
+8 -8
View File
@@ -25,13 +25,13 @@ pip install markitdown-mcp
To run the MCP server, using STDIO (default), use the following command:
```bash
```bash
markitdown-mcp
```
To run the MCP server, using Streamable HTTP and SSE, use the following command:
```bash
```bash
markitdown-mcp --http --host 127.0.0.1 --port 3001
```
@@ -86,12 +86,12 @@ If you want to mount a directory, adjust it accordingly:
"markitdown": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v",
"/home/user/data:/workdir",
"markitdown-mcp:latest"
"run",
"--rm",
"-i",
"-v",
"/home/user/data:/workdir",
"markitdown-mcp:latest"
]
}
}
+11 -11
View File
@@ -7,7 +7,7 @@
This project shows how to create a sample plugin for MarkItDown. The most important parts are as follows:
Next, implement your custom DocumentConverter:
First, implement your custom DocumentConverter:
```python
from typing import BinaryIO, Any
@@ -26,10 +26,10 @@ class RtfConverter(DocumentConverter):
stream_info: StreamInfo,
**kwargs: Any,
) -> bool:
# Implement logic to check if the file stream is an RTF file
# ...
raise NotImplementedError()
# Implement logic to check if the file stream is an RTF file
# ...
raise NotImplementedError()
def convert(
@@ -39,17 +39,17 @@ class RtfConverter(DocumentConverter):
**kwargs: Any,
) -> DocumentConverterResult:
# Implement logic to convert the file stream to Markdown
# ...
raise NotImplementedError()
# Implement logic to convert the file stream to Markdown
# ...
raise NotImplementedError()
```
Next, make sure your package implements and exports the following:
```python
# The version of the plugin interface that this plugin uses.
# The version of the plugin interface that this plugin uses.
# The only supported version is 1 for now.
__plugin_interface_version__ = 1
__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):
@@ -97,7 +97,7 @@ In Python, plugins can be enabled as follows:
```python
from markitdown import MarkItDown
md = MarkItDown(enable_plugins=True)
md = MarkItDown(enable_plugins=True)
result = md.convert("path-to-file.rtf")
print(result.text_content)
```
@@ -33,7 +33,7 @@ def register_converters(markitdown: MarkItDown, **kwargs):
class RtfConverter(DocumentConverter):
"""
Converts an RTF file to in the simplest possible way.
Converts an RTF file in the simplest possible way.
"""
def accepts(
@@ -60,7 +60,7 @@ class RtfConverter(DocumentConverter):
stream_info: StreamInfo,
**kwargs: Any,
) -> DocumentConverterResult:
# Read the file stream into an str using hte provided charset encoding, or using the system default
# Read the file stream into a str using the provided charset encoding, or using the system default
encoding = stream_info.charset or locale.getpreferredencoding()
stream_data = file_stream.read().decode(encoding)
@@ -13,7 +13,7 @@ RTF_TEST_STRINGS = {
def test_converter() -> None:
"""Tests the RTF converter dirctly."""
"""Tests the RTF converter directly."""
with open(os.path.join(TEST_FILES_DIR, "test.rtf"), "rb") as file_stream:
converter = RtfConverter()
result = converter.convert(
@@ -75,7 +75,7 @@ def main():
parser.add_argument(
"-c",
"--charset",
help="Provide a hint about the file's charset (e.g, UTF-8).",
help="Provide a hint about the file's charset (e.g., UTF-8).",
)
cloud_group = parser.add_mutually_exclusive_group()
@@ -50,18 +50,18 @@ class DocumentConverter:
) -> bool:
"""
Return a quick determination on if the converter should attempt converting the document.
This is primarily based `stream_info` (typically, `stream_info.mimetype`, `stream_info.extension`).
In cases where the data is retrieved via HTTP, the `steam_info.url` might also be referenced to
This is primarily based on `stream_info` (typically, `stream_info.mimetype`, `stream_info.extension`).
In cases where the data is retrieved via HTTP, the `stream_info.url` might also be referenced to
make a determination (e.g., special converters for Wikipedia, YouTube etc).
Finally, it is conceivable that the `stream_info.filename` might be used to in cases
Finally, it is conceivable that the `stream_info.filename` might be used in cases
where the filename is well-known (e.g., `Dockerfile`, `Makefile`, etc)
NOTE: The method signature is designed to match that of the convert() method. This provides some
assurance that, if accepts() returns True, the convert() method will also be able to handle the document.
IMPORTANT: In rare cases, (e.g., OutlookMsgConverter) we need to read more from the stream to make a final
determination. Read operations inevitably advances the position in file_stream. In these case, the position
MUST be reset it MUST be reset before returning. This is because the convert() method may be called immediately
determination. Read operations inevitably advance the position in file_stream. In these cases, the position
MUST be reset before returning. This is because the convert() method may be called immediately
after accepts(), and will expect the file_stream to be at the original position.
E.g.,
@@ -71,7 +71,7 @@ class DocumentConverter:
Parameters:
- file_stream: The file-like object to convert. Must support seek(), tell(), and read() methods.
- stream_info: The StreamInfo object containing metadata about the file (mimetype, extension, charset, set)
- stream_info: The StreamInfo object containing metadata about the file (mimetype, extension, charset, etc.)
- kwargs: Additional keyword arguments for the converter.
Returns:
@@ -92,7 +92,7 @@ class DocumentConverter:
Parameters:
- file_stream: The file-like object to convert. Must support seek(), tell(), and read() methods.
- stream_info: The StreamInfo object containing metadata about the file (mimetype, extension, charset, set)
- stream_info: The StreamInfo object containing metadata about the file (mimetype, extension, charset, etc.)
- kwargs: Additional keyword arguments for the converter.
Returns:
@@ -41,7 +41,7 @@ class UnsupportedFormatException(MarkItDownException):
class FailedConversionAttempt(object):
"""
Represents an a single attempt to convert a file.
Represents a single attempt to convert a file.
"""
def __init__(self, converter: Any, exc_info: Optional[tuple] = None):
@@ -270,7 +270,7 @@ class MarkItDown:
warn(f"Plugin '{plugin}' failed to register converters:\n{tb}")
self._plugins_enabled = True
else:
warn("Plugins converters are already enabled.", RuntimeWarning)
warn("Plugin converters are already enabled.", RuntimeWarning)
def convert(
self,
@@ -603,7 +603,7 @@ class MarkItDown:
# Add the list of converters for nested processing
_kwargs["_parent_converters"] = self._converters
# Add legaxy kwargs
# Add legacy kwargs
if stream_info is not None:
if stream_info.extension is not None:
_kwargs["file_extension"] = stream_info.extension
@@ -654,7 +654,7 @@ class MarkItDown:
)
def register_page_converter(self, converter: DocumentConverter) -> None:
"""DEPRECATED: User register_converter instead."""
"""DEPRECATED: Use register_converter instead."""
warn(
"register_page_converter is deprecated. Use register_converter instead.",
DeprecationWarning,
@@ -673,7 +673,7 @@ class MarkItDown:
Priorities work as follows: By default, most converters get priority
DocumentConverter.PRIORITY_SPECIFIC_FILE_FORMAT (== 0). The exception
is the PlainTextConverter, HtmlConverter, and ZipConverter, which get
priority PRIORITY_SPECIFIC_FILE_FORMAT (== 10), with lower values
priority PRIORITY_GENERIC_FILE_FORMAT (== 10), with lower values
being tried first (i.e., higher priority).
Just prior to conversion, the converters are sorted by priority, using
@@ -97,7 +97,7 @@ class BingSerpConverter(DocumentConverter):
) # Python 3 doesn't care about extra padding
try:
# RFC 4648 / Base64URL" variant, which uses "-" and "_"
# RFC 4648 / Base64URL variant, which uses "-" and "_"
a["href"] = base64.b64decode(u, altchars="-_").decode("utf-8")
except UnicodeDecodeError:
pass
@@ -207,7 +207,7 @@ class DocumentIntelligenceConverter(DocumentConverter):
def _analysis_features(self, stream_info: StreamInfo) -> List[str]:
"""
Helper needed to determine which analysis features to use.
Certain document analysis features are not availiable for
Certain document analysis features are not available for
office filetypes (.xlsx, .pptx, .html, .docx)
"""
mimetype = (stream_info.mimetype or "").lower()
@@ -30,7 +30,7 @@ ACCEPTED_FILE_EXTENSIONS = [".docx"]
class DocxConverter(HtmlConverter):
"""
Converts DOCX files to Markdown. Style information (e.g.m headings) and tables are preserved where possible.
Converts DOCX files to Markdown. Style information (e.g., headings) and tables are preserved where possible.
"""
def __init__(self):
@@ -25,7 +25,7 @@ MIME_TYPE_MAPPING = {
class EpubConverter(HtmlConverter):
"""
Converts EPUB files to Markdown. Style information (e.g.m headings) and tables are preserved where possible.
Converts EPUB files to Markdown. Style information (e.g., headings) and tables are preserved where possible.
"""
def __init__(self):
@@ -57,7 +57,7 @@ class EpubConverter(HtmlConverter):
**kwargs: Any, # Options to pass to the converter
) -> DocumentConverterResult:
with zipfile.ZipFile(file_stream, "r") as z:
# Extracts metadata (title, authors, language, publisher, date, description, cover) from an EPUB file."""
# Extracts metadata (title, authors, language, publisher, date, description, cover) from an EPUB file.
# Locate content.opf
container_dom = minidom.parse(z.open("META-INF/container.xml"))
@@ -43,7 +43,7 @@ class _CustomMarkdownify(markdownify.MarkdownConverter):
convert_as_inline: Optional[bool] = False,
**kwargs,
):
"""Same as usual converter, but removes Javascript links and escapes URIs."""
"""Same as usual converter, but removes JavaScript links and escapes URIs."""
prefix, suffix, text = markdownify.chomp(text) # type: ignore
if not text:
return ""
@@ -54,7 +54,7 @@ class OutlookMsgConverter(DocumentConverter):
finally:
file_stream.seek(cur_pos)
# Brue force, check if it's an Outlook file
# Brute force, check if it's an Outlook file
try:
if olefile is not None:
msg = olefile.OleFileIO(file_stream)
@@ -96,7 +96,7 @@ def test_output_to_file(shared_tmp_dir, test_vector) -> None:
@pytest.mark.parametrize("test_vector", CLI_TEST_VECTORS)
def test_input_from_stdin_without_hints(shared_tmp_dir, test_vector) -> None:
"""Test that the CLI readds from stdin correctly."""
"""Test that the CLI reads from stdin correctly."""
test_input = b""
with open(os.path.join(TEST_FILES_DIR, test_vector.filename), "rb") as stream:
@@ -126,7 +126,7 @@ def test_stream_info_operations() -> None:
**{keyword: f"{keyword}.2"}
)
# Make sure the targted attribute is updated
# Make sure the targeted attribute is updated
assert getattr(updated_stream_info, keyword) == f"{keyword}.2"
# Make sure the other attributes are unchanged
@@ -143,7 +143,7 @@ def test_stream_info_operations() -> None:
StreamInfo(**{keyword: f"{keyword}.2"})
)
# Make sure the targted attribute is updated
# Make sure the targeted attribute is updated
assert getattr(updated_stream_info, keyword) == f"{keyword}.2"
# Make sure the other attributes are unchanged