Skip to content

Small fix and minor additions#147

Closed
doluk wants to merge 3 commits intomasterfrom
small_fixes_additions
Closed

Small fix and minor additions#147
doluk wants to merge 3 commits intomasterfrom
small_fixes_additions

Conversation

@doluk
Copy link
Collaborator

@doluk doluk commented Jan 2, 2026

This pull request introduces improvements to both markdown parsing and time mention handling. The markdown parser now supports additional markdown syntaxes, and the time mention logic is enhanced to robustly handle extremely large timestamps that could previously cause errors.

Markdown parsing enhancements:

  • Added support for parsing single underscore italics (_text_) and rendering them as <em> tags.
  • Added support for a custom small text markdown (-# Heading) and rendering it as <small> tags.

Time mention handling improvements:

  • Updated the timestamp parsing logic to gracefully handle very large Unix timestamps by projecting them into 400-year cycles, preventing errors such as OverflowError or OSError and ensuring correct year calculation in the rendered output.

doluk added 2 commits January 2, 2026 13:38
Handle timestamp parsing errors and implement a safe range for large timestamps.
Add _ as alias for * to create italic text
Copilot AI review requested due to automatic review settings January 2, 2026 12:41
@doluk doluk requested a review from mahtoid as a code owner January 2, 2026 12:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances Discord chat export functionality by adding support for additional markdown syntaxes and implementing overflow-safe timestamp handling. The changes enable parsing of single underscore italics and Discord's small text syntax, while also preventing crashes when processing extremely large Unix timestamps through a 400-year cycle projection algorithm.

  • Added support for single underscore italics (_text_) and small text markdown (-# text)
  • Implemented exception handling for timestamp overflow errors using 400-year Gregorian calendar cycle arithmetic

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
chat_exporter/parse/markdown.py Added two new markdown patterns: single underscore for italics and -# prefix for small text rendering
chat_exporter/parse/mention.py Wrapped timestamp parsing in try-except block with fallback logic that projects large timestamps into safe 400-year cycles to prevent overflow errors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tooltip_time = tooltip_time.replace(str(datetime_stamp.year), str(time_stamp[0]))
except (OSError, OverflowError, ValueError):
# overflow error occurs when timestamp is too large, manual parsing
CYCLE_SECONDS = 12_622_780_800 # Exactly 400 years in seconds
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant CYCLE_SECONDS is defined inside the exception handler, which means it will be redefined every time an overflow occurs. Consider moving this constant to the class level (e.g., as a class variable in ParseMention) or module level for better performance and code organization. For example, add CYCLE_SECONDS = 12_622_780_800 near the top of the class definition alongside other constants like REGEX_TIME_HOLDER.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FroostySnoowman
Copy link
Contributor

Looks good to me

@doluk doluk closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants