zoukankan      html  css  js  c++  java
  • iblog语法高亮示例

    --------------------------------------------------------------------------------------

    iblog 是一款 Sublime Text 2 博客插件,目前只支持cnblog。

    项目地址:https://github.com/iskeeter/iblog

    --------------------------------------------------------------------------------------

    使用以下语法指定代码所使用的语言:

    ```python
    # 代码写在这里
    ```
    

    下面是语法高亮示例:

    ```python
    class PublishCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            if self.view.is_dirty():
                sublime.error_message(u'【错误】请先保存在发布!')
                return
            self.header_region = _get_header_region(self.view)
            if not self.header_region:
                sublime.error_message(u'【错误】请填写头部的博客信息!可按<Shift+F8>插入博客信息模板')
                return
            # status: 0-没有执行,1-正在执行,2-执行成功并停止,3-执行失败停止
            self.status = 0 
            self.file_name = self.view.file_name()
            header_str = self.view.substr(self.header_region)
            self.blog_info = _parse_blog_info(header_str)
            # self.action: 1--新建,2--更新
            if not self.blog_info['blog_id']:
                self.action = 1 
            else:
                self.action = 2
            global blog_settings
            if not blog_settings:
                settings = _load_setting()
                blog_settings = {
                    'login_name': settings.get('login_name'),
                    'login_password': settings.get('login_password'),
                    'xml_rpc_url': settings.get('xml_rpc_url'),
                }
            file_type = check_file_type(self.file_name)
            content = ''
            if file_type == F_MD:
                region = sublime.Region(0, len(self.view))
                content = self._markdown2html(self.view.substr(region))
            else:
                body_region = sublime.Region(self.header_region.end(), len(self.view))
                content = header_str + _plain2html(self.view.substr(body_region))
            self.post = { 'title': self.blog_info['title'],
                    'description': content,
                    'link': '',
                    'author': blog_settings['login_name'],
                    'categories': self.blog_info['categories'],
                    'mt_keywords': ''
                }
            content = None
            self.server = xmlrpclib.ServerProxy(blog_settings['xml_rpc_url'], allow_none=True)
            self._pulish_async()
    ```
    

    输出后的效果:

    class PublishCommand(sublime_plugin.TextCommand):
        def run(self, edit):
            if self.view.is_dirty():
                sublime.error_message(u'【错误】请先保存在发布!')
                return
            self.header_region = _get_header_region(self.view)
            if not self.header_region:
                sublime.error_message(u'【错误】请填写头部的博客信息!可按<Shift+F8>插入博客信息模板')
                return
            # status: 0-没有执行,1-正在执行,2-执行成功并停止,3-执行失败停止
            self.status = 0 
            self.file_name = self.view.file_name()
            header_str = self.view.substr(self.header_region)
            self.blog_info = _parse_blog_info(header_str)
            # self.action: 1--新建,2--更新
            if not self.blog_info['blog_id']:
                self.action = 1 
            else:
                self.action = 2
            global blog_settings
            if not blog_settings:
                settings = _load_setting()
                blog_settings = {
                    'login_name': settings.get('login_name'),
                    'login_password': settings.get('login_password'),
                    'xml_rpc_url': settings.get('xml_rpc_url'),
                }
            file_type = check_file_type(self.file_name)
            content = ''
            if file_type == F_MD:
                region = sublime.Region(0, len(self.view))
                content = self._markdown2html(self.view.substr(region))
            else:
                body_region = sublime.Region(self.header_region.end(), len(self.view))
                content = header_str + _plain2html(self.view.substr(body_region))
            self.post = { 'title': self.blog_info['title'],
                    'description': content,
                    'link': '',
                    'author': blog_settings['login_name'],
                    'categories': self.blog_info['categories'],
                    'mt_keywords': ''
                }
            content = None
            self.server = xmlrpclib.ServerProxy(blog_settings['xml_rpc_url'], allow_none=True)
            self._pulish_async()
    
  • 相关阅读:
    面试题25二叉树中和为某一值得路径+递归函数详细解析
    [Codeforces 1199D]Welfare State(线段树)
    [Codeforces 1199C]MP3(离散化+二分答案)
    [Codeforces 1191D] Tokitsukaze, CSL and Stone Game(博弈论)
    [Codeforces 639F] Bear and Chemistry (Tarjan+虚树)(有详细注释)
    [HDU5807] [BestCoder Round #86 1004] Keep In Touch (DP)
    [Codeforces712D] Memory and Scores(DP+前缀和优化)(不用单调队列)
    [Codeforces722E] Research Rover (dp+组合数学)
    [POJ3612] Telephone Wire(暴力dp+剪枝)
    [Codeforces600E] Lomsat gelral(树上启发式合并)
  • 原文地址:https://www.cnblogs.com/skeeter/p/3463551.html
Copyright © 2011-2022 走看看