在 Sublime Text 2 中突出显示 Github README.md 格式

2023-12-24

我有 README 文件,我希望 Sublime 仅突出显示由某些“标签”标识的某些代码片段,例如:

Here is an example of usage

# This should be highlighted
```ruby
  superhero = Superhero.new
  superhero.make_world_better
```

or with [code lang=ruby]管他呢


懒惰的回答

(for independent fast learners)

  1. 安装包控制 崇高文本 https://packagecontrol.io/packages/Package%20Control.
  2. 重新启动 sublime-text 后,请参阅“快速回答”。

快速答复

(for intermediate to advanced sublime-text users)

  1. Ctrl+Shift+P and Package Control: Install Package, then install Knockdown https://github.com/aziz/knockdown.

    就是这样,现在你有一个Set Syntax: Markdown (Github flavored)触手可及的选项。


详细解答

(powerless to powerfull)

- 安装Package Control

  1. Open sublime-text.
    [If you need this functionality available when you edit files on a directory owned by root or www-data ( i.e. /var/www/ ) you may want to open sublime with admin privileges using gksu sublime or similar and repeat every step]

  2. Activate sublime's console by pressing ctr+`
    [That is CONTROL key plus GRAVE ACCENT key (usually above the TAB key)]

  1. Copy-paste one of the following options to sublime console's prompt. (and press enter):

    如果是 sublime-text 2:

    import urllib2,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')
    

    如果是 sublime-text 3:

    import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
    
  1. Close sublime when the console prints back a message saying "Please restart Sublime Text to finish installation" (usually almost instantaneous). Open sublime-text again.

  2. Once you restarted sublime-text, the rest is easy, see "Fast Answer" (above), or read on.

关于使用包控制

您刚刚安装的内容向您的Palette并打开了通向社区贡献插件的美妙世界的大门;一种由其他人或您自己扩展 sublime 功能的方法! (分享您的代码!)。
现在让我们用它来安装knockdown.

  1. You can access Package Controll simply by pressing ctr+shift+P, and typing Package Control, pc, pack (or anything similar thanks to the fuzzy search feature of the command palette), in this case search the right command by writing Package Control: Install Package (or just pi).
    (If something goes wrong you can always Remove Package).
  1. To see all the available packages just enter or click on it. Sublime will search for all the registered packages and will even check and show for you only the ones that are compatible with your version of sublime-text, you'll have to wait a few seconds.
    (or less than a second, depending on your internet+computer latency+speed).
  1. 现在搜索并选择knockdown.
  1. After you hit Enter or click on it it will take a brief moment to install.

就是这样, 它就是有效的.


## - How to use it you ask?

要在当前加载的缓冲区中激活此突出显示:

(lets say "the open file")

  1. Inside sublime-text and with a .md file opened, press ctr+shift+P again.
  2. Search for Set Syntax: Markdown (Github Flavored) and enter or click on it. enter image description here

IF you want to activate for all .md files (that's a big IF)

On current version (Latest Sublime Text 2 releases & any ver 3 release):
  • 浏览以下菜单:View -> Syntax -> Open all with current extension as... ->[your syntax choice].
On previous versions of sublime:
  • Go to a Packages/User、创建(或编辑).sublime-settings文件 以您要添加扩展的语法命名,Markdown (Github Flavored).sublime-settings在你的情况下,那么 在那里写下这样的东西:


    {
        "extensions":
        [
            "md"
        ]
    }
   

然后重启Sublime Text

...图片,否则它就不会发生:

(it totally works! here's the evidence) enter image description here

presto!
我希望你在成为一名 Sublime Text 大师方面又迈出了一步我的答案帮助了你

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Sublime Text 2 中突出显示 Github README.md 格式 的相关文章

随机推荐