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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
474f84e0
Commit
474f84e0
authored
Oct 22, 2018
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_corporate_identity: make inline anchors work
parent
4bc22d6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_createTableOfContent.py
...s/erp5_corporate_identity/WebPage_createTableOfContent.py
+5
-5
No files found.
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_createTableOfContent.py
View file @
474f84e0
...
...
@@ -15,14 +15,13 @@ blank = ""
header_current
=
1
header_initial
=
None
table_of_content
=
blank
index
=
0
for
header
in
re
.
findall
(
"<h[1-6].*?</h[1-6]>"
,
doc_content
or
blank
):
header_level
=
header
[
2
]
header_initial
=
header_initial
or
header_level
header_reference
=
re
.
findall
(
">(.*)<"
,
header
)[
0
]
header_lowercase
=
header_reference
.
lower
()
header_reference_prefix
=
header_lowercase
.
replace
(
" "
,
"-"
)
header_reference_prefix
=
header_lowercase
.
replace
(
" "
,
"-"
)
+
str
(
index
)
if
header_level
==
header_current
:
table_of_content
+=
'</li>'
...
...
@@ -37,15 +36,16 @@ for header in re.findall("<h[1-6].*?</h[1-6]>", doc_content or blank):
table_of_content
+=
'</li></ol>'
*
iterations
header_current
=
header_level
index
+=
1
# add anchor in content
snippet
=
''
.
join
([
'>'
,
header_reference
])
named_snippet
=
''
.
join
([
'>'
,
'<a name="'
,
html_quote
(
header_reference_prefix
),
'_anchor"></a>'
,
header_reference
,
'<a class="custom-para" href='
,
doc_reference
,
'#'
,
header_reference_prefix
,
'><span style="font-size:.75em;line-height:1em;padding-left:.5em;">¶</span></a>'
'<a class="custom-para" href='
,
'#'
,
header_reference_prefix
,
'_anchor'
,
'><span style="font-size:.75em;line-height:1em;padding-left:.5em;">¶</span></a>'
])
doc_content
=
doc_content
.
replace
(
snippet
,
named_snippet
)
doc_content
=
doc_content
.
replace
(
header
,
header
.
replace
(
snippet
,
named_snippet
),
1
)
# create table of content entry
table_of_content
+=
''
.
join
([
...
...
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