使用org-mode写cnblogs博客
使用org-mode写cnblogs博客
*/-->
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
pre.src {background-color: #002b36; color: #839496;}
使用org-mode写cnblogs博客
Table of Contents
1 下载
https://github.com/yangwen0228/unimacs/tree/master/packages/vendor/cnblogs
这个插件是下载的cnblogs , 但作者好像很久没有更新了,而我们org-mode更新之后,org-html-export-as-html的行为有些改变,不能使用异步的方式了,导致插件使用不了。所以需要把异步改为同步,另外需要把org-export-show-temporary-export-buffer设置为nil,即导出的临时buffer在后台不可见。
(cons "description"
(let ((org-export-show-temporary-export-buffer nil))
(with-current-buffer (org-html-export-as-html nil nil nil nil nil)
(let ((buf-str (cnblogs-replace-media-object-location
(buffer-substring-no-properties
(point-min) (point-max)))))
(kill-buffer)
buf-str))))
具体的使用方法可以参加原作者的博客:
http://www.cnblogs.com/Open_Source/archive/2012/09/14/2684897.html
还有csophys的这两篇文章也写得很好:
http://www.cnblogs.com/csophys/archive/2012/04/26/2471667.html#2542335
http://www.cnblogs.com/csophys/archive/2012/11/16/2773812.html
2 配置
设置cnblogs的url和username,然后,Alt+x运行cnblogs-setup-blog,依次输入博客的名称(一般和用户名相同,比如我的是yangwen0228),用户名和密码就可以了。
(use-package cnblogs
:ensure nil
:init
(require 'cnblogs)
(cnblogs-minor-mode t)
;; Run command: cnblogs-setup-blog to set up.
(bind-keys ("C-c c p" . cnblogs-post)
("C-c c n" . cnblogs-new-post)
("C-c c e" . cnblogs-edit-post)
("C-c c d" . cnblogs-delete-post))
;; Bugfix: error url-http-create-request: Multibyte text in HTTP request
;; @ http://www.cnblogs.com/yangwen0228/p/6238528.html
(defun url-http-create-request (&optional ref-url)
"Create an HTTP request for `url-http-target-url', referred to by REF-URL."
(let* ((extra-headers)
(request nil)
(no-cache (cdr-safe (assoc "Pragma" url-http-extra-headers)))
(using-proxy url-http-proxy)
(proxy-auth (if (or (cdr-safe (assoc "Proxy-Authorization"
url-http-extra-headers))
(not using-proxy))
nil
(let ((url-basic-auth-storage
'url-http-proxy-basic-auth-storage))
(url-get-authentication url-http-proxy nil 'any nil))))
(real-fname (url-filename url-http-target-url))
(host (url-http--encode-string (url-host url-http-target-url)))
(auth (if (cdr-safe (assoc "Authorization" url-http-extra-headers))
nil
(url-get-authentication (or
(and (boundp 'proxy-info)
proxy-info)
url-http-target-url) nil 'any nil))))
(if (equal "" real-fname)
(setq real-fname "/"))
(setq no-cache (and no-cache (string-match "no-cache" no-cache)))
(if auth
(setq auth (concat "Authorization: " auth "\r\n")))
(if proxy-auth
(setq proxy-auth (concat "Proxy-Authorization: " proxy-auth "\r\n"))) ;; Protection against stupid values in the referrer
(if (and ref-url (stringp ref-url) (or (string= ref-url "file:nil")
(string= ref-url "")))
(setq ref-url nil)) ;; We do not want to expose the referrer if the user is paranoid.
(if (or (memq url-privacy-level '(low high paranoid))
(and (listp url-privacy-level)
(memq 'lastloc url-privacy-level)))
(setq ref-url nil)) ;; url-http-extra-headers contains an assoc-list of
;; header/value pairs that we need to put into the request.
(setq extra-headers (mapconcat
(lambda (x)
(concat (car x) ": " (cdr x)))
url-http-extra-headers "\r\n"))
(if (not (equal extra-headers ""))
(setq extra-headers (concat extra-headers "\r\n"))) ;; This was done with a call to `format'. Concatenating parts has
;; the advantage of keeping the parts of each header together and
;; allows us to elide null lines directly, at the cost of making
;; the layout less clear.
(setq request
(concat
;; The request
(or url-http-method "GET") " "
(url-http--encode-string
(if using-proxy (url-recreate-url url-http-target-url) real-fname))
" HTTP/" url-http-version "\r\n"
;; Version of MIME we speak
"MIME-Version: 1.0\r\n"
;; (maybe) Try to keep the connection open
"Connection: " (if (or using-proxy
(not url-http-attempt-keepalives))
"close" "keep-alive") "\r\n"
;; HTTP extensions we support
(if url-extensions-header
(format
"Extension: %s\r\n" url-extensions-header))
;; Who we want to talk to
(if (/= (url-port url-http-target-url)
(url-scheme-get-property
(url-type url-http-target-url) 'default-port))
(format
"Host: %s:%d\r\n" (puny-encode-domain host)
(url-port url-http-target-url))
(format "Host: %s\r\n" (puny-encode-domain host)))
;; Who its from
(if url-personal-mail-address
(concat
"From: " url-personal-mail-address "\r\n"))
;; Encodings we understand
(if (or url-mime-encoding-string
;; MS-Windows loads zlib dynamically, so recheck
;; in case they made it available since
;; initialization in url-vars.el.
(and (eq 'system-type 'windows-nt)
(fboundp 'zlib-available-p)
(zlib-available-p)
(setq url-mime-encoding-string "gzip")))
(concat
"Accept-encoding: " url-mime-encoding-string "\r\n"))
(if url-mime-charset-string
(concat
"Accept-charset: "
(url-http--encode-string url-mime-charset-string)
"\r\n"))
;; Languages we understand
(if url-mime-language-string
(concat
"Accept-language: " url-mime-language-string "\r\n"))
;; Types we understand
"Accept: " (or url-mime-accept-string "*/*") "\r\n"
;; User agent
(url-http-user-agent-string)
;; Proxy Authorization
proxy-auth
;; Authorization
auth
;; Cookies
(when (url-use-cookies url-http-target-url)
(url-http--encode-string
(url-cookie-generate-header-lines
host real-fname
(equal "https" (url-type url-http-target-url)))))
;; If-modified-since
(if (and (not no-cache)
(member url-http-method '("GET" nil)))
(let ((tm (url-is-cached url-http-target-url)))
(if tm
(concat "If-modified-since: "
(url-get-normalized-date tm) "\r\n"))))
;; Whence we came
(if ref-url (concat
"Referer: " ref-url "\r\n"))
extra-headers
;; Length of data
(if url-http-data
(concat
"Content-length: " (number-to-string
(length url-http-data))
"\r\n"))
;; End request
"\r\n"
;; Any data
url-http-data))
;; Bug#23750
(setq request (url-http--encode-string request))
(unless (= (string-bytes request)
(length request))
(error "Multibyte text in HTTP request: %s" request))
(url-http-debug "Request is: \n%s" request)
request))
)
3 使用org写文章
用org写文章,org-mode可以去看org-mode的官网,或者是其他的教程介绍,一旦用上,就再也离不开了。
3.1 tags
其中有几个常用的tags:
- TITLE
- CATEGORIES
- DESCRIPTION
- KEYWORDS
- DATE
因为这是每次写cnblogs都需要的,所以,我做了一个snippet:
#+TITLE: $
#+CATEGORIES: ${2:Emacs}
#+DESCRIPTION: ${3:}
#+KEYWORDS: $
#+DATE: `(format-time-string "%Y-%m-%d %H:%M")`
这样,每次写博客之前,只需要输入cnblogs,然后tab一下,就可以把这个插入到文章的开头了,然后根据实际需要再填入相关的信息。
3.2 code blocks
默认的code block的配色只取front-face的颜色,背景是浅色或白色的,显示的效果不太好,使用下面的配置,就是可以和Emacs中显示的效果一模一样了。
;; @ http://emacs.stackexchange.com/questions/3374/set-the-background-of-org-exported-code-blocks-according-to-theme
(defun my/org-inline-css-hook (exporter)
"Insert custom inline css to automatically set the
background of code to whatever theme I'm using's background"
(when (eq exporter 'html)
(let* ((my-pre-bg (face-background 'default))
(my-pre-fg (face-foreground 'default)))
(setq
org-html-head-extra
(concat
org-html-head-extra
(format "<style type=\"text/css\">\n pre.src {background-color: %s; color: %s;}</style>\n"
my-pre-bg my-pre-fg))))))
(add-hook 'org-export-before-processing-hook 'my/org-inline-css-hook)
3.3 quote
我们写博客时,经常会引用别人的经典的语录。这个时候怎么办呢?
假设我们这样写:
#+BEGIN_SRC text
/*子曰:学而时习之,不亦说乎!*/
#+ENDSRC
结果是这样的:
/*子曰:学而时习之,不亦说乎!*/
我们看到,这个引用使用的是与code block一样的设置。那么,引用改怎么写呢?
其实,org-mode中专门有一个引用的tag:
#+BEGIN_QUOTE
/*子曰:学而时习之,不亦说乎!*/
#+END_QUOTE
效果是这样的:
子曰:学而时习之,不亦说乎!
这个才是正确的引用姿势。
4 发布
只需要按 C-c c p 进行发布就可以了,如果是第一次发布,会提示"Do you want to post this blog to cnblogs?" ,回答"y"。如果是更新之前发表过的文章,"Already published! Do you want to update this blog to cnblogs?",回答"y"就可以更新文章。
5 资源
使用org-mode写cnblogs博客的更多相关文章
- 配置Windows Live Writer,写cnblogs博客
引言 以前写博客一般都是联网在cnblogs上面写,不好的地方就是不联网就写不了,当然我们也可以先记录在word文件,等联网在从word里面拷贝出来发布到cnblogs上面,但是样式这些 ...
- 配置WindowsLiveWriter,写cnblogs博客
转载:http://www.haogongju.net/art/2307587 引言 以前写博客一般都是联网在cnblogs上面写,不好的地方就是不联网就写不了,当然我们也可以先记录在word文件,等 ...
- 【原创】配置Windows Live Writer,写cnblogs博客
20180115更新补充: 现在live writer已经改名open live writer了,需要去下载的到地址:http://openlivewriter.org/ 引言 以前写博客一般都是联网 ...
- org-mode 写 cnblogs 博客
1. 为什么用org-mode写博客 我最开始用Emacs, 是因为org-mode.这是一个专注于写,而让我忽略展示结果的一种写作方式.为 什么这么说?因为所有内容的格式都是可定制的.按照自己喜欢的 ...
- 用emacs的org2blog组件写cnblogs博客 -- 环境配置及使用
Table of Contents 配置 使用 创建一篇博文并发布 更新一篇博文 删除一篇博文 待办 本文给出了一个安装.配置org2blog的方法,实现在emacs中书写blog文章.并发布到cnb ...
- emacs写cnblog博客
emacs的版本 org-mode版本 参考链接: 用Emacs管理博客园博客 用emacs org-mode写cnblogs博客 用emacs org-mode写博客 & 发布到博客 ...
- 把cnblogs变成简书 - cnblogs博客自定义皮肤css样式
吐槽 博客园cnblogs作为老牌的IT技术博客类网站,为广大的开发者提供了非常不错的学习交流平台. 虽然博客内容才是重点,但是如果有赏心悦目的页面不更好吗! cnblogs可以更换博客模板,并且提供 ...
- cnblogs博客迁移到hexo
cnblogs博客备份 备份地址:https://i.cnblogs.com/BlogBackup.aspx?type=1 备份文件为xml格式,打开备份文件,如下所示: <?xml versi ...
- 利用Word发布文章到cnblogs博客
利用Word发布文章到cnblogs博客 用博客园cnblogs:http://www.cnblogs.com/博客名称/services/metablogapi.aspx,word老是提醒" ...
随机推荐
- MySQL数据库时区问题导致java程序无法连接数据库
转载自https://blog.csdn.net/man_zuo/article/details/81027934 先把报错信息贴上, The server time zone value '???ú ...
- Bentley二次开发中的,沿曲线构造拉伸实体问题
引用文件:Bentley.Interop.MicroStationDGN 本人开发过程中遇到问题: 创建多个线段及弧线,通过自动创建复杂链获得,沿曲线构造拉伸实体的Path参数,拉伸曲线路径首尾特别近 ...
- JVM系列(一) — Jvm内存模型
总结自<深入理解java虚拟机> 很多博客在讲虚拟机内存模型时,比较宽泛或者粗化,甚者,不准确,以下是我的一个笔记照片 运行时数据区可以分为两部分:线程共享区和线程私有区 一.线程共享区 ...
- Logstash配置文件详情
logstash 配置文件编写详解 说明 它一个有jruby语言编写的运行在java虚拟机上的具有收集分析转发数据流功能的工具能集中处理各种类型的数据能标准化不通模式和格式的数据能快速的扩展自定义日志 ...
- Python - zipfile 乱码问题解决
最近使用zipfile进行解包过程中遇到了很不舒服的问题,解包之后文件名是乱码的.下面进行简单总结: 首先,乱码肯定是因为解码方式不一样了,zipfile使用的是utf-8和cp437这两种编码方式, ...
- Purfer序列
我们经常干的一件事是把数变为关于图的问题来解决,那么久了未免不会有这个疑问:能不能把图变成数来解决问题? 所以有了这个purfer数列. 介绍一下这个数列有什么用(或者说有什么性质): 能够将一棵无根 ...
- jq轮播图实现
html基本框架如下: <div class="out"> <ul class="img"> <li><a href= ...
- Mac 安装cnpm
1.先安装node node的下载地址:http://nodejs.cn/download/ 这个没什么好说的,安装完成后测试一下,在终端输入:node -v 这时候就可以看到安装的nod ...
- 【记录】Mybatis Generator生成数据对象Date/TimeStamp 查询时间格式化
Mybatis Generator是很好的工具帮助我们生成表映射关联代码,最近博主遇到一个问题,找了很久才解决, 就是用Mybatis Generator生成实体类的时候,Date 时间无法格式化输出 ...
- Video Mode Timings
A monitor draws an image on the screen by using an electron beam (3 electron beams for color models, ...