Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
22449a30
Commit
22449a30
authored
Jun 01, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_corporate_identity: downgrade heading with an attribute
Example: <h2 class="foo">bar</h2> => <h3 class="foo">bar</h3>
parent
ac7a4b3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_downgradeHeaders.py
...skins/erp5_corporate_identity/WebPage_downgradeHeaders.py
+10
-12
No files found.
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_downgradeHeaders.py
View file @
22449a30
...
...
@@ -5,17 +5,15 @@ Downgrade headers in passed content by 1 or number of levels specified
"""
import
re
def
pushDown
(
level
):
return
''
.
join
([
"h"
,
str
(
level
),
">"
])
REGEXP
=
re
.
compile
(
'<h([1-6]).*>.*</h([1-6])>'
)
for
header
in
re
.
findall
(
"<h[1-6].*</h[1-6]>"
,
content
or
""
):
header_list
=
re
.
findall
(
"<(h[1-6]>)"
,
header
)
if
len
(
header_list
):
tag
=
header_list
[
0
]
#h2>
key
=
tag
[
1
]
content
=
content
.
replace
(
header
,
header
.
replace
(
tag
,
pushDown
(
int
(
key
)
+
(
downgrade
or
1
)))
)
def
pushDown
(
regexp_match
):
text
=
'%r'
%
regexp_match
.
group
()
start_level
=
regexp_match
.
group
(
1
)
stop_level
=
regexp_match
.
group
(
2
)
if
(
start_level
==
stop_level
):
next_level
=
"%i"
%
(
int
(
start_level
)
+
downgrade
)
text
=
'<h'
+
next_level
+
text
[
4
:
-
3
]
+
next_level
+
'>'
return
text
return
content
return
REGEXP
.
sub
(
pushDown
,
content
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment