SublimeMarkdownBuild icon indicating copy to clipboard operation
SublimeMarkdownBuild copied to clipboard

Specify custom CSS file

Open christiangenco opened this issue 13 years ago • 5 comments

SublimeMarkdownBuild is a better plugin than sublimetext-markdown-preview, but I prefer how their pages look (formatted with something called "clownfart markdown css" that I can't seem to find).

Could you add an option to specify a custom CSS file to be inserted into the document?

christiangenco avatar Sep 14 '12 16:09 christiangenco

There is a file named markdown.css in the plugin folder. You can overwrite that file with the css you like.

I can make it an option later. (leave this issue open to remind me ^_^)

erinata avatar Sep 14 '12 16:09 erinata

That's what I'll do in the meantime, thanks! :D

Will it get overwritten if the plugin gets updated or something?

christiangenco avatar Sep 14 '12 16:09 christiangenco

Yes it will. So you better back up your custom css file. sorry for the inconvenience.

erinata avatar Sep 14 '12 16:09 erinata

Ooo, better short-term solution:

  1. Put your custom markdown CSS in a central place (like in your dotfiles directory)
mkdir -p ~/dotfiles/markdown_css/
wget https://raw.github.com/revolunet/sublimetext-markdown-preview/master/markdown.css -O ~/dotfiles/markdown_css
  1. Symlink the custom css to the MarkdownBuild style.css file
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/MarkdownBuild
rm markdown.css
ln ~/dotfiles/markdown_css/clownfart.css markdown.css

Now when it auto-updates, just re-symlink the custom file :D


Note: for this css file in particular, I had to remove the "微软雅黑" characters for it to work.

christiangenco avatar Sep 14 '12 19:09 christiangenco

Would adding a conditional that checks for custom.css and uses that if found and markdown.css if not to MarkdownBuild.py be enough or is this more complicated than that?

Something like this:

if use_css:
    customcss =  = os.path.join(sublime.packages_path(), 'MarkdownBuild', 'custom.css')
    css = os.path.join(sublime.packages_path(), 'MarkdownBuild', 'markdown.css')
    if (os.path.isfile(customcss))::
        styles = open(customcss, 'r').read()
        html += '<style>' + styles + '</style>'
    elif (os.path.isfile(css)):
        styles = open(css, 'r').read()
        html += '<style>' + styles + '</style>'

sbaney avatar Jan 22 '13 16:01 sbaney