diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2016-05-16 15:43:25 +0100 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2016-05-16 15:43:25 +0100 |
commit | 46c308b58d396240975c7cb7042e5aab9fecdfb3 (patch) | |
tree | 47eaaec4a6de622cb38989dcbf24e21d85e09982 | |
parent | 010c5fd2743fe457f9799db4c697748c4bd080bf (diff) |
split-topics: Add support for DRAFT questions
If a question contains the word DRAFT anywhere in it then the splitter
will not include the draft question in the output.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
-rw-r--r-- | split-topics.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/split-topics.py b/split-topics.py index 1f9b9e5..56d96d0 100644 --- a/split-topics.py +++ b/split-topics.py @@ -4,15 +4,22 @@ import sys for fname in sys.argv[1:]: with open(fname) as f: - g = open('front-matter.md', 'w') + draft = False + g = None for ln in f.readlines(): if ln.strip().startswith('# '): - g.close() + if g: + g.close() gname = ln[1:].strip().replace(' ', '-')+'.md' g = open(gname, 'w') continue - g.write(ln) + if '**' in ln and 'Q:' in ln and '?' in ln: + draft = 'DRAFT' in ln - g.close() + if g and not draft: + g.write(ln) + + if g: + g.close() |