mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-03-03 01:40:19 +00:00
Patch up TOC generator
This commit is contained in:
@@ -3,38 +3,17 @@
|
||||
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?",
|
||||
separators = [
|
||||
"---",
|
||||
"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))
|
||||
slide_count = 1
|
||||
for line in open("index.html"):
|
||||
line = line.strip()
|
||||
if line in separators:
|
||||
slide_count += 1
|
||||
if line.startswith('# '):
|
||||
print slide_count, '# #', line
|
||||
elif line.startswith('# '):
|
||||
print slide_count, line
|
||||
|
||||
@@ -3213,8 +3213,7 @@ for BIN in snapd snapctl; do ln -s /opt/snap/bin/$BIN /usr/local/bin/$BIN; done
|
||||
|
||||
## Our first task manifest
|
||||
|
||||
```json
|
||||
---
|
||||
```yaml
|
||||
version: 1
|
||||
schedule:
|
||||
type: "simple" # collect on a set interval
|
||||
|
||||
Reference in New Issue
Block a user