平衡点


2011/08/25

_ muse-mode にカスタムタグを追加する[Emacs

ちょっとじたばたしたのでメモ.

(defun muse-publish-cmdline-tag (beg end &optional attr)
  "create custom tag for non-syntax highlighting preformatted text"
  (let* ((class (cdr (assoc "class" attrs))))
    (if (muse-style-derived-p 'html)
       (progn
        (muse-publish-ensure-block beg end)
        (goto-char beg)
        (insert (concat "<pre "
        (if (stringp class)
           (concat "class=\""class"\">") ">")))
        (goto-char end)
        (insert "</pre>")
        (muse-publish-mark-read-only beg (point))))))
(add-to-list 'muse-publish-markup-tags
             '("cmdline" t t nil muse-publish-cmdline-tag))
(add-to-list 'muse-colors-tags
             '("cmdline"  t nil nil muse-colors-example-tag))

本当は include で適当な class を指定できると良いのだけれど, そういうわけにもいかないので

(add-to-list 'muse-html-markup-strings
             '(begin-example . "<pre class=\"prettyprint\">"))

とかして <example> タグを書き変えてしまったわけで. そうしたら単なる pre を書くのが面倒になってしまったので, 別途定義した, という次第.

でも, これは結構イロイロな所で使えそうな雰囲気です.


連絡先など

portrait

最近の日記

一覧

Back to Top ▲