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

Re-worked Telegram HTML/Markdown -> HTML Conversion #579

Merged
merged 1 commit into from
May 1, 2022

Conversation

caronc
Copy link
Owner

@caronc caronc commented May 1, 2022

Description:

Related issue (if applicable): #changedetection.io/555, #573, #565, #566, #576, #572, and #577

This should complete the over-hall of Apprise/Telegram HTML support. Up until now Telegram Unit Tests and Usage pretty much worked well so long as the input provided into Apprise was text. But if the input provided was HTML or Markdown, there were very odd side effects.

The biggest problem is Telegram's HTML support isn't really HTML at all. It only supports <a>, <b>, <i>, and <code>.

This completed change attempts to handle most (hopefully through bulletproofing later, i'll get all) unsuported (Telegram) HTML tags (such as title, body, li, ul, etc, etc ) and convert them back to the closest supported tag (if not remove it all together). This change also attempts to respect block vs inline code and places new lines where applicable during the transformation.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in
# This way you can just destroy it after when it's all over.
# The below will create a directory called apprise
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@more-html-conversion-support

# Run your telegram testing for HTML input:
apprise -i html  -t "<i>A Title</li>"  \
   -b "<p>a entry<div>another div entry</div></p>" \
    "tgram://credentials"

# or Markdown:
apprise -i markdown  -t "_A Title_"  \
   -b "[a link](http://localhost)" \
   "tgram://credentials"

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2022

Codecov Report

Merging #579 (969d81c) into master (3c07d80) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #579   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          109       109           
  Lines        14092     14094    +2     
  Branches      2636      2637    +1     
=========================================
+ Hits         14092     14094    +2     
Impacted Files Coverage Δ
apprise/conversion.py 100.00% <100.00%> (ø)
apprise/plugins/NotifyTelegram.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c07d80...969d81c. Read the comment docs.

@caronc caronc merged commit fd0cb3f into master May 1, 2022
@caronc caronc deleted the more-html-conversion-support branch May 2, 2022 00:45
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