平衡点


2006/11/10

_ tdiary とはてなダイアリ

現在 tdiary を動かしているサーバを, 来年以降動かせるかどうか定かでは無いので, はてなダイアリに乗りかえます.

…という宣言は既にしていたのですが, tdiary の方は rd-style で記述しているので, RD 記法からはてな記法に変換することをちまちまとやっていました.

で, rd2html-lib.rb を見ながらちまちまと弄っていたんですよ. rd でパース対象になる要素の一覧が欲しかった訳ですが, まとまった所が無いんですね(というか, それぐらい嫁, とかいうレベルかもしれません).

そんな訳でメモ.

rd のパーサを作るために

apply_to_DocumentElement(element, content):要素全体. 全ての要素を最後に出力するために使う.

例えば

def apply_to_DocumentElement(element, content)
  ret = make_body(content) + "\n"
  ret
end
def make_body(contents)
  contents = contents.join("\n")
  %Q[#{content}]
end

みたいに.

apply_to_Headline(element, title):見出し. つまり "=" について処理を行なう

はてなの記法では "=" ではなくて "*" の数でヘッディングするので,

def apply_to_Headline(element, title)
  headlevel = '*' * element.level.to_i
  %Q[#{headlevel}#{title}\n]
end

みたいに

apply_to_TextBlock(element, content):ul, dl, ol などのブロック要素を処理する.

これ上手くいってないなぁ…

apply_to_Verbatim(element):整形済みテキストの処理.

はてなの記法では ">||" と "<||" で囲まれた部分を整形済みとして pre で囲むので

def apply_to_Verbatim(element)
  content = []
  element.each_line do |i|
    content.push(apply_to_String(i))
  end
  %Q[>||\n#{content.join("").chomp}\n||<\n]
end

他には.

apply_to_ItemList(element, items):
apply_to_EnumList(element, items):
apply_to_DescList(element, items):
apply_to_MethodList(element, items):
apply_to_ItemListItem(element, content):
apply_to_EnumListItem(element, content):
apply_to_DescListItem(element, term, description):
apply_to_MethodListItem(element, term, description):
apply_to_StringElement(element):
apply_to_Emphasis(element, content):
apply_to_Code(element, content):
apply_to_Var(element, content):
apply_to_Keyboard(element, content):
apply_to_Index(element, content):
apply_to_Reference_with_RDLabel(element, content):
apply_to_Reference_with_URL(element, content):
apply_to_RefToElement(element, content):
apply_to_RefToOtherFile(element, content):
apply_to_Footnote(element, content):
apply_to_Foottext(element, content):
apply_to_Verb(element):
apply_to_String(element):

連絡先など
最近の日記
  • 2024/04/28
    • 1. CF-SR3 での生活環境構築 (できてない)
  • 2024/03/29
    • 1. Debian GNU/Linux on CF-SR3
  • 2024/03/25
    • 1. org-mode → beamer でのリスト記号の一時変更
  • 2024/03/22
    • 1. 静的htmlによるGit Repository Browser
  • 2024/02/15
    • 1. org-mode → bemaer での番号付きリスト
一覧
2006|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|02|03|04|08|09|10|11|12|
2013|01|02|03|04|05|06|08|09|10|11|12|
2014|01|02|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|09|10|
2016|02|03|
2017|01|02|03|05|06|07|09|11|12|
2018|03|06|07|10|11|12|
2019|01|02|03|04|05|07|10|12|
2020|01|02|03|04|05|08|09|10|11|12|
2021|01|02|03|05|06|07|08|09|11|12|
2022|01|02|03|04|05|06|08|10|11|12|
2023|02|03|04|06|08|09|11|12|
2024|01|02|03|04|
Back to Top ▲