Skip to content

Commit

Permalink
Fix character decoding issues with text-like files
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Dec 14, 2024
1 parent 70ab149 commit 112c276
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies = [
"youtube-transcript-api",
"SpeechRecognition",
"pathvalidate",
"charset-normalizer",
]

[project.urls]
Expand Down
5 changes: 2 additions & 3 deletions src/markitdown/_markitdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import puremagic
import requests
from bs4 import BeautifulSoup
from charset_normalizer import from_path

# Optional Transcription support
try:
Expand Down Expand Up @@ -161,9 +162,7 @@ def convert(
elif "text/" not in content_type.lower():
return None

text_content = ""
with open(local_path, "rt", encoding="utf-8") as fh:
text_content = fh.read()
text_content = str(from_path(local_path).best())
return DocumentConverterResult(
title=None,
text_content=text_content,
Expand Down

0 comments on commit 112c276

Please sign in to comment.