This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
__version__ = get_versions()['version'] | ||
del get_versions | ||
|
||
from . import presentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
import click | ||
import pkg_resources | ||
from . import presentation | ||
|
||
DEFAULT_HTML_FILE = pkg_resources.resource_filename('remarker', 'templates/default.html') | ||
DEFAULT_CSS_FILE = pkg_resources.resource_filename('remarker', 'templates/default.css') | ||
|
||
def loadfile(filename): | ||
with open(filename) as infile: | ||
return infile.read() | ||
|
||
@click.argument('slides_markdown_file', type=click.Path(exists=True)) | ||
@click.option('--html-template', type=click.Path(exists=True), | ||
default=DEFAULT_HTML_FILE) | ||
@click.option('--css-file', type=click.Path(exists=True), | ||
default=DEFAULT_CSS_FILE) | ||
@click.option('--output-file', '-o', type=click.Path(), | ||
default='presentaiton.html') | ||
@click.option('--title', '-t', default='Presentation') | ||
@click.option('--verbose', '-v', is_flag=True) | ||
@click.command() | ||
def cli(): | ||
click.echo("Hello, World!") | ||
def remarker(slides_markdown_file, html_template, css_file, output_file, | ||
title, verbose): | ||
if verbose: | ||
click.echo('Input:') | ||
click.echo('slides_markdown_file: {}'.format(slides_markdown_file)) | ||
click.echo('html-template: {}'.format(html_template)) | ||
click.echo('css-file: {}'.format(css_file)) | ||
click.echo('Output file: {}'.format(output_file)) | ||
|
||
|
||
template_html = loadfile(html_template) | ||
slide_markdown = loadfile(slides_markdown_file) | ||
stylesheet_html = loadfile(css_file) | ||
|
||
click.echo(stylesheet_html) | ||
with open(output_file, 'w') as outfile: | ||
output_html = presentation.generate_html(template_html, slide_markdown, | ||
stylesheet_html, title=title) | ||
outfile.write(output_html) | ||
|
||
if __name__ == '__main__': | ||
cli() | ||
remarker() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from jinja2 import Template | ||
|
||
DEFAULT_JAVASCRIPT = """ | ||
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script> | ||
<script>var slideshow = remark.create();</script>""" | ||
|
||
def generate_html(template_html, slide_markdown, stylesheet_html, title=None): | ||
""" Generate HTML for a Reveal.js presentation given a template_html, | ||
slide_markdown contents, and stylesheet_html. """ | ||
|
||
# only support inline css for now, maybe links in the future | ||
stylesheet_html = '<style>\n{0}</style'.format(stylesheet_html) | ||
presentation = { | ||
'stylesheet_html': stylesheet_html, | ||
'slide_source': slide_markdown, | ||
'title': title, | ||
} | ||
remark = { | ||
'javascript': DEFAULT_JAVASCRIPT, | ||
} | ||
template = Template(template_html) | ||
return template.render(presentation=presentation, remark=remark) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
click | ||
jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
class: center, middle | ||
|
||
# Title | ||
|
||
--- | ||
|
||
# Agenda | ||
|
||
1. Introduction | ||
2. Deep-dive | ||
3. ... | ||
|
||
--- | ||
|
||
# Introduction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Presentation</title> | ||
<meta charset="utf-8"> | ||
<style> | ||
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); | ||
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); | ||
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic); | ||
|
||
body { font-family: 'Droid Serif'; } | ||
h1, h2, h3 { | ||
font-family: 'Yanone Kaffeesatz'; | ||
font-weight: normal; | ||
} | ||
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; } | ||
</style | ||
</head> | ||
<body> | ||
<textarea id="source"> | ||
|
||
class: center, middle | ||
|
||
# Title | ||
|
||
--- | ||
|
||
# Agenda | ||
|
||
1. Introduction | ||
2. Deep-dive | ||
3. ... | ||
|
||
--- | ||
|
||
# Introduction | ||
|
||
|
||
</textarea> | ||
|
||
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script> | ||
<script>var slideshow = remark.create();</script> | ||
</body> | ||
</html> |