2008/03/22

EmEditorのマクロ 選択範囲をpタグで囲む

選択範囲をpタグで囲むマクロ。

改行はbrタグで記事を書こうと思っていたわけですが、やっぱりパラグラフはpタグの方がレイアウトしやすいなと思って、pタグも準備しました。ソース的には新鮮さゼロですが。

ついでに個人的にはすーごく気持ち悪かったbloggerの記事を囲んでいたpタグも外してしまいました(ウィジットテンプレートをぽーっと見ていて、やっとどこで設定しているのかわかりました。ふー、スッキリ。更に調子に乗って「ウィジットのテンプレートを展開」にチェックを入れて、ウィジットのタグもいじってみましたが、こちらはことごとくエラーになりました。あー改造したい…)。

  1. Dim intXB        '選択範囲の最終行のX  
  2. Dim intYC        '現在位置のY  
  3. Dim intYA        '選択範囲の開始行  
  4. Dim intYB        '選択範囲の最終行  
  5. Dim i  
  6.   
  7. intYC = document.selection.GetActivePointY( eePosLogical )  
  8. intXB = document.selection.GetBottomPointX( eePosLogical )  
  9.   
  10. intYA = document.selection.GetAnchorPointY( eePosLogical )  
  11. intYB = document.selection.GetBottomPointY( eePosLogical )  
  12.   
  13.   
  14. If intXB = 1 Then  
  15.     intYB = intYB -1  
  16.     If intYC > 1 Then intYC = intYC - 1  
  17. End If  
  18.   
  19. If intYC <> intYB Then  
  20.     For i = intYC To intYB  
  21.         document.selection.StartOfLine False,eeLineLogical  
  22.         document.selection.Text="<p>"  
  23.         document.selection.EndOfLine False,eeLineLogical  
  24.         document.selection.Text="</p>"  
  25.         document.selection.LineDown  
  26.     Next  
  27. Else  
  28.     For i= intYA to intYB  
  29.         document.selection.StartOfLine False,eeLineLogical  
  30.         document.selection.Text="<p>"  
  31.         document.selection.EndOfLine False,eeLineLogical  
  32.         document.selection.Text="</p>"  
  33.         document.selection.LineDown  
  34.     Next  
  35. End If  

0 件のコメント: