Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psvg.doc.ic.ac.uk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
xr119
psvg.doc.ic.ac.uk
Commits
a1510181
Commit
a1510181
authored
9 years ago
by
Thomas Wood
Browse files
Options
Downloads
Patches
Plain Diff
Fix publications ToC
parent
8f8c22e3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_layouts/toc.html
+16
-0
16 additions, 0 deletions
_layouts/toc.html
_plugins/jekyll-toc.rb
+34
-0
34 additions, 0 deletions
_plugins/jekyll-toc.rb
publications/index.html
+2
-12
2 additions, 12 deletions
publications/index.html
with
52 additions
and
12 deletions
_layouts/toc.html
0 → 100644
+
16
−
0
View file @
a1510181
---
layout: page
dataspy: "#sidenav"
toc: "true"
---
<div
class=
"row stickyrow"
>
<div
class=
"col-sm-9"
>
{{ content | parse_toc }}
</div>
<div
class=
"col-sm-3"
>
<nav
class=
"sidenav fixedsticky"
id=
"sidenav"
><ul
class=
"nav list-group"
>
{% for i in page.toc %}
<li
class=
"nav-item list-group-item"
><a
href=
"#{{i.id}}"
class=
"nav-link"
>
{{i.name}}
</a></li>
{% endfor %}
</ul></nav>
</div>
</div>
This diff is collapsed.
Click to expand it.
_plugins/jekyll-toc.rb
0 → 100644
+
34
−
0
View file @
a1510181
require
'nokogiri'
module
Jekyll
# parse logic is from html-pipeline toc_filter
# https://github.com/jch/html-pipeline/blob/v1.1.0/lib/html/pipeline/toc_filter.rb
module
TableOfContentsFilter
PUNCTUATION_REGEXP
=
RUBY_VERSION
>
"1.9"
?
/[^\p{Word}\- ]/u
:
/[^\w\- ]/
def
parse_toc
(
html
)
toc
=
[]
doc
=
Nokogiri
::
HTML
::
DocumentFragment
.
parse
(
html
)
headers
=
Hash
.
new
(
0
)
doc
.
css
(
'h1, h2, h3, h4, h5, h6'
).
each
do
|
node
|
text
=
node
.
text
id
=
text
.
downcase
id
.
gsub!
(
PUNCTUATION_REGEXP
,
''
)
# remove punctuation
id
.
gsub!
(
' '
,
'-'
)
# replace spaces with dash
uniq
=
(
headers
[
id
]
>
0
)
?
"-
#{
headers
[
id
]
}
"
:
''
uniqid
=
"
#{
id
}#{
uniq
}
"
headers
[
id
]
+=
1
toc
<<
{
'id'
=>
uniqid
,
'name'
=>
text
,
'level'
=>
node
.
name
}
node
[
'id'
]
=
uniqid
end
@context
.
environments
.
first
[
'page'
][
'toc'
]
=
toc
doc
.
inner_html
end
end
end
Liquid
::
Template
.
register_filter
(
Jekyll
::
TableOfContentsFilter
)
This diff is collapsed.
Click to expand it.
publications/index.html
+
2
−
12
View file @
a1510181
---
title: Publications
dataspy: "#sidenav"
menu: true
layout: toc
---
<div
class=
"row stickyrow"
>
<div
class=
"col-sm-9"
>
{% bibliography -g year %}
</div>
<div
class=
"col-sm-3"
>
<nav
class=
"sidenav fixedsticky"
id=
"sidenav"
><ul
class=
"nav list-group"
>
{% for group in page.bibliography_groups %}
<li
class=
"nav-item list-group-item"
><a
href=
"#{{group[0]}}"
class=
"nav-link"
>
{{group[0]}}
</a></li>
{% endfor %}
</ul></nav>
</div>
</div>
{% bibliography -g year %}
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