Unstructured-IO / Unstructured-IO/unstructured
bug/<partition_md> does not properly handled title hireachy
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 15.5k
- Forks
- 1.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 13
Description
Describe the bug
When processing markdown using partition_md.The title 'section' should be under 'Chapter 1' as its parent, but in this case, it is NaN. Or could you please suggest if there is any other parameter I might have missed that could be causing this problem? Thanks.
To Reproduce
Provide a code snippet that reproduces the issue.
markdown_document = """# Title\n\n \
## Chapter 1\n\n \
Hi this is Jim\n\n Hi this is Joe\n\n \
### Section \n\n \
Hi this is Lance \n\n
## Chapter 2\n\n \
Hi this is Molly"""
from unstructured.partition.md import partition_md
from unstructured.staging.base import convert_to_dataframe
# file = r"C:\Users\Cjy\Desktop\fix\out.md"
raw_md_elements = partition_md(text=markdown_document)
df = convert_to_dataframe(raw_md_elements)
df
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment Info
Please run python scripts/collect_env.py and paste the output here.
This will help us understand more about the environment in which the bug occurred.
Additional context
version: 0.12.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the partition_md(text=...) entry point and inspect how the markdown headings in the provided reproduction are converted into elements and then into a dataframe by convert_to_dataframe. Confirm the observed NaN parent for “Section” and define the expected heading hierarchy before changing behavior; add or update a focused regression test for the sample markdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100