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

Remove <br> tags in html #618

Merged
merged 2 commits into from
Oct 1, 2024
Merged

Remove <br> tags in html #618

merged 2 commits into from
Oct 1, 2024

Conversation

addie9800
Copy link
Collaborator

Occasionally, a <br> tag is used to start a new paragraph instead of the usual new <p> element. I have modified the _base_setup to replace these tags prior to processing the article. As an extreme example consider this article: https://www.namibian.com.na/namibian-disability-federation-urges-official-recognition-of-sign-language-for-deaf-inclusion/
The test case also contains one example.

Comment on lines 55 to 57
html = re.sub(r"(<br>)+", "<p>", html)
doc = lxml.html.document_fromstring(html)
self.precomputed = Precomputed(html, doc, get_meta_content(doc), get_ld_content(doc))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two things here:

  1. The intended way to do something like this would be to use the function decorator instead of overwriting the _base_setup
  2. html should still reflect the original HTML. We have to find some way around this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it to only modify the html for the purpose of extracting the body. This way it's also not necessary to overwrite the HTML.

@addie9800 addie9800 merged commit acd378f into master Oct 1, 2024
5 checks passed
@addie9800 addie9800 deleted the fix-the-namibian branch October 1, 2024 13:51
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