Markdownをもっと書きやすくするTextwellアクション MarkdownTools

小物入れに詰めてみました。


Textwell 1.2.1
分類: 仕事効率化,ユーティリティ
価格: \300 (Sociomedia)

Textwellは公式アクションでMarkdownをサポートしていますが、入力に関して何もない。確かにプレーン・テキストに記号をつけるだけなので困るわけではないけれど、それでもキーボードを英字に変えたりするのは少し手間。その手間をアクションで楽してみます。

T.loadlets([
  {title:"[MarkdownTools]",
  fn:function(){
    T("done");
  }},
  {title:"見出し",
  fn:function(){
    c=T.current;
    s=(/^#? /.test(c))? c.replace(/^#? /mg,"") : c.replace(/^/mg,"### ");
    T("replaceCurrent",{text:s});
  }},
  {title:"リスト",
  fn:function(){
    c=T.current;
    s=(/^(- )/.test(c))? c.replace(/^(- )/mg,"") : c.replace(/^([0-9]\. )?/mg,"- ");
    T("replaceCurrent",{text:s});
  }},
  {title:"連番",
  fn:function(){
    c=T.current;
    s=(/^[0-9]\. /.test(c))? c.replace(/^[0-9]\. /mg,"") : c.replace(/^(- )?/mg,"1. ");
    T("replaceCurrent",{text:s});
  }},
  {title:"強調",
  fn:function(){
    s=T.current.replace(/^/mg,"**").replace(/$/mg,"**");
    T("replaceCurrent",{text:s});
  }},
  {title:"引用",
  fn:function(){
    c=T.current;
    s=(/^> /.test(c))? c.replace(/^> /mg,"") : c.replace(/^/mg,"> ");
    T("replaceCurrent",{text:s});
  }},
  {title:"コード",
  fn:function(){
    s="```\n"+T.current+"\n```\n";
    T("replaceCurrent",{text:s});
  }},
  {title:"水平線",
  fn:function(){
    s="\n- - -\n";
    T("insert",{text:s});
  }},
  {title:"リンク",
  fn:function(){
    c=T.current;
    s=(/^https?:/.test(c))? "[ LINK ]("+c+")" : "["+c+"]( URL )";
    T("replaceCurrent",{text:s});
  }},
  {title:"プレビュー",
  fn:function(){
    T.translucent(false);
    location = 'http://sociomedia.com/textwell/wd/markdownpreview/';
  }}

],
  function(){location="about:blank"}
)

登録リンクはこちら→ http://tinyurl.com/kbj4h7e



アクションを立ち上げると、装飾用のリストが出ます。



カーソル行を対象に変換。あるいは範囲選択をリスト化したりできます。



すでにMarkdownが付加されていれば解除します。あるいはリストを連番に変えたり、連番をリストに変えたりできます。少しだけ手数を減らすことができる。



プレビューは、公式のプレビュー・アシストを呼び出します。


Textwellからwri.peに書き込むアクションwripeを微妙に修正
使っているうちに使いやすくなるのが好循環。死角がない。wri.peは長い文章を書くには不向きだけれど、そこはTextwellを使えばいい。Textwellはパソコンとの連携が一手間だけど、wri.pe...
wri.peはプレビューがMarkdown仕様。そんなわけで、下書きにMarkdownを使う機会が増えます。HTMLタグは、一度つけてしまうと、外すときに面倒なんです。ただMarkdownは出来ることが少ない。表の作成とかややこしい。たぶん、英文には「表」という概念がないんだろうと思う。タイプライター文化なので、その延長上にパソコンの作法も沿っている。図表類は二の次三の次。そこあたり割り切って、まずは文章の表現力を磨くしかない。