From 16150de23e2f9f8fef5d2fd42839f7f2e377b285 Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Tue, 1 Dec 2020 16:04:42 +0100 Subject: [PATCH] README.md --- README.md | 51 +++++++++++++++ md2reveal.py | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f75b364 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# md2reveal + +It's an extremly basic +[Markdown](https://daringfireball.net/projects/markdown/) to +[reveal.js](https://revealjs.com/) conversion tool. + +Yes reveal already supports Markdown, but it needs specifically +crafted Markdown with strange separators which I don't personally +like. And yes you can also do this using pandoc but it mess with +syntax highlighting by handling it. + +## Usage + + md2reveal my_prez.md --output my_prez.html + +It's also allowed to skip the output file, so its name is guessed, the +previous command is equivalent to the following one: + + md2reveal my_prez.md + + +## Configuration + +There's not, deal with it, don't loose your time on fine-tuning, and +focus on your presentation. + +Still, you prefer a dark theme? It's unreadable on video projectors, +keep this one, trust me. + +You want bigger code blocks? You already have 12 lines and 61 columns, +if you stuff more, it won't be readable anyway, stick to it. + +You want a bigger font for your code blocks, so it's still readable +from the end of the room? I can understand that, I used to use a +bigger one too, let's talk in the issues. + + +## You're using a Makefile? + +Me too ♥ this should do: + +```Makefile +SRCS := $(wildcard *.md) +HTML := $(SRCS:.md=.html) + +.PHONY: static +static: $(HTML) + +%.html: %.md + md2reveal $< -o $@ +``` diff --git a/md2reveal.py b/md2reveal.py index 7deabf8..38b25b6 100644 --- a/md2reveal.py +++ b/md2reveal.py @@ -1,6 +1,7 @@ import re import tarfile import io +import sys from pathlib import Path import argparse @@ -20,7 +21,173 @@ TPL = """ - +
@@ -64,7 +231,7 @@ TPL = """ def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("md", help="Markdown input file") - parser.add_argument("html", help="HTML output file") + parser.add_argument("-o", "--output", dest="html", help="HTML output file") return parser.parse_args() @@ -76,6 +243,14 @@ REVEAL_ARCHIVE = ( def main(): args = parse_args() + if not args.html: + args.html = args.md.replace(".md", ".html") + if args.md == args.html: + print( + "You did not specified an output file, and I failed to guess it, " + "please use the --output option" + ) + sys.exit(1) tpl = jinja2.Template(TPL) root = Path(args.html).resolve().parent