Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
prace-lessons
Lesson Template
Commits
c21ab5b9
Commit
c21ab5b9
authored
10 years ago
by
Aaron O'Leary
Browse files
Options
Downloads
Plain Diff
Merge pull request #44 from r-gaia-cs/add-anchor-in-glossary
Add id to glossary entry
parents
7df94bf9
0428c499
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pages/Makefile
+2
-1
2 additions, 1 deletion
pages/Makefile
tools/filters/blockquote2div.py
+0
-0
0 additions, 0 deletions
tools/filters/blockquote2div.py
tools/filters/id4glossary.py
+35
-0
35 additions, 0 deletions
tools/filters/id4glossary.py
with
37 additions
and
1 deletion
pages/Makefile
+
2
−
1
View file @
c21ab5b9
...
...
@@ -29,7 +29,8 @@ $(DST_DIR)/motivation.html : $(SRC_DIR)/motivation.md ../_layouts/slides.html
$(DST_DIR)/%.html
:
$(SRC_DIR)/%.md ../_layouts/page.html
pandoc
-s
-t
html
\
--template
=
../_layouts/page
\
--filter
=
../tools/blockquote2div.py
\
--filter
=
../tools/filters/blockquote2div.py
\
--filter
=
../tools/filters/id4glossary.py
\
$(
INCLUDES
)
\
-o
$@
$<
...
...
This diff is collapsed.
Click to expand it.
tools/blockquote2div.py
→
tools/
filters/
blockquote2div.py
+
0
−
0
View file @
c21ab5b9
File moved
This diff is collapsed.
Click to expand it.
tools/filters/id4glossary.py
0 → 100755
+
35
−
0
View file @
c21ab5b9
#!/usr/bin/env python
"""
Pandoc filter to convert add ids to glossary entries.
Usage:
pandoc source.md --filter=id4glossary.py --output=output.html
"""
import
pandocfilters
as
pf
def
normalize_keyword
(
keyword
):
"""
Normalize keyword for became id
- Replace white space with
'
-
'
- Convert to lowercase
"""
return
keyword
.
lower
().
replace
(
'
'
,
'
-
'
)
def
keyword2html
(
keyword_node
):
"""
Return HTML version of keyword with id.
"""
keyword
=
pf
.
stringify
(
keyword_node
)
id
=
normalize_keyword
(
keyword
)
return
[{
"
t
"
:
"
Span
"
,
"
c
"
:
[[
id
,
[],[]],
keyword_node
]}]
def
id4glossary
(
key
,
value
,
format
,
meta
):
"""
Add id to keywords at glossary.
"""
if
"
subtitle
"
in
meta
and
pf
.
stringify
(
meta
[
'
subtitle
'
])
==
'
Reference
'
:
if
key
==
"
DefinitionList
"
:
for
definition
in
value
:
definition
[
0
]
=
keyword2html
(
definition
[
0
])
return
{
"
t
"
:
key
,
"
c
"
:
value
}
if
__name__
==
'
__main__
'
:
pf
.
toJSONFilter
(
id4glossary
)
This diff is collapsed.
Click to expand it.
Preview
0%
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