feat: custom Markdown extensions for partition_md#4292
Merged
PastelStorm merged 11 commits intoUnstructured-IO:mainfrom Mar 25, 2026
Merged
Conversation
Contributor
Author
|
@PastelStorm Would you please review? |
Contributor
Author
|
@PastelStorm Had a chance to review this? |
Contributor
|
@claytonlin1110 a few small findings, after those are fixed this PR should be good to merge :) Findings
_default_extensions = ["tables", "fenced_code"]
extensions = kwargs.pop("extensions", _default_extensions)
if not (isinstance(extensions, list) and all(isinstance(ext, str) for ext in extensions)):
logging.warning(
"Ignoring invalid 'extensions' argument (expected list of strings): %r", extensions
)
extensions = _default_extensions
html = markdown.markdown(text, extensions=extensions)
def test_partition_md_invalid_extensions_logs_and_falls_back(mocker: MockFixture):
"""Invalid `extensions` value is ignored with a warning and falls back to the default list."""
text = "# Heading"
logger = mocker.patch("unstructured.partition.md.logging.warning")
elements = partition_md(text=text, extensions="not-a-list") # type: ignore[arg-type]
# Still parses something
assert len(elements) > 0
# Warning was logged
logger.assert_called_once()
|
Contributor
Author
|
@PastelStorm Thank you for your review. |
PastelStorm
approved these changes
Mar 25, 2026
auto-merge was automatically disabled
March 25, 2026 05:25
Head branch was pushed to by a user without write access
Contributor
Author
|
@PastelStorm I just fixed the test error. |
Contributor
Author
|
@PastelStorm auto-merge is disabled as I just pushed the test fixes |
Contributor
Author
|
All CI passed |
Contributor
Thanks again for your contribution! |
c250e67 to
ca1faf8
Compare
Contributor
Author
|
@PastelStorm conflicts resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4006
extensionswhen callingpartition_md, defaulting to["tables"]for backward compatibility.extensionsvalues log a warning and fall back to["tables"].Motivation
Fixes incorrect parsing when fenced code blocks contain
#lines (treated as headings withoutfenced_code).How to use