Confluence.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:SublimeConfluence 作者: mlf4aiur 项目源码 文件源码
def on_done_pages(self, idx):
        if idx == -1:
            return
        content_id = self.pages[idx]["id"]
        response = self.confluence_api.get_content_by_id(content_id)
        if response.ok:
            content = response.json()
            body = content["body"]["storage"]["value"]
            if HTML_PRETTIFY:
                document_root = lxml.html.fromstring(body)
                body = (lxml.etree.tostring(document_root, encoding="unicode", pretty_print=True))

            new_view = self.view.window().new_file()
            # set syntax file
            new_view.set_syntax_file("Packages/HTML/HTML.sublime-syntax")
            new_view.settings().set("auto_indent", False)

            # insert the page
            new_view.run_command("insert", {"characters": body})
            new_view.set_name(content["title"])
            new_view.settings().set("confluence_content", content)
            new_view.settings().set("auto_indent", True)
            new_view.run_command("reindent", {"single_line": False})
            new_view.run_command("expand_tabs", {"set_translate_tabs": True})

            # copy content url
            content_uri = self.confluence_api.get_content_uri(content)
            sublime.set_clipboard(content_uri)
            sublime.status_message(self.MSG_SUCCESS)
        else:
            print(response.text)
            sublime.error_message("Can not get content, reason: {}".format(response.reason))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号