Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reuse of io2012 and io2011 markup style #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MarkdownSlideshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MarkdownSlideshowCommand(sublime_plugin.TextCommand):
def run(self, edit):
settings = sublime.load_settings('MarkdownSlideshow.sublime-settings')
themes = settings.get('themes', None)
theme = settings.get('theme', 'io2012')
theme_processor = settings.get('theme_processor', 'io2012')
extensions = settings.get('extensions', [])
output_file = settings.get('output_file', None)
clean = settings.get('clean', False)
Expand All @@ -36,6 +36,7 @@ def run(self, edit):
opts = {
'themes': themes,
'theme': theme,
'theme_processor': theme_processor,
'contents': self.view.substr(sublime.Region(0, self.view.size())),
'extensions': extensions,
'clean': clean
Expand Down
3 changes: 3 additions & 0 deletions MarkdownSlideshow.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

// Theme of the slide. (io2012, io2011, ...)
"theme" : "io2012",

// Processor used to Render the slide. (io2012, io2011, ...)
"theme_processor" : "io2012",

// Provided to expand the base syntax. (extra, fenced_code, tables, ...)
"extensions": [],
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ $ git clone git://github.com/ogom/sublimetext-markdown-slideshow.git
// Theme of the slide. (io2012, io2011, ...)
"theme" : "io2012",

// Theme of the slide. (io2012, io2011, ...)
"theme_processor" : "io2012",

// Provided to expand the base syntax. (extra, fenced_code, tables, ...)
"extensions": [],

Expand Down
11 changes: 7 additions & 4 deletions lib/mcider/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Slide():
""" opts
.themes themes path
.theme io2012(default) or io2011
.theme_processor io2012(default) or io2011
.contents
.extensions extra fenced_code tables, ...
.clean (boolean, default False)
Expand All @@ -31,6 +32,8 @@ def __init__(self, opts):
raise KeyError('themes')
if 'theme' not in self.options:
self.options['theme'] = 'io2012'
if 'theme_processor' not in self.options:
self.options['theme_processor'] = self.options['theme']
if 'contents' not in self.options:
self.options['contents'] = None
if 'extensions' not in self.options:
Expand All @@ -44,7 +47,7 @@ def __init__(self, opts):
def maker(self, output_path=None):
theme_path = os.path.abspath(os.path.join(self.options['themes'], self.options['theme']))
template = self._get_template(output_path, theme_path, self.options['clean'])
slide = self._get_slide(self.options['theme'], self.options['contents'], self.options['extensions'])
slide = self._get_slide(self.options['theme'], self.options['theme_processor'], self.options['contents'], self.options['extensions'])
return template.replace('{{ slide }}', slide)

def _get_template(self, output_path=None, theme_path=None, clean=False):
Expand All @@ -60,11 +63,11 @@ def _get_template(self, output_path=None, theme_path=None, clean=False):
shutil.copytree(src_path, dst_path)
return util.fs_reader(os.path.join(theme_path, 'base.html'))

def _get_slide(self, theme=None, contents=None, extensions=[]):
def _get_slide(self, theme=None, theme_processor=None, contents=None, extensions=[]):
html = None
if theme == 'io2011':
if theme_processor == 'io2011':
html = self._get_slide_io2011(contents, extensions)
elif theme == 'io2012':
elif theme_processor == 'io2012':
html = self._get_slide_io2012(contents, extensions)
else:
html = self._get_slide_none(contents, extensions)
Expand Down