Personal tools
You are here: Home KtJ's Blog reStructuredTextのAdmonitionsディレクティブをPloneでレンダリングするためのcss

reStructuredTextのAdmonitionsディレクティブをPloneでレンダリングするためのcss

by ktj posted at 2008-02-26 07:48 last modified 2010-06-01 20:44

reStructureTextってのは、いわゆる構造化テキストの一種で、パーサによってHTMLなんかに容易に変換できるように構造化された文書で、かつソースを自然文として普通に読めるという特徴をもった文書のこと。 詳細はWikipediaの説明ページを参照 のこと。

このreStructureTextはPython言語のDocutilsフレームワークとして開発されたという経緯があるため、このサイトのCMSであるPloneでも標準の構造化テキストとして使用されている。このサイト内の文書も、Plone移行後に書いたもの(このブログ内の投稿も)はreStructuredTextで書いている。HTMLのタグをちまちま書くのもめんどくさいしね。

で、reStructureedTextには、admontionsディレクティブ、っていう仕組があって、ソースで、

.. DANGER::
   Beware killer rabbits!

と書くと、

!DANGER!

Beware killer rabbits!

みたいに段落自体を強調表現してくれることが期待される。(これ、 reStructuredテキストのディレクティブのドキュメント からそのまま持ってきた例文だけど、 ホーリーグレイル ネタじゃないか。 Python の人って、本当に パイソン 好きだな。かくいう私も字幕版ビデオ、字幕版DVDに加え、 吹替版DVD を当然の如く購入しましたが。pythonは入門レベルだけど)

ただ、Ploneの初期設定では、admontionsディレクティブを他の段落と区別が付くようにレンダリングしてくれない。そこで、 takanory.net さんとこの 説明 を参考に、ploneCustom.cssを以下のように編集してみた。

div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning {
   margin: 2em 4em;
   padding: 0.5em;
   border-style: solid;
}

div.caution>p.admonition-title, div.danger>p.admonition-title, div.warning>p.admonition-title {
   color: red;
}

p.admonition-title {
   text-align: center;
   font-weight: bold;
}

今勉強も兼ねて、 reStructuredText Markup Specification の翻訳に挑戦しているんだけど、ディレクティブの説明も訳さなきゃ全体像は掴めない・・かな?

(2/28)上下のマージンが大き目なので修正しました。

Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)
(Required)
(Required)


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: