Skip to content

Commit

Permalink
Implement remark presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Oct 13, 2013
1 parent 9005d62 commit c3f176c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions remarkable/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
remarkable.
Usage:
remarkable [options] command <param> <another_params>
remarkable [options] another-command <param>
remarkable [options] remark <path-to-markdown-file>
remarkable -h | --help
Expand All @@ -14,9 +14,11 @@
-h --help Show this screen.
"""
import logging

from docopt import docopt
import logging

from jinja2 import Environment, PackageLoader

import remarkable

Expand All @@ -28,3 +30,19 @@ def main():
debug = arguments['--debug']
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
log.debug('arguments: %s', arguments)

if arguments['remark']:
file_name = arguments['<path-to-markdown-file>']
html_file_name = '%s.html' % file_name

html = render_remark(open(file_name).read())
with open(html_file_name, 'w') as html_file:
html_file.write(html)
log.info('Created %s' % html_file_name)


def render_remark(markdown):
loader = PackageLoader('remarkable', 'templates')
env = Environment(loader=loader)
template = env.get_template('remark.html')
return template.render({'markdown': markdown})

0 comments on commit c3f176c

Please sign in to comment.