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
5b9b38e3
Commit
5b9b38e3
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
7b5b5d4a
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 @
5b9b38e3
...
@@ -5,17 +5,15 @@ Downgrade headers in passed content by 1 or number of levels specified
...
@@ -5,17 +5,15 @@ Downgrade headers in passed content by 1 or number of levels specified
"""
"""
import
re
import
re
def
pushDown
(
level
):
REGEXP
=
re
.
compile
(
'<h([1-6]).*>.*</h([1-6])>'
)
return
''
.
join
([
"h"
,
str
(
level
),
">"
])
for
header
in
re
.
findall
(
"<h[1-6].*</h[1-6]>"
,
content
or
""
):
def
pushDown
(
regexp_match
):
header_list
=
re
.
findall
(
"<(h[1-6]>)"
,
header
)
text
=
'%r'
%
regexp_match
.
group
()
if
len
(
header_list
):
start_level
=
regexp_match
.
group
(
1
)
tag
=
header_list
[
0
]
#h2>
stop_level
=
regexp_match
.
group
(
2
)
key
=
tag
[
1
]
if
(
start_level
==
stop_level
):
content
=
content
.
replace
(
next_level
=
"%i"
%
(
int
(
start_level
)
+
downgrade
)
header
,
text
=
'<h'
+
next_level
+
text
[
4
:
-
3
]
+
next_level
+
'>'
header
.
replace
(
tag
,
pushDown
(
int
(
key
)
+
(
downgrade
or
1
)))
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