Compare commits

...

10 Commits

6 changed files with 113 additions and 61 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
__pycache__/
*.egg-info/
.envrc
.venv/

View File

@ -1,4 +1,4 @@
# md2reveal
# mdtoreveal
It's an extremly basic
[Markdown](https://daringfireball.net/projects/markdown/) to
@ -11,12 +11,43 @@ syntax highlighting by handling it.
## Usage
md2reveal my_prez.md --output my_prez.html
mdtoreveal 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
mdtoreveal my_prez.md
## Syntax
Let's start with pure Markdown:
# Big titles makes reveal.js "columns"
## Sub titles make reveal.js "slides" inside columns.
```python
print("Syntax highlighting works")
```
::: notes
Look, this is a personal note, it's not mandatory to use them, but you still can.
Everything betwen `::: notes` and the next slide is only visible by the presenter.
## 2nd slide
Blah blah …
## Example
It converts
[this](https://framagit.org/JulienPalard/atelier-perf/-/blob/master/perf.md)
into [this](https://julienpalard.frama.io/atelier-perf/perf.html)
(this one uses a
[.gitlab-ci.yml](https://framagit.org/JulienPalard/atelier-perf/-/blob/master/.gitlab-ci.yml)
to publish on push).
## Configuration
@ -47,5 +78,5 @@ HTML := $(SRCS:.md=.html)
static: $(HTML)
%.html: %.md
md2reveal $< -o $@
mdtoreveal $< -o $@
```

View File

@ -8,19 +8,7 @@ import argparse
import jinja2
import requests
TPL = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Prez</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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">
MDTOREVEAL_CSS = """
<style>
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
@ -188,6 +176,32 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
.reveal { font-family: sans-serif; }
</style>
"""
MDTOREVEAL_JS = """
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
disableLayout: false,
plugins: [ RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight ]
});
"""
TPL = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Prez</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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="mdtoreveal.css">
</head>
<body>
<div class="reveal">
@ -213,16 +227,7 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
<script src="{{ revealjs_url }}/plugin/search/search.js"></script>
<script src="{{ revealjs_url }}/plugin/markdown/markdown.js"></script>
<script src="{{ revealjs_url }}/plugin/highlight/highlight.js"></script>
<script>
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
disableLayout: false,
plugins: [ RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight ]
});
</script>
<script src="mdtoreveal.js"></script>
</body>
</html>
"""
@ -254,7 +259,10 @@ def main():
tpl = jinja2.Template(TPL)
root = Path(args.html).resolve().parent
reveal_path = root / f"reveal.js-{REVEAL_JS_VERSION}"
(root / "mdtoreveal.css").write_text(MDTOREVEAL_CSS)
(root / "mdtoreveal.js").write_text(MDTOREVEAL_JS)
reveal_dir = f"reveal.js-{REVEAL_JS_VERSION}"
reveal_path = root / reveal_dir
if not reveal_path.exists():
tarball = io.BytesIO(requests.get(REVEAL_ARCHIVE).content)
tarfile.open(fileobj=tarball, mode="r:gz").extractall(root)
@ -274,7 +282,7 @@ def main():
sections.append(slides)
with open(args.html, "w") as f:
f.write(tpl.render(slides=sections, revealjs_url=reveal_path))
f.write(tpl.render(slides=sections, revealjs_url=reveal_dir))
if __name__ == "__main__":

43
pyproject.toml Normal file
View File

@ -0,0 +1,43 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"
[project]
name = "mdtoreveal"
version = "0.3.3"
description = "Transform a flat markdown to a reveal.js presentation."
authors = [
{ name = "Julien Palard", email = "julien@palard.fr" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
]
requires-python = ">= 3.6"
dependencies = [
"jinja2",
"requests",
"markdown",
]
[project.readme]
file = "README.md"
content-type = "text/markdown; charset=UTF-8"
[project.license]
text = "MIT License"
[project.urls]
Homepage = "https://git.afpy.org/mdk/mdtoreveal"
[project.scripts]
mdtoreveal = "mdtoreveal:main"
[tool.setuptools]
py-modules = [
"mdtoreveal",
]
include-package-data = false

View File

@ -1,29 +0,0 @@
[metadata]
name = md2reveal
version = 0.1
description = Transform a flat markdown to a reveal.js presentation.
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
author = Julien Palard
author_email = julien@palard.fr
url = https://github.com/JulienPalard/md2reveal
license = MIT License
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Natural Language :: English
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
[options]
py_modules = md2reveal
python_requires = >= 3.6
install_requires =
jinja2
requests
[options.entry_points]
console_scripts = md2reveal=md2reveal:main

View File

@ -1,3 +0,0 @@
import setuptools
setuptools.setup()