ウェブ制作 - エディタによるマークアップ作業支援:補記
屁理屈でよく使うEmEditorのマクロ。もっと高度な使い方もあるんだろうが、俺には無理。
リスト作成
単なる箇条書きをリスト要素でマークアップする。
document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.EndOfLine(true,eeLineView); document.selection.Cut(); document.selection.Text="<li></li>"; document.selection.CharLeft(false,5); document.selection.Paste(eeCopyUnicode); document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.LineDown(false,1);
これで1行ぶん。複数行あるなら行数ぶんだけマクロを実行すればよい。
同様にリンク付きリストの場合。
document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.EndOfLine(true,eeLineView); document.selection.Cut(); document.selection.Text="<li></li>"; document.selection.CharLeft(false,5); document.selection.Text="<a href=\x22\x22></a>"; document.selection.CharLeft(false,4); document.selection.Paste(eeCopyUnicode); document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.LineDown(false,1);
最後にOL要素かUL要素で全体を囲えばおk
なお、俺は各要素を辞書登録してるので普段やってる(マクロを使わない状態での)手順どおりに組んだけれども、最初のマクロは
document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.Text="<li>"; document.selection.EndOfLine(false,eeLineView); document.selection.Text="</li>"; document.selection.StartOfLine(false,eeLineView | eeLineHomeText); document.selection.LineDown(false,1);
でももちろん構わない。
日別見出し挿入
屁理屈ではex. <h3 id="entry_2009-08-21">2009-08-21</h3>といった感じで日ごとの見出しにid属性を割り当てている。これを簡単に記述するためのマクロ。書いたのは最低人類0号>>138。
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var day = now.getDate();
if(year < 2000) { year += 1900; }
if(month < 10) { month = ":0": + month; }
if(day < 10) { day = ":0": + day; }
str = year + ":-": + month + ":-": + day
document.selection.Text=
":<h3 id=\x22entry_": + str + ":\x22>": + str + ":</h3>":;
最後の改行は便宜上入れただけなので実際には不要。
画像と拡大画像リンク
辞書登録は便利なのだけれども、字数制限があるのであまり長い文字列には適さない。<img src="" alt=" title=" width=" height="" />にclass属性を入れたりA要素でマークアップした状態は無理。
document.selection.Text=" <a href=\x22./images/\x22> <img src=\x22./images/\x22 alt=\x22\x22 title=\x22\x22 width=\x22\x22 height=\x22\x22 class=\x22\x22 /> </a>";
これも実際には改行はいらない。B地区exのコンテンツ表示幅が狭すぎるだけ。
結果は<a href="./images/">となる(これまた実際には改行はない)。俺の場合画像は基本的にカレントのサブディレクトリ“images”に放り込んでるので、それもあらかじめ記述してある。またclass属性であるが、屁理屈ではインラインの場合は“inline”もしくは“inlines”、ブロック要素の場合は“block”(それぞれスタイルシートでfloatやdisplay:blockなんかを指定してある)。
<img src="./images/" alt=" title=" width=" height="" class="" />
</a>