Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Specification Tools
Scripts
Commits
8b2d051b
Commit
8b2d051b
authored
1 year ago
by
Andreas Kraft
Browse files
Options
Downloads
Patches
Plain Diff
Made <br> replacement a bit more flexible. Also, ignoring code blocks
parent
96613f89
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
generateChangemarks/pandocFilter.py
+11
-2
11 additions, 2 deletions
generateChangemarks/pandocFilter.py
with
11 additions
and
2 deletions
generateChangemarks/pandocFilter.py
+
11
−
2
View file @
8b2d051b
...
...
@@ -132,14 +132,23 @@ def replaceLineBreaks(progress: Progress, mdLines: list[str]) -> list[str]:
"""
_taskID
=
progress
.
add_task
(
'
[blue]Replacing linebreaks
'
,
start
=
False
,
total
=
0
)
# progress.update()
linebreaksregex
=
re
.
compile
(
'
<br
/
>
'
)
linebreaksregex
=
re
.
compile
(
'
<br
\s*/?\s*
>
'
)
_lines
:
list
[
str
]
=
[]
_inCodeBlock
=
False
for
line
in
mdLines
:
# Check if we are in a code block
if
line
.
strip
().
startswith
(
'
```
'
):
_inCodeBlock
=
not
_inCodeBlock
if
_inCodeBlock
:
_lines
.
append
(
line
)
continue
# Replace linebreaks
matches
=
re
.
findall
(
linebreaksregex
,
line
)
if
matches
:
# Replace the linebreak with "\(newline)"
_lines
.
append
(
re
.
sub
(
r
'
<br />
'
,
f
'
\\\n
'
,
line
))
_lines
.
append
(
re
.
sub
(
linebreaksregex
,
f
'
\\\n
'
,
line
))
else
:
_lines
.
append
(
line
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment