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

Improve "Remove extra paragraph spacing" feature #1203

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f2a0378
Improve "Remove extra paragraph spacing" feature
Palloxin Aug 11, 2024
76a2a0c
Adjust in case of p with classes
Palloxin Aug 12, 2024
b5447b4
Lint
Palloxin Aug 12, 2024
06663fa
Lint - part 2
Palloxin Aug 12, 2024
3847351
Lint - part 3
Palloxin Aug 12, 2024
a13c648
forgot \s*
Palloxin Aug 17, 2024
86e05ad
\u00a exception
Palloxin Aug 17, 2024
8eedb38
Better
Palloxin Aug 17, 2024
5e26fe4
Fix
Palloxin Aug 17, 2024
51b6cc1
fix lint
Palloxin Aug 17, 2024
4f0b8a3
forgot ``?:``
Palloxin Aug 17, 2024
d081f33
Remove zero width
Palloxin Aug 17, 2024
d2050f7
fix lint
Palloxin Aug 17, 2024
842ab2a
lint
Palloxin Aug 17, 2024
74aee06
better v2
Palloxin Aug 17, 2024
845bbaf
better 2.1
Palloxin Aug 17, 2024
f85404c
Lint
Palloxin Aug 17, 2024
5146bdb
\s
Palloxin Aug 18, 2024
670ed3f
Exception: double br are used to simulate paragraphs
Palloxin Sep 4, 2024
97b0574
double br exception correction
Palloxin Sep 5, 2024
46c9d27
-
Palloxin Sep 5, 2024
d25af1a
better exception
Palloxin Sep 5, 2024
1fbfac9
Lint
Palloxin Sep 5, 2024
b3471b1
flaw correction
Palloxin Sep 5, 2024
3c46dd4
fix little flaw
Palloxin Sep 5, 2024
858a94b
Shortening regex
Palloxin Sep 5, 2024
fd4c1a8
faster regex
Palloxin Sep 5, 2024
fb7df2c
comment + faster regex
Palloxin Sep 6, 2024
153e03a
lint
Palloxin Sep 6, 2024
85a4412
lint
Palloxin Sep 6, 2024
fbfdf0a
Improve double br exception
Palloxin Sep 11, 2024
e7c87b1
Correct flaw
Palloxin Sep 14, 2024
7cdbc51
forgot
Palloxin Sep 14, 2024
812d3ae
\b for p
Palloxin Sep 14, 2024
89f777c
Revert correct flaw
Palloxin Sep 14, 2024
932dff9
Minimal faster regex
Palloxin Sep 15, 2024
f999c49
remove useless piece
Palloxin Sep 15, 2024
842179d
forgot
Palloxin Sep 15, 2024
4950bfd
Faster regex
Palloxin Sep 18, 2024
7777fe9
very minor change
Palloxin Sep 24, 2024
5baeee9
Max level fast
Palloxin Sep 26, 2024
5229a51
forgot a thing
Palloxin Sep 26, 2024
fd696e6
missing \s
Palloxin Sep 26, 2024
7f7935f
plus ultra
Palloxin Sep 28, 2024
b70aa1e
suppefast
Palloxin Nov 26, 2024
e012927
ops
Palloxin Nov 26, 2024
946863a
u200b
Palloxin Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion android/app/src/main/assets/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,14 @@ window.addEventListener('DOMContentLoaded', async () => {
}

if (reader.generalSettings.val.removeExtraParagraphSpacing) {
html = html.replace(/<\s*br[^>]*>/gi, '\n').replace(/\n{2,}/g, '\n\n');
html = html
.replace(/(?:&nbsp;\s*|[\u200b]\s*)+(?=<\/?p[> ])/g, '')
.replace(/<br>\s*<br>\s*(?:<br>\s*)+/g, '<br><br>') //force max 2 consecutive <br>, chaining regex
.replace(
/<br>\s*<br>(?:(?!\s*<(?:em|[iab]|strong|span)[> ])|(?<!(?:\/em|\/[iab]|\/strong|\/span)>\s*<br>\s*<br>))\s*/g,
'',
) //look-around double br. If certain tags aren't near, delete the double br.
.replace(/<br>(?:(?=\s*<\/?p[> ])|(?<=<\/?p>\s*<br>))\s*/g, '');
}
reader.chapterElement.innerHTML = html;
});
Expand Down
Loading