Skip to content
Browse files

option to use css or not, and specify charset

  • Loading branch information...
1 parent ff5b8ef commit 45e29f2b7d80cff9b885e9c3e7ed94c4cbf19cb7 @erinata committed
Showing with 13 additions and 12 deletions.
  1. +10 −11 MarkdownBuild.py
  2. +3 −1 MarkdownBuild.sublime-settings
View
21 MarkdownBuild.py
@@ -5,15 +5,15 @@
import tempfile
import webbrowser
-#TODO: option to generate html using the same name as the markdown file
-#TODO: option to use or not using css
#TODO: option to embedded the css into the file or using external file
-#TODO: option to set charset
#TODO: Some way to make html prettier?
class MarkdownBuild(sublime_plugin.WindowCommand):
def run(self):
s = sublime.load_settings("MarkdownBuild.sublime-settings")
output_html = s.get("output_html", False)
+ use_css = s.get("use_css", True)
+ charset = s.get("charset", "UTF-8")
+
view = self.window.active_view()
if not view:
return
@@ -22,14 +22,13 @@ def run(self):
return
contents = view.substr(sublime.Region(0, view.size()))
md = markdown_python.markdown(contents)
- html = '<html><meta charset="UTF-8">'
- css = os.path.join(sublime.packages_path(), 'MarkdownBuild', 'markdown.css')
- if (os.path.isfile(css)):
- styles = open(css, 'r').read()
- html += '<style>' + styles + '</style>'
- html += "<body>"
- html += md
- html += "</body></html>"
+ html = '<html><meta charset="' + charset + '">'
+ if use_css:
+ css = os.path.join(sublime.packages_path(), 'MarkdownBuild', 'markdown.css')
+ if (os.path.isfile(css)):
+ styles = open(css, 'r').read()
+ html += '<style>' + styles + '</style>'
+ html += "<body>" + md + "</body></html>"
if output_html:
html_name = os.path.splitext(file_name)[0]
View
4 MarkdownBuild.sublime-settings
@@ -1,4 +1,6 @@
{
"output_html" : false,
- "focus_sublime" : true
+ "use_css" : true,
+ "focus_sublime" : true,
+ "charset" : "UTF-8"
}

0 comments on commit 45e29f2

Please sign in to comment.
Something went wrong with that request. Please try again.