Skip to content

Commit

Permalink
Improve Outlook forward style
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasst committed Jun 27, 2024
1 parent 6ad101d commit 277d34f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion quotequail/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ def _trim_spaces(text: str) -> str:
is_forward = (
is_block
and state == BEGIN
and el.attrib.get("style") in FORWARD_STYLES
and (style := el.attrib.get("style"))
and any(
style_re.match(style)
for style_re in FORWARD_STYLES
)
)

if is_block or line_break:
Expand Down
12 changes: 10 additions & 2 deletions quotequail/_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,16 @@
)

FORWARD_STYLES = [
# Outlook
"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in",
# Outlook starts forwards directly with the "From: " line but we can catch
# it with the header to avoid falsely identifying a forward
# - #B5C4DF and #E1E1E1 are known border colors.
# - "padding:3.0pt 0in 0in 0in" and "padding:3.0pt 0cm 0cm 0cm" are known
# paddings.
re.compile(
r"^border:none;border-top:solid #[0-9a-fA-f]{6} 1\.0pt;"
r"padding:3\.0pt 0(in|cm) 0(in|cm) 0(in|cm)$",
re.UNICODE,
),
]

HEADER_RE = re.compile(r"\*?([-\w ]+):\*?(.*)$", re.UNICODE)
Expand Down

0 comments on commit 277d34f

Please sign in to comment.