Skip to content

Commit

Permalink
Add support for markdown files (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
paskett authored Jan 16, 2024
1 parent 20ecade commit 18a6a25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ragna/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"Requirement",
"Source",
"SourceStorage",
"TxtDocumentHandler",
"PlainTextDocumentHandler",
]

from ._utils import (
Expand All @@ -36,7 +36,7 @@
LocalDocument,
Page,
PdfDocumentHandler,
TxtDocumentHandler,
PlainTextDocumentHandler,
)

# isort: split
Expand Down
8 changes: 5 additions & 3 deletions ragna/core/_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ def load_if_available(self, cls: Type[T]) -> Type[T]:


@DOCUMENT_HANDLERS.load_if_available
class TxtDocumentHandler(DocumentHandler):
"""Document handler for `.txt` documents."""
class PlainTextDocumentHandler(DocumentHandler):
"""Document handler for plain-text documents.
Currently supports `.txt` and `.md` extensions.
"""

@classmethod
def supported_suffixes(cls) -> list[str]:
return [".txt"]
return [".txt", ".md"]

def extract_pages(self, document: Document) -> Iterator[Page]:
yield Page(text=document.read().decode())
Expand Down

0 comments on commit 18a6a25

Please sign in to comment.