2008/03/18

EmEditorのマクロ 選択範囲内をprettyprint

EmEditorのマクロで選択範囲をソースコード用のタグ<pre class="prettyprint"></pre>で囲んで、&類を実体参照化するマクロ。preの中だと自動で実体参照に変換してくれないようなので。

Blogger投稿用デス。

  1. Dim strData  
  2. Dim intSCount  
  3.   
  4. intSCount = 4    'tab→半角スペース置換えの際のスペースの数  
  5. strData = document.selection.Text  
  6.   
  7. strData = Replace(strData, vbTab, String(intSCount," "))  
  8. strData = Replace(strData, "&""&amp;")  
  9. strData = Replace(strData, "<""&lt;")  
  10. strData = Replace(strData, ">""&gt;")  
  11. strData = Replace(strData, """""&quot;")  
  12. strData = Replace(strData, "'""&#39;")  
  13.   
  14. document.selection.Text = "<pre class=""prettyprint"">"  
  15. document.selection.NewLine  
  16. document.selection.Text = strData  
  17. document.selection.Text = "</pre>"  

0 件のコメント: