mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-18 04:19:43 +00:00
Merge pull request #22 from soulshake/master
Add script to extract section title
This commit is contained in:
@@ -22,10 +22,6 @@ Required environment variables:
|
||||
|
||||
### 4. Update settings.yaml
|
||||
|
||||
If you have more than one workshop:
|
||||
|
||||
$ cp settings/default.yaml settings/YOUR_WORKSHOP_NAME-settings.yaml
|
||||
|
||||
Then pass `settings/YOUR_WORKSHOP_NAME-settings.yaml` as an argument to `deploy`, `cards`, etc.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -13,7 +13,7 @@ def prettify(l):
|
||||
return ret
|
||||
|
||||
|
||||
# Read settings from settings.yaml
|
||||
# Read settings from user-provided settings file
|
||||
with open(sys.argv[1]) as f:
|
||||
data = f.read()
|
||||
|
||||
|
||||
40
www/extract-section-titles.py
Executable file
40
www/extract-section-titles.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Extract and print level 1 and 2 titles from workshop slides.
|
||||
"""
|
||||
|
||||
with open("htdocs/index.html", "r") as f:
|
||||
data = f.read()
|
||||
|
||||
# @jpetazzo abuses "class: title" to make a point sometimes
|
||||
skip = [
|
||||
"Why?",
|
||||
"---",
|
||||
"But ...",
|
||||
"WHY?!?",
|
||||
]
|
||||
|
||||
# Ditch linebreaks from main section titles
|
||||
replace = [
|
||||
"<br/>",
|
||||
]
|
||||
|
||||
# remove blank lines
|
||||
sections = [x for x in data.split('\n') if x] # and x not in skip]
|
||||
sections = "\n".join(sections)
|
||||
sections = sections.split('class: title')
|
||||
del(sections[0]) # delete the CSS frontmatter
|
||||
|
||||
for section in sections:
|
||||
lines = [x for x in section.split("\n") if x]
|
||||
|
||||
if lines[0] not in skip:
|
||||
title = lines[0]
|
||||
title = title.replace("<br/> ", "")
|
||||
title = title.replace("# ", "")
|
||||
del(lines[0])
|
||||
print("{}".format(title))
|
||||
|
||||
titles = [x[2:] for x in lines if x.startswith("# ")]
|
||||
for title in titles:
|
||||
print("\t{}".format(title))
|
||||
Reference in New Issue
Block a user