Fix: frontpage news codeblock linebreaks & add news fixtures#671
Open
m1rm wants to merge 4 commits intoarchlinux:masterfrom
Open
Fix: frontpage news codeblock linebreaks & add news fixtures#671m1rm wants to merge 4 commits intoarchlinux:masterfrom
m1rm wants to merge 4 commits intoarchlinux:masterfrom
Conversation
bugfix(archlinux#573): add a test for newline preservation
f82e259 to
5757a13
Compare
Contributor
Author
|
converted to draft again bc. I am checking if the "linebreak" filter might add too many linebreaks. @jelly @christian-heusel because it is applied to all the content (not only codeblocks) |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Tip
This pull request aims at fixing missing line breaks in frontpage news code blocks. Additionally, for local development, news fixtures for the frontpage news section were added.
Issue linebreak loss
vendor code details
The `truncatewords_html` filter uses the TruncateWordsHTMLParser -> The filter is in: `.venv/lib/python3.14/site-packages/django/template/defaultfilters.py` -> The Truncator is in: `.venv/lib/python3.14/site-packages/django/utils/text.py`-> I think there the \n is lost because of the \S and \s usage (see https://docs.python.org/3/library/re.html)
Potential fixes
Using the linebreak filter
Commit: f543590 -> might not be a good choice, see comment screenshot
Using a custom filter
The custom filter is based on the builtin filter and only changes the behavior for
<pre>blocksCommit: d05be81
News fixtures
In order to debug this issue locally, fixtures for news are added (they are fully made up, I am not emotionally attached to the content so feel free to change it).
Tests
I added a test for newline preservation. Not sure if we need it but we can always remove it.
Fixes #573