想让 markdown
高亮,找了点插件,比如
https://github.com/jonschlinkert/sublime-markdown-extended
可以让代码块高亮。但没有达到我想要的效果,我想让markdown
的每个部分高亮,比如 # 标题 高亮。
然后找到了
这个达到了我的效果,但是将整个的 color scheme
都改了,自然不行。
现在的问题是——
继续寻找,然后找了这个
按照上面说的,将代码复制到我的 Obsidian.tmTheme
,成功了。在现有 color scheme
上高亮了 markdown
。
但是头疼的是,我不喜欢他的 标题 颜色,想改。看了代码,摘录一段:
<dict>
<key>name</key>
<string>Markup: Underline</string>
<key>scope</key>
<string>markup.underline</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#839496</string>
</dict>
</dict>
一头雾水,完全不知道 how does it working
,也就无从改起。
没有解决不了的问题,找了半天,这篇博客
Tips For Creating Sublime Text Color Schemes
解决了我的问题。其中的 tip1
尤其好——
Sublime text color schemes work by defining colors for scopes. A syntax definition matches the different parts of the file's text (e.g. functions, classes, keywords, etc.) and maps them to a named scope. Then the color scheme specifies what colors to use for what scopes. The hard part comes when you see a particular piece of syntax you want to style a specific way, but you do not know what scope it is. I did a lot of guess work until I discovered the ScopeHunter plugin. The ScopeHunter plugin allows you to select some text and it tells you what scope it matches. This removes the guess work and allows you to quickly color the pieces you want to.
sublime text 的 color scheme 是通过 scopes
来定义 color
的,我们可以安装插件 ScopeHunter
来查看光标出的 scopes
,从而可以自定义颜色。
<dict>
<key>name</key>
<string>Markup: Underline</string>
<key>scope</key> <!-- 这里就是 scope,知道了这个,其他就好办 -->
<string>markup.underline</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#839496</string>
</dict>
</dict>
至此,已经可以修改 markdown
到我想要的状态了。但是我又想,能不能把 markdown.md
的背景也改了, 甚至模仿 github
的样式。
少说多做,幸福一生。
<dict>
<key>name</key>
<string>Markdown</string>
<key>scope</key>
<string>text.html.markdown</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#ffffff</string>
<key>foreground</key>
<string>#666666</string>
</dict>
</dict>
马上把上面的代码加入color scheme
,有效果,嗯,现在比较大的问题是lineHighlight
(鼠标所在行高亮)比较突兀。
是个问题,并且 lineHighlight
没有 scope
,蛋疼了。
解决方式是调整全局 lineHighlight
的值,使其用透明度达到效果。
Perfect!
参考:
http://stackoverflow.com/questions/10636410/modifying-sublime-text-2-for-js
附上我的 color scheme
Obsidian.tmTheme
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Marcus Ekwall</string>
<key>modify</key>
<string>jerry</string>
<key>name</key>
<string>Obsidian</string>
<key>version</key>
<string>0.1</string>
<key>settings</key>
<array>
<!-- global -->
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#293134</string>
<key>caret</key>
<string>#E0E2E4</string>
<key>foreground</key>
<string>#81969A</string>
<key>invisibles</key>
<string>#BFBFBF</string>
<key>lineHighlight</key>
<string>#E5E5E520</string>
<key>selection</key>
<string>#0D0F0F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text base</string>
<key>scope</key>
<string>text</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#293134</string>
<key>foreground</key>
<string>#E0E2E4</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Source base</string>
<key>scope</key>
<string>source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#293134</string>
<key>foreground</key>
<string>#E0E2E4</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#66747B</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Block</string>
<key>scope</key>
<string>comment.block</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#66747B</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment Doc</string>
<key>scope</key>
<string>comment.documentation</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#66747B</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String</string>
<key>scope</key>
<string>string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#EC7600</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Number</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFCD22</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Built-in constant</string>
<key>scope</key>
<string>constant.language</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#93C763</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>User-defined constant</string>
<key>scope</key>
<string>constant.character, constant.other</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable</string>
<key>scope</key>
<string>variable.language, variable.other</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#678CB1</string>
</dict>
</dict>
<dict>
<key>name</key>
<string> Variable</string>
<key>scope</key>
<string>variable.language.js</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#93C763</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#93C763</string>
</dict>
</dict><dict><key>name</key><string>Operator</string><key>scope</key><string>keyword.operator</string><key>settings</key><dict><key>fontStyle</key><string></string><key>foreground</key><string>#E0E2E4</string></dict></dict><dict><key>name</key><string>Storage</string><key>scope</key><string>storage</string><key>settings</key><dict><key>fontStyle</key><string>bold</string><key>foreground</key><string>#93C763</string></dict></dict><dict><key>name</key><string>Class name</string><key>scope</key><string>entity.name.class</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict><dict><key>name</key><string>Inherited class</string><key>scope</key><string>entity.other.inherited-class</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict><dict><key>name</key><string>Function name</string><key>scope</key><string>entity.name.function</string><key>settings</key><dict><key>fontStyle</key><string>bold</string><key>foreground</key><string>#678CB1</string></dict></dict><dict><key>name</key><string>Function argument</string><key>scope</key><string>variable.parameter</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict><dict><key>name</key><string>Tag name</string><key>scope</key><string>entity.name.tag</string><key>settings</key><dict><key>fontStyle</key><string>bold</string><key>foreground</key><string>#408080</string></dict></dict><dict><key>name</key><string>Tag attribute</string><key>scope</key><string>entity.other.attribute-name</string><key>settings</key><dict><key>fontStyle</key><string>bold</string><key>foreground</key><string>#808040</string></dict></dict><dict><key>name</key><string>Library function</string><key>scope</key><string>support.function</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict><dict><key>name</key><string>Library constant</string><key>scope</key><string>support.constant</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict><dict><key>name</key><string>Library class/type</string><key>scope</key><string>support.type, support.class</string><key>settings</key><dict><key>fontStyle</key><string></string></dict></dict>