LoginSignup
4
3

More than 3 years have passed since last update.

Markdown正規表現全文検索ツール「Note-CLI」をリリースしました。

Posted at

Markdown正規表現全文検索ツール「Note-CLI」をリリースしました。

以下かんたんな日本語版クイックスタートになります。

Markdown Indexing and Pcre Regular Expression Compatible Full Text Searching for Advanced Note Takers.

ノートテイキング上級者のためのMarkdownインデックスとPCRE正規表現対応の全文検索システム。

クイックスタート


# データベースへMarkdownファイルをインデックス indexing file
./note-cli.js --index --database notes.db.example --file notes.md.example

# データベースで正規表現でキーワード検索 searching for keywords by regular expression
./note-cli.js --search --database notes.db.example --header "python" --content "hello.?world" --hide-sql

# 出力結果 and you will get:
[
    {
        "id": 2,
        "header": "how to hello world in python",
        "content": "```py \n# how to hello world in python\n\nprint(\"hello world\")\n```\n\n",
        "entire_note": "# how to hello world in python\n\n```py \n# how to hello world in python\n\nprint(\"hello world\")\n```\n\n"
    }
]

コンセプト Basic concept

There are great note taking tools over there, such as Evernote. But the reason I quit using Evernote was its poor searching capability (i.e. cannot search some special characters; cannot search with regular expression, of course) and also, lack of extensibility. That's where Note-CLI comes in.

I'm kind of person who likes to take a note on my favorite text editor (Atom editor, for my case). For note taking, I have a single Markdown format text file. In it, I do take notes about everything. Note-CLI does work for indexing chunks of Markdown content to a database file and enables you to search your Markdown notes with SQL query (and also regex).

巷には既に便利なノートテイキングツールが数多くあります。例えば僕はEvernoteの愛用者でしたが、Evernoteでは検索において特定の特殊文字を使えない、正規表現が使えない、など、欠点があります。オープンソースではないので、拡張性の低さもその一つです。そこにNote-CLIの活用場面があります。

僕は大抵のノートテイキングは、お気に入りのAtomエディタから、一つのMarkdown形式のファイル上で行います。そこにほぼ全ての知識があるわけです。Note-CLIはこのようなMarkdown形式で記述されたノートをパーシングしデータベースへインデックス、SQLおよび正規表現でのノートの検索を可能にします。

インストール Installation


git clone https://github.com/yuis-ice/note-cli.git
cd note-cli
chmod 755 ./note-cli.js # if needed
npm i

必要環境 Requirement

  • node.js v13.10.1 (probably higher or other versions work)
  • sqlite3-pcre

# node.js [nvm-sh/nvm](https://github.com/nvm-sh/nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
bash
nvm install v13.10.1
node -v

# sqlite3-pcre
sudo apt update
sudo apt install sqlite3 sqlite3-pcre

例 Examples

https://yuis.xsrv.jp/images/ss/ShareX_ScreenShot_da0baae1-0746-49b4-ab0d-790b1adddb7c.png


./note-cli.js --search --database notes.db.example --header "python" --content "hello.?world" --limit 1 --hide-sql --format md | bat -l md --paging=never # using [sharkdp/bat](https://github.com/sharkdp/bat) *image
./note-cli.js --search --database notes.db.example --header "python" --content "hello.?world" --limit 1 --hide-sql --format json | jq ".[].header" -r # using [jq](https://github.com/stedolan/jq/)
./note-cli.js --search --database notes.db.example --header "python" --content "hello.?world" --limit 1 --hide-sql --format html | jq ".[].entire_note" -r
./note-cli.js --search --database notes.db.example --header "python" --content "hello.?world" --limit 1 --raw-sql "$( cat raw-sql.sql.example )"

コマンドラインオプション Command line options


$ ./note-cli.js --help
Usage: note-cli [options]

Options:
  -i, --index            set command type: index
  -f, --file <file>      (index) specify file to index (default: null)
  -s, --search           set command type: search
  -r, --regex            (search) enable regex extension for search (default: true)
  --header <keyword>     (search) search by header (default: ".")
  --content <keyword>    (search) search by content (default: ".")
  --note <keyword>       (search) search by note (default: ".")
  --limit <number>       (search) set limit for search (default: -1)
  -S, --raw-sql <sql>    (search) use raw SQL query for search (default: null)
  -H, --hide-sql         (search) disable showing sql query executed
  -F, --format <format>  (search) output format (default: "json")
  --pcre-path <file>     set sqlite3 pcre file path for search (default: "/usr/lib/sqlite3/pcre.so")
  -d, --database <file>  specify database file for index/search (default: "./note-cli.db")
  --delete-database      delete database
  -y, --yes              no confirmation prompt
  -h, --help             display help for command

4
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
4
3