@commte/mdbrowse 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +10 -2
- package/README.md +10 -2
- package/assets/head.html +3 -1
- package/bin/mdbrowse +13 -1
- package/package.json +10 -1
package/README.ja.md
CHANGED
|
@@ -47,7 +47,7 @@ cd mdbrowse
|
|
|
47
47
|
./install.sh
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
`mdb`(と長いほうの `mdbrowse
|
|
50
|
+
`install.sh` は、実行に要る依存(Shiki)が無ければ npm で入れてから、`mdb`(と長いほうの `mdbrowse`)を `~/.local/bin` に、スタイルシートを `~/.config/mdbrowse/head.html` に置く。再インストールしても自分で編集したスタイルシートは上書きされない。配布時の状態に戻したいときは `--force` を付ける
|
|
51
51
|
|
|
52
52
|
</details>
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ mdb
|
|
|
59
59
|
|
|
60
60
|
プレビュー用のタブが開き、小さな背景プロセスが動きだす。以後どの Markdown を保存しても、どのプロジェクトのものでも、そのタブに出る。止めるときは `mdb --stop`、再開はまた `mdb`
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
ログアウトや再起動で消えるので、そのままだと次に使うときにもう一度 `mdb` を叩くことになる。macOS なら、勝手に戻ってくるようにもできる
|
|
63
63
|
|
|
64
64
|
```sh
|
|
65
65
|
mdb --install-agent
|
|
@@ -186,6 +186,14 @@ vim.api.nvim_create_autocmd("BufWritePost", {
|
|
|
186
186
|
mdb sample.md
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
## テスト
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm test
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`test/cli.sh` はコマンド側を動かす。変換、相対パスの書き換え、異常系、監視、背景プロセスまで通す。必要なのは pandoc だけ。`test/browser.test.js` は `assets/head.html` からスクリプトを取り出して jsdom で動かし、更新の検知、目次の判定、バーの設定を見る。CI では macOS と Linux の両方で回していて、通らないものは公開されない
|
|
196
|
+
|
|
189
197
|
## 仕組み
|
|
190
198
|
|
|
191
199
|
```
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ cd mdbrowse
|
|
|
47
47
|
./install.sh
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
`install.sh` pulls in the one runtime dependency (Shiki) with npm if it is not there yet, then installs `mdb` (and the longer `mdbrowse`) into `~/.local/bin` and the stylesheet into `~/.config/mdbrowse/head.html`. Your stylesheet is never overwritten on reinstall; pass `--force` when you do want the shipped one back.
|
|
51
51
|
|
|
52
52
|
</details>
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ mdb
|
|
|
59
59
|
|
|
60
60
|
That opens the preview tab and starts a small background process. Save any Markdown file from here on and it shows up in that tab, whichever project it lives in. `mdb --stop` ends it; `mdb` starts it again.
|
|
61
61
|
|
|
62
|
-
The process is gone after a logout or a reboot. On macOS you can have it come back on its own:
|
|
62
|
+
The process is gone after a logout or a reboot, so otherwise you run `mdb` again next time. On macOS you can have it come back on its own:
|
|
63
63
|
|
|
64
64
|
```sh
|
|
65
65
|
mdb --install-agent
|
|
@@ -186,6 +186,14 @@ Everything else visual lives in `~/.config/mdbrowse/head.html`: a settings block
|
|
|
186
186
|
mdb sample.md
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
## Tests
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm test
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`test/cli.sh` drives the command itself — rendering, path rewriting, exit codes, watching, the background sync — and needs nothing but pandoc. `test/browser.test.js` pulls the script out of `assets/head.html` and runs it under jsdom, covering the reload loop, the table of contents rules and the settings bar. Both run on macOS and Linux in CI, and a release only goes out if they pass.
|
|
196
|
+
|
|
189
197
|
## How it works
|
|
190
198
|
|
|
191
199
|
```
|
package/assets/head.html
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
body {
|
|
57
57
|
max-width: var(--content-width);
|
|
58
58
|
margin: 0 auto;
|
|
59
|
-
padding:
|
|
59
|
+
padding: 80px 32px 160px;
|
|
60
60
|
font-size: var(--font-size);
|
|
61
61
|
line-height: var(--line-height);
|
|
62
62
|
font-family: var(--font-family);
|
|
@@ -79,6 +79,8 @@
|
|
|
79
79
|
h1:first-child { margin-top: 0; }
|
|
80
80
|
p, ul, ol, blockquote, table, pre { margin: 0 0 16px; }
|
|
81
81
|
a { color: var(--link); text-decoration: none; }
|
|
82
|
+
/* 訪問済みも同じ色にする。指定しないと環境によっては本文色に落ちて見分けが付かない */
|
|
83
|
+
a:visited { color: var(--link); }
|
|
82
84
|
a:hover { text-decoration: underline; }
|
|
83
85
|
code {
|
|
84
86
|
font-family: var(--code-font-family); font-size: 85%;
|
package/bin/mdbrowse
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# browser tab can stay open and just swap its contents.
|
|
4
4
|
set -euo pipefail
|
|
5
5
|
|
|
6
|
-
VERSION="0.3.
|
|
6
|
+
VERSION="0.3.3"
|
|
7
7
|
PROG="$(basename "$0")"
|
|
8
8
|
OUT="${MDBROWSE_OUT:-/tmp/mdbrowse.html}"
|
|
9
9
|
case "$OUT" in
|
|
@@ -141,6 +141,17 @@ stop_sync() {
|
|
|
141
141
|
if [ "$stopped" -eq 1 ]; then echo "$PROG: stopped"; else echo "$PROG: not running"; fi
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
# ログイン時の自動起動があることを、初回だけ1行で知らせる。
|
|
145
|
+
# 毎回出すと邪魔になるので、一度出したら記録して黙る
|
|
146
|
+
hint_agent() {
|
|
147
|
+
[ "$(uname -s)" = "Darwin" ] || return 0
|
|
148
|
+
agent_installed && return 0
|
|
149
|
+
[ -f "$RUNTIME_DIR/agent-hint" ] && return 0
|
|
150
|
+
mkdir -p "$RUNTIME_DIR" 2>/dev/null || true
|
|
151
|
+
: > "$RUNTIME_DIR/agent-hint" 2>/dev/null || true
|
|
152
|
+
echo "$PROG: it stops at logout — 'mdb --install-agent' starts it at every login"
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
start_sync() {
|
|
145
156
|
if running_pid >/dev/null; then
|
|
146
157
|
echo "$PROG: already in sync (mdb --stop to end it)"
|
|
@@ -156,6 +167,7 @@ start_sync() {
|
|
|
156
167
|
done
|
|
157
168
|
if running_pid >/dev/null; then
|
|
158
169
|
echo "$PROG: in sync — save any .md and it shows up here (mdb --stop to end it)"
|
|
170
|
+
hint_agent
|
|
159
171
|
else
|
|
160
172
|
echo "$PROG: could not start the background sync (see $LOGFILE)" >&2
|
|
161
173
|
return 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commte/mdbrowse",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Preview the Markdown file you are editing in a real browser, with your own CSS, from any editor that can run a shell command. No server, no port.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mdbrowse": "bin/mdbrowse",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"README.ja.md",
|
|
16
16
|
"LICENSE"
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "bash test/cli.sh && vitest run",
|
|
20
|
+
"test:cli": "bash test/cli.sh",
|
|
21
|
+
"test:browser": "vitest run"
|
|
22
|
+
},
|
|
18
23
|
"keywords": [
|
|
19
24
|
"markdown",
|
|
20
25
|
"preview",
|
|
@@ -43,5 +48,9 @@
|
|
|
43
48
|
},
|
|
44
49
|
"dependencies": {
|
|
45
50
|
"shiki": "^4.4.3"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"jsdom": "^30.0.1",
|
|
54
|
+
"vitest": "^5.0.0"
|
|
46
55
|
}
|
|
47
56
|
}
|