Add a to_markdown method and simplify fix for sections being repeated
# Description
- Add a to_markdown() method that converts the document to markdown
- Refactor for the fix of repeated elements, mentioned in https://github.com/nlmatics/llmsherpa/issues/49 and https://github.com/nlmatics/llmsherpa/issues/73#issuecomment-2076736128. The fix for that issue was introduced in https://github.com/nlmatics/llmsherpa/commit/89e4bc703885928c48d48e236d6fb7cd154d65b9#diff-f5675ab91d217e33d82e4c00035b574f60ccfa0dbd9678da3bd2ae3d18f8a92cR543, but it's not needed to get the top level sections to fix that issue; you could get the root element and iterate the children recursively.
Also, I cannot think of a use case where you want duplicate elements in your document.to_html(), to_text() or to_markdown() methods, so the logic gets simplified a lot by removing the `_get_top_sections` method and avoid querying on every method if you want to include duplicates or not.
合并状态:未合并 9 条评论