Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug within LocalAttachmentHandler and regex search returning None causing AttributeError & add html meta tags to transcript #111

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix regex search returning no match causing AttributeError
Signed-off-by: doluk <69309597+doluk@users.noreply.github.com>
  • Loading branch information
doluk committed May 23, 2024
commit aeef1a336a227bbc69f25b394f64aa08faf7dc9f
30 changes: 18 additions & 12 deletions chat_exporter/parse/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,28 +388,34 @@ def remove_silent_link(url, raw_url=None):

if "&lt;" in word and "&gt;" in word:
pattern = r"&lt;https?:\/\/(.*)&gt;"
match_url = re.search(pattern, word).group(1)
url = f'<a href="https://{match_url}">https://{match_url}</a>'
word = word.replace("https://" + match_url, url)
word = word.replace("http://" + match_url, url)
match_url = re.search(pattern, word)
if match_url:
match_url = match_url.group(1)
url = f'<a href="https://{match_url}">https://{match_url}</a>'
word = word.replace("https://" + match_url, url)
word = word.replace("http://" + match_url, url)
output.append(remove_silent_link(word, match_url))
elif "https://" in word:
pattern = r"https://[^\s>`\"*]*"
word_link = re.search(pattern, word).group()
if word_link.endswith(")"):
word_link = re.search(pattern, word)
if word_link and word_link.group().endswith(")"):
output.append(word)
continue
word_full = f'<a href="{word_link}">{word_link}</a>'
word = re.sub(pattern, word_full, word)
elif word_link:
word_link = word_link.group()
word_full = f'<a href="{word_link}">{word_link}</a>'
word = re.sub(pattern, word_full, word)
output.append(remove_silent_link(word))
elif "http://" in word:
pattern = r"http://[^\s>`\"*]*"
word_link = re.search(pattern, word).group()
if word_link.endswith(")"):
word_link = re.search(pattern, word)
if word_link and word_link.group().endswith(")"):
output.append(word)
continue
word_full = f'<a href="{word_link}">{word_link}</a>'
word = re.sub(pattern, word_full, word)
elif word_link:
word_link = word_link.group()
word_full = f'<a href="{word_link}">{word_link}</a>'
word = re.sub(pattern, word_full, word)
output.append(remove_silent_link(word))
else:
output.append(word)
Expand Down