20230831

Table of Contents

1. このページについて

NOTE に手を出そうかなと思い、(元テキストを書く)org-mode についておさらいしていたのだけど「そもそも org-mode で吐く HTML で充分なんだよな……」と頭を抱えてしまったので、真面目に体裁を整える方法を模索しようとした結果。

2. 今あるもの

  • リンクの貼りかた URL を直接コピペすると勝手にリンクになる→C-c C-l でキャプションを付けられる
  • 引用 例とソースではフォントが違うのか……?
  • HTML の書き出し C-c C-e h h

3. 今回追加したもの

3.1. テーマ

参考: @sambatriste/org-modeのHTMLテーマ第2弾

norang っていうテーマ気にいった org.css 拾ってきて

<link rel="stylesheet" type="text/css" href="./norang.css"/>

スタイルシートタグの下あたりに挿入しておくだけ。

3.2. ヘッダとフッタ

本家: 13.9.4 HTML preamble and postamble

参考: Org-mode htmlエクスポート

どうやら .emacs に書けるらしい。

(setq org-publish-project-alist
      '(
	("doc"
	 :base-directory "orgファイルを置くディレクトリ"
	 :base-extension "org"
	 :publishing-directory "HTML出力先のディレクトリ"
	 :publishing-function org-html-publish-to-html
	)))

このへんいいですね

(setq org-html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"../conf/default.css\" />")

あっここで指定できるんだ。

  (setq org-html-preamble-format '(("en" "
<div align=right>
最終更新日: %C
</div>

<div align=right>
<a href=\"http://cha.la.coocan.jp/\">ホーム</a> |
<a href=\"index.html\">文書トップ</a> | <a href=\"sitemap.html\">目次</a>
</div>
")))

(setq org-html-postamble "
<div align=right>
<a href=\"http://cha.la.coocan.jp/\">ホーム</a> |
<a href=\"index.html\">文書トップ</a> | <a href=\"sitemap.html\">目次</a>
</div>

<div align=right>
Created by %c
</div>

")

これがサンプル。変数についてはこのサイトにある。

 org-html-preamble-format の第2要素に設定すればよいらしい。 また、第2要素では、下記の書式が使用可能である。

%t stands for the title.
%a stands for the author's name.
%e stands for the author's email.
%d stands for the date.
%c will be replaced by `org-html-creator-string'.
%v will be replaced by `org-html-validation-link'.
%T will be replaced by the export time.
%C will be replaced by the last modification time.

3.3. インデックスページ

本家: 14.3.1 Example: simple publishing configuration 設定すればできるぽい……

This example publishes a set of Org files to the ‘publichtml’ directory on the local machine.

(setq org-publish-project-alist
      '(("org"
	 :base-directory "~/org/"
	 :publishing-function org-html-publish-to-html
	 :publishing-directory "~/public_html"
	 :section-numbers nil
	 :with-toc nil
	 :html-head "<link rel=\"stylesheet\"
		    href=\"../other/mystyle.css\"
		    type=\"text/css\"/>")))

3.4. キャプション類

参考: Build Your Website with Org Mode - System Crafters よくわかんないけどどさどさ書いてある

Improving the HTML output

(setq org-publish-project-alist
      (list
       (list "org-site:main"
	     :recursive t
	     :base-directory "./content"
	     :publishing-function 'org-html-publish-to-html
	     :publishing-directory "./public"
	     :with-author nil           ;; Don't include author name
	     :with-creator t            ;; Include Emacs and Org versions in footer
	     :with-toc t                ;; Include a table of contents
	     :section-numbers nil       ;; Don't include section numbers
	     :time-stamp-file nil)))    ;; Don't include time stamp in file
Publish setting key 	Emacs Lisp variable
------------------------ 	----------------------------------
:author 	user-full-name
:email 	user-mail-address
:creator 	org-export-creator-string
:exclude-tags 	org-export-exclude-tags
:headline-levels 	org-export-headline-levels
:language 	org-export-default-language
:preserve-breaks 	org-export-preserve-breaks
:section-numbers 	org-export-with-section-numbers
:select-tags 	org-export-select-tags
:time-stamp-file 	org-export-time-stamp-file
:with-archived-trees 	org-export-with-archived-trees
:with-author 	org-export-with-author
:with-creator 	org-export-with-creator
:with-date 	org-export-with-date
:with-drawers 	org-export-with-drawers
:with-email 	org-export-with-email
:with-emphasize 	org-export-with-emphasize
:with-entities 	org-export-with-entities
:with-fixed-width 	org-export-with-fixed-width
:with-footnotes 	org-export-with-footnotes
:with-inlinetasks 	org-export-with-inlinetasks
:with-latex 	org-export-with-latex
:with-planning 	org-export-with-planning
:with-priority 	org-export-with-priority
:with-properties 	org-export-with-properties
:with-smart-quotes 	org-export-with-smart-quotes
:with-special-strings 	org-export-with-special-strings
:with-statistics-cookies 	org-export-with-statistics-cookies
:with-sub-superscript 	org-export-with-sub-superscripts
:with-toc 	org-export-with-toc
:with-tables 	org-export-with-tables
:with-tags 	org-export-with-tags
:with-tasks 	org-export-with-tasks
:with-timestamps 	org-export-with-timestamps
:with-title 	org-export-with-title
:with-todo-keywords 	org-export-with-todo-keywords

with-\n t が効いたりしないかなあ…… いや :preserve-breaks か?!

3.5. web拍手

http://www.webclap.com/ 無料のアカウントつくってCGIを発行してもらうとコピペできるソースがお出しされるっぽいので、フッタに書けばいいのかな。

3.6. 忘れてたがwwwサーバ

ふぉろわっさまが Cloudflare Pages ての教えてくれたよ。 【Cloudflare Pages】ブログを公開したい?…5分もあれば十分だ このへん読めば取れそう もうなんというか……直接ページだけでよくない?(とりあえず)て気分なので しかし github で put せなならんのか? うーん

4. まとめ

・とりあえず .emacs にゴリゴリ書いてみてうまく情報の載った HTML が吐けるようなら良し ・目標はメタデータ、テーマ、ヘッダ(テキスト、投稿日、最終更新時間)、フッタ(web拍手を貼る、テキスト)あたり ・そしたら……まず github か……それさえイケれば Cloudflare はだいじょぶそうな気がする

Author: KAWAKAMI Kyoko

Created: 2023-12-27 水 00:54

Validate