README.md
This commit is contained in:
parent
7f1bb87f34
commit
16150de23e
|
@ -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 $@
|
||||
```
|
179
md2reveal.py
179
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 = """
|
|||
<link rel="stylesheet" href="{{ revealjs_url }}/dist/reset.css">
|
||||
<link rel="stylesheet" href="{{ revealjs_url }}/dist/reveal.css">
|
||||
<link rel="stylesheet" href="{{ revealjs_url }}/dist/theme/simple.css" id="theme">
|
||||
<link rel="stylesheet" href="{{ revealjs_url }}/plugin/highlight/monokai.css" id="highlight-theme">
|
||||
<style>
|
||||
a.sourceLine { display: inline-block; line-height: 1.25; }
|
||||
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
|
||||
a.sourceLine:empty { height: 1.2em; }
|
||||
.sourceCode { overflow: visible; }
|
||||
code.sourceCode { white-space: pre; position: relative; }
|
||||
div.sourceCode {
|
||||
margin: 1em 0;
|
||||
color: #333;
|
||||
background: #f8f8f8;
|
||||
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
pre.sourceCode { margin: 0; }
|
||||
@media screen {
|
||||
div.sourceCode { overflow: auto; }
|
||||
}
|
||||
@media print {
|
||||
code.sourceCode { white-space: pre-wrap; }
|
||||
a.sourceLine { text-indent: -1em; padding-left: 1em; }
|
||||
}
|
||||
pre.numberSource a.sourceLine
|
||||
{ position: relative; left: -4em; }
|
||||
pre.numberSource a.sourceLine::before
|
||||
{ content: attr(title);
|
||||
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
||||
border: none; pointer-events: all; display: inline-block;
|
||||
-webkit-touch-callout: none; -webkit-user-select: none;
|
||||
-khtml-user-select: none; -moz-user-select: none;
|
||||
-ms-user-select: none; user-select: none;
|
||||
padding: 0 4px; width: 4em;
|
||||
color: #aaaaaa;
|
||||
}
|
||||
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
||||
div.sourceCode
|
||||
{ }
|
||||
@media screen {
|
||||
a.sourceLine::before { text-decoration: underline; }
|
||||
}
|
||||
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
||||
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
||||
code span.at { color: #7d9029; } /* Attribute */
|
||||
code span.bn { color: #40a070; } /* BaseN */
|
||||
code span.bu { } /* BuiltIn */
|
||||
code span.cf { color: #333; font-weight: bold; } /* ControlFlow */
|
||||
code span.ch { color: #4070a0; } /* Char */
|
||||
code span.cn { color: #880000; } /* Constant */
|
||||
code span.co { color: #998; font-style: italic; } /* Comment */
|
||||
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
||||
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
||||
code span.dt { color: #902000; } /* DataType */
|
||||
code span.dv { color: #008080; } /* DecVal */
|
||||
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
||||
code span.ex { } /* Extension */
|
||||
code span.fl { color: #008080; } /* Float */
|
||||
code span.fu { color: #06287e; } /* Function */
|
||||
code span.im { } /* Import */
|
||||
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
||||
code span.kw { color: #333; font-weight: bold; } /* Keyword */
|
||||
code span.op { color: #666666; } /* Operator */
|
||||
code span.ot { color: #008080; } /* Other */
|
||||
code span.pp { color: #bc7a00; } /* Preprocessor */
|
||||
code span.sc { color: #4070a0; } /* SpecialChar */
|
||||
code span.ss { color: #bb6688; } /* SpecialString */
|
||||
code span.st { color: #d14; } /* String */
|
||||
code span.va { color: #008080; } /* Variable */
|
||||
code span.vs { color: #4070a0; } /* VerbatimString */
|
||||
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
color: #333;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #998;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-subst {
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-number,
|
||||
.hljs-literal,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-tag .hljs-attr {
|
||||
color: #008080;
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-doctag {
|
||||
color: #d14;
|
||||
}
|
||||
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-selector-id {
|
||||
color: #900;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-subst {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-type,
|
||||
.hljs-class .hljs-title {
|
||||
color: #458;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-tag,
|
||||
.hljs-name,
|
||||
.hljs-attribute {
|
||||
color: #000080;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: #009926;
|
||||
}
|
||||
|
||||
.hljs-symbol,
|
||||
.hljs-bullet {
|
||||
color: #990073;
|
||||
}
|
||||
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name {
|
||||
color: #0086b3;
|
||||
}
|
||||
|
||||
.hljs-meta {
|
||||
color: #999;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.hljs-deletion {
|
||||
background: #fdd;
|
||||
}
|
||||
|
||||
.hljs-addition {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
.reveal section img { border: none; }
|
||||
.reveal pre { width: 100%; font-size: .65em;}
|
||||
.reveal h2 { font-family: sans-serif; }
|
||||
.reveal { font-family: sans-serif; }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="reveal">
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue