LoginSignup
2
3

More than 5 years have passed since last update.

メール等の日本語テキスト文章の記法をMarkdown記法に変換する秀丸マクロを作成してみた

Last updated at Posted at 2018-01-29

はじめに

 会社でMarkdownを普及させたいが、普段のメール等で使うテキスト文章な日本語記法と、markdown記法では差があり、現状のままでは使ってくれない。使ってくれる方法を、両者を比較して考えてみた。結果、自動変換の秀丸マクロを作りました。

会社でのMarkdown普及の課題

  • 入力中「半角/全角/漢字」ボタンを何回も押すのが大変
  • Markdownの「#」と「半角スペース」は変換の時に一発で出てこない。(腹立つわー)
  • Markdownは半角文字が多くて、全角主体の日本語と一緒に織り交ぜる入力は煩雑。(英文なら良いのかな?)
  • 文字の辞書登録やShiftボタンを押しながらの入力は、思いのほか玄人技らしく難しいので避けたい。
  • Markdown向け文字登録をたくさんのパソコンに展開する方法を知らない。

言語とそれぞれのキーボード入力

言語 文字入力方法 キーボード入力からの流れ
英語 キーボードから直接入力 キーボード入力=そのままの言葉
日本語 変換前提 ローマ字入力→ひらがなに変換→漢字に変換

 

考えたこと。気づいたこと。思ったこと

  • 日本語記法は「■◆●▲★□◇〇△☆・:」の記号と罫線を多用している。
  • ■◆●▲★等が使われる要因は、コントラストが強くて目印になるから?
  • 日本語記法は全角や半角スペース、改行を多用して、間隔(間)で強調して目立たせて読みやすさを確保している。もともと日本語は単語ごとにスペースを使わない記法なので利用されてるのでしょう。
  • 日本語記法は矢印記号「→」も多用されている。英語記号はもちろん「->」
  • 「・」は一発で打てて楽。やはり一発で打てる文字は使い易い。
  • 一方でMarkdownの「# 」等は一発では打てない。
  • 半角文字は、最初は一発で検索項目の一番上に来ない。繰り返せば出るけど。
  • Markdownが世界中で普及した要因は
    「HTMLの様な構造体テキストでありながら、HTMLよりも読みやすい」+「英文で助長ではない」+「打ちやすい」+「markdownと言う絶妙なネーミング」
  • 上記のMarkdownが普及した要因と比べて、日本語記法を当てはめると。
    「テキスト状態で見やすい?否」+「打ちやすい?否」
  • 表の書き方がめんどくさい。エクセルのコピペがいい。tab区切り。
  • と言いつつスマホは、tab入力出来ないので罫線の│を利用かな。
  • なんだかんだ書きましたがMarkdownは現状最強であり、恐ろしい速さで広がっている。やっぱり英語は強いのか。

自己ルール

  • Markdownは最強であり、太刀打ちできないので、流れに乗る。
  • Excelも最強である。利用できるものは利用する。
  • code=プログラム=英語=半角には手を出さない。「`」方面には手を出さずそのまま

比較してみた(その1)

Markdown
記法
なんとなく
定義
内容 備考
# ■■■ 見出し1 ・■は個人的趣味
・■が多=大見出し
## ■■ 見出し2
### 見出し3
- A
- B
・A
・B
箇条書き 「・」の箇条書きは一般的と思う
* 日時
・日時 箇条書き 「●日時」と悩んだ
--- ─── 区切線 「─」は15個とした
*** ─── 区切線
1. 山
2. 川
①山
②川
番号付き箇条書き 使用率高め
あ*い*え あ「い」う 斜体
か**き**く か【き】く 太字
さし~~すせ~~そ さし×すせ×そ 見消線 間違ったら「×」だね
たちつ
半角Space×2
たちつ\n 改行 2個の半角Spaceを変換する大変

比較してみた(その2)

Markdown
記法
なんとなく
定義
内容 備考
[google](https://www.google.co.jp/) google\t
https://www.google.co.jp/
リンク 下にアドレス置くだけ
A|B
---|---
C|D 
A\tB
C\tD
Excelコピペでtab区切り

秀丸マクロ(txt→md)

appendsave filename +".md"; //別ファイルへの追加保存(ファイル名)
openfile filename +".md";

disabledraw;

//見出し
replaceallfast "^[■]{3}(.*)","# \\1",regular;
replaceallfast "^[■]{2}(.*)","## \\1",regular;
replaceallfast "^[■]{1}(.*)","### \\1",regular;

replaceallfast "^───────────────","---",regular;
replaceallfast "^───────────────","\\*\\*\\*",regular;

//箇条書き
replaceallfast "^(  ・)(.*)","  - \\2",regular;
replaceallfast "^( ・)(.*)"," - \\2",regular;
replaceallfast "^(・)(.*)","- \\2",regular;

//強調文字
replaceallfast "(.*)【(.*)】(.*)","\\1**\\2**\\3",regular;
replaceallfast "(.*)「(.*)」(.*)","\\1*\\2*\\3",regular;

//見消線
replaceallfast "(.*)×(.*)×(.*)","\\1~~\\2~~\\3",regular;

//改行
replaceallfast "^(.*)","\\1  ",regular;

//番号
replaceallfast "^①","1. ",regular;
replaceallfast "^②","2. ",regular;
replaceallfast "^③","3. ",regular;
replaceallfast "^④","4. ",regular;
replaceallfast "^⑤","5. ",regular;

save;
showwindow 1; // ウインドウを元に戻す
gofiletop;
enabledraw;

秀丸マクロ(md→txt)

appendsave filename +"→"+hour+"h"+minute+"m"+second+"s作成"+".txt";
openfile filename +"→"+hour+"h"+minute+"m"+second+"s作成"+".txt";
disabledraw;//画面の書換禁止

//見出し
replaceallfast "^(# )(.*)","■■■\\2",regular;
replaceallfast "^(## )(.*)","■■\\2",regular;
replaceallfast "^(### )(.*)","■\\2",regular;

replaceallfast "^(---)","───────────────",regular;
replaceallfast "^(\\*\\*\\*)","───────────────",regular;

//箇条書き
replaceallfast "^  - ","  ・",regular;
replaceallfast "^ - "," ・",regular;
replaceallfast "^- ","・",regular;

//箇条書き・その2
replaceallfast "^  \\* ","  ・",regular;
replaceallfast "^ \\* "," ・",regular;
replaceallfast "^\\* ","・",regular;

//強調文字
replaceallfast "(.*)\\*\\*(.*)\\*\\*(.*)","\\1【\\2】\\3",regular;
replaceallfast "(.*)\\*(.*)\\*(.*)","\\1「\\2」\\3",regular;

//見消線
replaceallfast "(.*)~~(.*)~~(.*)","\\\\\\3",regular;

//改行
replaceallfast "  ","";

//番号
replaceallfast "^1. ","①",regular;
replaceallfast "^2. ","②",regular;
replaceallfast "^3. ","③",regular;
replaceallfast "^4. ","④",regular;
replaceallfast "^5. ","⑤",regular;

save;
showwindow 1; // ウインドウを元に戻す
gofiletop;
enabledraw;
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3