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

Detect code in pre-tag using indicators and fix code formatting issues #776

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

steineggerroland
Copy link

@steineggerroland steineggerroland commented Jan 13, 2025

Tackles #775 and an issue mentioned in #553.

Regarding #775 which mentions problems in detecting code blocks using just <pre>-tag:

convert_quotes is extended so that it uses a list of indicators to verify, if the element is a quote or a code block. If a code indicator is detected within the element, its expected to be a code block.
Suggested indicators to start with are: {, (", (', \n

Regarding #553:
Quote: "btw. here is another bug (maybe) when extracting inline code block, a redundant '\n' was added after a inline code block now result"

I changed how the line break is added to code blocks. I removed code as "NEWLINE_ELEMS" which currently leads to the line break. Instead the line break is now added when converting code to text if its a multiline block.

While fixing this issue another problem arose. A space is added after inline code. I fixed this issue making code a "SPECIAL_FORMATTING" element.

Issue with breaking code is tackled, too.
Line breaks are converted to \n within code blocks. There might be an issue with spaces which definitely needs to be addressed as mentioned in #553.

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.27%. Comparing base (42ada5a) to head (8309d65).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #776   +/-   ##
=======================================
  Coverage   99.27%   99.27%           
=======================================
  Files          21       21           
  Lines        3587     3594    +7     
=======================================
+ Hits         3561     3568    +7     
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adbar
Copy link
Owner

adbar commented Jan 14, 2025

Hi @steineggerroland, thanks for the PR, could you please address the issue above? The rest looks fine!

@adbar
Copy link
Owner

adbar commented Jan 21, 2025

@steineggerroland Thanks for taking the time to do the tests! I'm fine with your solution, there is a remaining problem with mypy on Python 3.13 though.

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.

Code blocks using pre could be detected more effectively
2 participants