#desc Top ; -*- mode: Muse; coding: euc-japan-unix -*- #title Muse Mode の設定 ****** $Lastupdate: 2007/11/09 16:25:38 $ * 始めに 2006 年 11 月に [[http://www.emacswiki.org/cgi-bin/wiki/EmacsWikiMode][emacs-wiki]] から[[http://www.mwolson.org/projects/MuseMode.html][muse-mode]] に移行しました. できる事が増えて, 設定が更に複雑になった感は否めませんが, [[http://www.emacswiki.org/cgi-bin/wiki/EmacsWikiMode][emacs-wiki]] 同様に大変便利です. * install etch の Debian package は 3.02.8-1 なのですが, 本家では 3.12 が公開されています. 3.02 はリストのネスティングができないので, 本家から 3.12 を取得して, testing のソースを使って Debian package を 野良ビルドしました. 野良ビルドは [[../pub/][野良ビルド置き場]] から取得できます. $ wget http://www.mwolson.org/static/dist/muse-latest.tar.gz $ apt-get source muse-el -t testing $ cd muse-el-3.11 $ uupdate ../muse-el-latest.tar.gz -v 3.12 $ cd muse-el-3.12 $ dch -i $ debiuld -rfakeroot -uc -us $ sudo dpkg -i muse-el_3.12-1.uwabami1_all.deb * 設定 ** .emacs での設定 今の所 xhtml での出力しか考えていません(この文書です). latex での出力もできるみたいですが, あんまり使ってません - -;) ;; 読み込み (require 'muse-mode) (require 'muse-html) (require 'muse-latex) (require 'muse-project) (require 'muse-wiki) ;; project の定義 (setq muse-project-alist '(("cc-env" ("~/work/muse/cc-env" :default "index") (:base "xhtml" :path "~/public_html/cc-env") ))) (add-to-list 'muse-project-alist '("lec_note" ("~/work/muse/lec_note" :default "index") (:base "latex" :path "~/work/tex/lec_note"))) ;; 拡張子をつけない場合にはコメントを外す ;(setq muse-file-extension nil muse-mode-auto-p t) ;;文字コード設定 (setq muse-xhtml-charset-default "euc-jp") (setq muse-html-encoding-default (quote euc-jp)) (setq muse-html-meta-content-encoding (quote euc-jp)) (setq muse-latexcjk-encoding-default (cdr (assoc 'euc-jp-unix muse-latexcjk-encoding-map))) (setq muse-latex-header "~/.emacs.d/template/muse-header.tex") ;; footer の読み込み (setq muse-xhtml-footer "~/.emacs.d/template/muse-footer.html") ;; header の読み込み. (setq muse-xhtml-header "~/.emacs.d/template/muse-header.html") ;; CSS の読み込み (setq muse-xhtml-style-sheet "") ;; 日付フォーマットの指定 (setq muse-footer-date-format "%Y-%m-%d") ;; \C-x n で project-find-file を起動 (define-key ctl-x-map "n" 'muse-project-find-file) ;; テンプレートの自動挿入 (setq auto-insert-alist (append '( ;; モードで選択 (muse-mode . "muse-template.muse") ;; ファイル名で指定 ("\\.muse" . "muse-template.muse") ) auto-insert-alist)) ** xhtml 変換のヘッダ, フッタ, テンプレート ヘッダはこんな感じ. muse-xhtml-style-sheet <lisp> (let ((current-project (car (muse-project-of-file muse-publishing-current-file)))) (concat (when current-project (concat current-project " - ")) (muse-publishing-directive "title"))) </lisp>

(concat (muse-publishing-directive "title") (let ((author (muse-publishing-directive "author"))) (if (not (string= author (user-full-name))) (concat " (by " author ")"))))

フッタはこんな感じ
テンプレートはこんな感じ. $Lastupdate:$($は半角の $) は, emacs で save-buffer 時に更新する設定をしてます. #desc Top ; -*- mode: Muse; coding: euc-japan-unix -*- #title ****** $Lastupdate: $ ** 画像のサムネイル出力 画像へリンクをはった際に, サムネイルへリンクするようにしてみた. ...と言っても, アップロードする際に変換しているだけで. #!/usr/bin/ruby1.8 require 'RMagick' require 'tempfile' #--- image size setting width = 320.0 height = 240.0 #--- error handring if ARGV.size < 1 puts "usage: muse-img-hook.rb [html_dir]" exit 1 end #--- main Dir.glob(ARGV[0] +"/*.html").each do |file| puts file temp = Tempfile::new(File.basename(file), "/tmp") File.open(file).each do |line| if line =~ /img src=\"\.\/img\/(.*\.png).*alt=\"(.*)\"/ img_name = "/img/" + $1 thumb_name = "/img/thumb/" + $1 unless $1 =~ /thumb/ img = Magick::ImageList.new(File.dirname(file) + "/" + img_name) img.resize(width,height).write(File.dirname(file) + "/" + thumb_name) uri = "" imgtag = "\"#{$2}\"" link = uri + imgtag + "" temp.puts( \ line.gsub(//,link)) end else temp.puts(line.gsub(/font-style: italic/,"font-style: normal")) end end temp.close; temp.open File.open(file, "w").write(temp.read) temp.close(true) end なんて. ---- * 参考文献 - [[http://www.mwolson.org/projects/MuseMode.html][muse-mode]] - 本家のドキュメント: [[http://www.mwolson.org/static/doc/muse.html][Muse]] - 上記ドキュメントの読書メモ:[[http://amt.ty.land.to/OpenNote/muse.html][museのinfo の読書メモ]] - [[http://homepage.mac.com/matsuan_tamachan/software/EmacsMuse.html][emacs-muse のインストールと設定]]