nanopeek 0.1.0__tar.gz
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.
- nanopeek-0.1.0/LICENSE +21 -0
- nanopeek-0.1.0/PKG-INFO +166 -0
- nanopeek-0.1.0/README.md +141 -0
- nanopeek-0.1.0/nanopeek.egg-info/PKG-INFO +166 -0
- nanopeek-0.1.0/nanopeek.egg-info/SOURCES.txt +10 -0
- nanopeek-0.1.0/nanopeek.egg-info/dependency_links.txt +1 -0
- nanopeek-0.1.0/nanopeek.egg-info/entry_points.txt +2 -0
- nanopeek-0.1.0/nanopeek.egg-info/requires.txt +10 -0
- nanopeek-0.1.0/nanopeek.egg-info/top_level.txt +1 -0
- nanopeek-0.1.0/nanopeek.py +1456 -0
- nanopeek-0.1.0/pyproject.toml +42 -0
- nanopeek-0.1.0/setup.cfg +4 -0
nanopeek-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 grobelr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
nanopeek-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nanopeek
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: nano-style terminal editor with live Markdown, JSON, YAML, TOML and Dockerfile previews
|
|
5
|
+
Author: grobelr
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/grobelr/nanopeek
|
|
8
|
+
Keywords: markdown,editor,nano,tui,terminal,preview
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Text Editors
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: textual>=3.0
|
|
17
|
+
Requires-Dist: tree-sitter>=0.23
|
|
18
|
+
Requires-Dist: tree-sitter-markdown>=0.3
|
|
19
|
+
Requires-Dist: tree-sitter-json>=0.21
|
|
20
|
+
Requires-Dist: tree-sitter-yaml>=0.6
|
|
21
|
+
Requires-Dist: tree-sitter-toml>=0.6
|
|
22
|
+
Requires-Dist: PyYAML>=6.0
|
|
23
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# nanopeek
|
|
27
|
+
|
|
28
|
+
A [`nano`](https://www.nano-editor.org/)-style terminal editor with a
|
|
29
|
+
**live, properly rendered preview** — edit on the left, watch it render on
|
|
30
|
+
the right. For Markdown files the right pane shows the rendered document;
|
|
31
|
+
for `.json` files it becomes a live **JSON formatter and validator**.
|
|
32
|
+
YAML, TOML, and Dockerfiles get a **syntax-highlighted source preview**;
|
|
33
|
+
YAML and TOML also show live syntax errors.
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
## What it does
|
|
38
|
+
|
|
39
|
+
- **Split view** — raw text on the left, rendered result on the right:
|
|
40
|
+
for Markdown, headings, **bold**/*italic*, lists (incl. task lists), tables,
|
|
41
|
+
fenced code blocks with syntax highlighting, block quotes, horizontal
|
|
42
|
+
rules, links; for `.json`, a pretty-printed, syntax-highlighted formatter
|
|
43
|
+
that doubles as a live validator (parse errors show the offending line and
|
|
44
|
+
column as you type).
|
|
45
|
+
- **JSON mode is automatic** — open any `.json`, `.jsonl`, `.ndjson` or
|
|
46
|
+
`.jsonc` file (or force it with `--json`; `--markdown` forces the
|
|
47
|
+
Markdown view). The editor switches to JSON syntax highlighting too, and
|
|
48
|
+
saving a buffer out as one of these switches the preview on the fly.
|
|
49
|
+
JSON Lines files render as one pretty-printed, colored record each;
|
|
50
|
+
JSONC comments (`//`, `/* */`) and trailing commas are tolerated —
|
|
51
|
+
commented `.json` files get the same leniency. Broken input shows the
|
|
52
|
+
exact line and column.
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
- **Configuration viewers** — `.yaml`/`.yml` (including Docker Compose)
|
|
56
|
+
and `.toml` files display highlighted source with live syntax validation.
|
|
57
|
+
Comments, ordering, spacing, and YAML document separators stay intact.
|
|
58
|
+
Dockerfiles and Containerfiles are highlighted too, including names such
|
|
59
|
+
as `Dockerfile.dev`, `Containerfile.prod`, and `build.Dockerfile`.
|
|
60
|
+
Dockerfile viewing does not run builds or validate Docker instructions;
|
|
61
|
+
Compose validation checks YAML syntax, not the Compose schema.
|
|
62
|
+
These previews show at most 2,000 lines without changing the buffer.
|
|
63
|
+
- **Live updates** — the preview re-renders ~200 ms after you stop typing.
|
|
64
|
+
The two panes scroll **together, in both directions** (mouse wheel,
|
|
65
|
+
keys, either side). For Markdown the sync is **section-aware**: the
|
|
66
|
+
preview anchors to the rendered heading matching your cursor's source
|
|
67
|
+
section (via markdown-it), so long documents with code blocks and
|
|
68
|
+
tables stay aligned instead of drifting; heading-less documents and
|
|
69
|
+
the JSON views fall back to proportional scrolling.
|
|
70
|
+
- **Scales to large files** — on big buffers the app trims itself
|
|
71
|
+
automatically: the JSON formatter renders at most 2,000 lines and the
|
|
72
|
+
Markdown preview at most 12,000 (with a notice; your file is never
|
|
73
|
+
touched), and for enormous single lines (minified JSON) or
|
|
74
|
+
multi-hundred-KB buffers it turns off soft wrap, cursor blink and
|
|
75
|
+
tree-sitter highlighting — everything comes back once the document is
|
|
76
|
+
small again.
|
|
77
|
+
- **nano keybindings** — feel right at home: `^O` write out, `^S` save, `^X`
|
|
78
|
+
exit (asks to save a modified buffer), `^K`/`^U` cut line/uncut, `^W` where
|
|
79
|
+
is, `^Y`/`^V` page up/down, `^A`/`^E` line start/end, `^G` help.
|
|
80
|
+
- **Markdown syntax highlighting in the editor** via tree-sitter.
|
|
81
|
+
- **Auto-copy on select** — highlighting text with the mouse (or
|
|
82
|
+
Shift+arrows) copies it to the system clipboard immediately.
|
|
83
|
+
- **Toggleable preview** — `^P` cycles between the split view, a
|
|
84
|
+
full-screen rendered Markdown page (read mode), and editor-only.
|
|
85
|
+
- **Display modes** — cycle 12 themes including dark and light (`Alt+T`),
|
|
86
|
+
flip dark/light (`Alt+D`), switch color depth between truecolor, ANSI
|
|
87
|
+
(16 colors) and mono (`Alt+C`), and force ASCII-only output for legacy
|
|
88
|
+
terminals (`Alt+A`). All also available as CLI flags.
|
|
89
|
+
|
|
90
|
+
## Install
|
|
91
|
+
|
|
92
|
+
Requires Python 3.9+.
|
|
93
|
+
|
|
94
|
+
pipx install .
|
|
95
|
+
|
|
96
|
+
or, for development:
|
|
97
|
+
|
|
98
|
+
pip install -e .
|
|
99
|
+
|
|
100
|
+
That installs the `nanopeek` command and its dependencies, including Textual,
|
|
101
|
+
tree-sitter grammars, PyYAML, and (on Python older than 3.11) `tomli`.
|
|
102
|
+
YAML and TOML editor highlighting uses their installed tree-sitter grammars;
|
|
103
|
+
the preview remains highlighted if an editor grammar is unavailable.
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
nanopeek # new, unsaved buffer
|
|
108
|
+
nanopeek note.md # open (or create on save) a file
|
|
109
|
+
nanopeek --theme nord # start with a specific theme (--themes lists all)
|
|
110
|
+
nanopeek --color ansi # 16-color mode (truecolor | ansi | mono)
|
|
111
|
+
nanopeek --ascii # ASCII-only output for legacy terminals
|
|
112
|
+
nanopeek data.json # JSON formatter/validator preview
|
|
113
|
+
nanopeek events.jsonl # JSON Lines: one pretty record per line
|
|
114
|
+
nanopeek notes.txt --json # force the JSON view for any file
|
|
115
|
+
nanopeek compose.yaml # YAML source preview and syntax validation
|
|
116
|
+
nanopeek pyproject.toml # TOML source preview and syntax validation
|
|
117
|
+
nanopeek Dockerfile # Dockerfile source preview
|
|
118
|
+
nanopeek config --yaml # force YAML for a file without an extension
|
|
119
|
+
nanopeek config --toml # force TOML
|
|
120
|
+
nanopeek build --dockerfile # force Dockerfile highlighting
|
|
121
|
+
|
|
122
|
+
| Key | Action |
|
|
123
|
+
|-----------------|----------------------------------------------|
|
|
124
|
+
| `^G` | Get help |
|
|
125
|
+
| `^O` | Write out (save, always prompting for name) |
|
|
126
|
+
| `^S` | Save |
|
|
127
|
+
| `^X` | Exit (prompts if the buffer is modified) |
|
|
128
|
+
| `^W` | Where is — Enter jumps to next match |
|
|
129
|
+
| `^K` / `^U` | Cut line (consecutive cuts append) / uncut |
|
|
130
|
+
| `^Y` / `^V` | Previous / next page |
|
|
131
|
+
| `^A` / `^E` | Beginning / end of line |
|
|
132
|
+
| `^P` | Cycle view: split / full rendered page / editor only |
|
|
133
|
+
| `Alt+T` / `Alt+D` | Cycle themes / toggle dark-light |
|
|
134
|
+
| `Alt+C` | Cycle color mode: truecolor / ansi / mono |
|
|
135
|
+
| `Alt+A` | Toggle ASCII-only output |
|
|
136
|
+
| `Tab` | Switch focus between editor and preview |
|
|
137
|
+
| `Ctrl+Shift+X/C/V` | Cut / copy / paste in the editor |
|
|
138
|
+
| `Ctrl+Shift+P` | Textual command palette |
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
Run the headless smoke tests (no TTY needed):
|
|
143
|
+
|
|
144
|
+
python3 tests/smoke_test.py
|
|
145
|
+
|
|
146
|
+
Run the exhaustive keyboard and save/exit-flow tests (32 checks — every
|
|
147
|
+
keybinding in both focus panes, and every save / no-save / exit path
|
|
148
|
+
verified against the real filesystem, content and mtime):
|
|
149
|
+
|
|
150
|
+
python3 tests/keyboard_test.py
|
|
151
|
+
|
|
152
|
+
Run the JSON formatter-mode tests:
|
|
153
|
+
|
|
154
|
+
python3 tests/json_test.py
|
|
155
|
+
|
|
156
|
+
Run the YAML, TOML, and Dockerfile viewer tests:
|
|
157
|
+
|
|
158
|
+
python3 tests/config_test.py
|
|
159
|
+
|
|
160
|
+
Regenerate the screenshot:
|
|
161
|
+
|
|
162
|
+
python3 scripts/screenshot.py
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT — see [LICENSE](https://github.com/grobelr/nanopeek/blob/main/LICENSE).
|
nanopeek-0.1.0/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# nanopeek
|
|
2
|
+
|
|
3
|
+
A [`nano`](https://www.nano-editor.org/)-style terminal editor with a
|
|
4
|
+
**live, properly rendered preview** — edit on the left, watch it render on
|
|
5
|
+
the right. For Markdown files the right pane shows the rendered document;
|
|
6
|
+
for `.json` files it becomes a live **JSON formatter and validator**.
|
|
7
|
+
YAML, TOML, and Dockerfiles get a **syntax-highlighted source preview**;
|
|
8
|
+
YAML and TOML also show live syntax errors.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- **Split view** — raw text on the left, rendered result on the right:
|
|
15
|
+
for Markdown, headings, **bold**/*italic*, lists (incl. task lists), tables,
|
|
16
|
+
fenced code blocks with syntax highlighting, block quotes, horizontal
|
|
17
|
+
rules, links; for `.json`, a pretty-printed, syntax-highlighted formatter
|
|
18
|
+
that doubles as a live validator (parse errors show the offending line and
|
|
19
|
+
column as you type).
|
|
20
|
+
- **JSON mode is automatic** — open any `.json`, `.jsonl`, `.ndjson` or
|
|
21
|
+
`.jsonc` file (or force it with `--json`; `--markdown` forces the
|
|
22
|
+
Markdown view). The editor switches to JSON syntax highlighting too, and
|
|
23
|
+
saving a buffer out as one of these switches the preview on the fly.
|
|
24
|
+
JSON Lines files render as one pretty-printed, colored record each;
|
|
25
|
+
JSONC comments (`//`, `/* */`) and trailing commas are tolerated —
|
|
26
|
+
commented `.json` files get the same leniency. Broken input shows the
|
|
27
|
+
exact line and column.
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
- **Configuration viewers** — `.yaml`/`.yml` (including Docker Compose)
|
|
31
|
+
and `.toml` files display highlighted source with live syntax validation.
|
|
32
|
+
Comments, ordering, spacing, and YAML document separators stay intact.
|
|
33
|
+
Dockerfiles and Containerfiles are highlighted too, including names such
|
|
34
|
+
as `Dockerfile.dev`, `Containerfile.prod`, and `build.Dockerfile`.
|
|
35
|
+
Dockerfile viewing does not run builds or validate Docker instructions;
|
|
36
|
+
Compose validation checks YAML syntax, not the Compose schema.
|
|
37
|
+
These previews show at most 2,000 lines without changing the buffer.
|
|
38
|
+
- **Live updates** — the preview re-renders ~200 ms after you stop typing.
|
|
39
|
+
The two panes scroll **together, in both directions** (mouse wheel,
|
|
40
|
+
keys, either side). For Markdown the sync is **section-aware**: the
|
|
41
|
+
preview anchors to the rendered heading matching your cursor's source
|
|
42
|
+
section (via markdown-it), so long documents with code blocks and
|
|
43
|
+
tables stay aligned instead of drifting; heading-less documents and
|
|
44
|
+
the JSON views fall back to proportional scrolling.
|
|
45
|
+
- **Scales to large files** — on big buffers the app trims itself
|
|
46
|
+
automatically: the JSON formatter renders at most 2,000 lines and the
|
|
47
|
+
Markdown preview at most 12,000 (with a notice; your file is never
|
|
48
|
+
touched), and for enormous single lines (minified JSON) or
|
|
49
|
+
multi-hundred-KB buffers it turns off soft wrap, cursor blink and
|
|
50
|
+
tree-sitter highlighting — everything comes back once the document is
|
|
51
|
+
small again.
|
|
52
|
+
- **nano keybindings** — feel right at home: `^O` write out, `^S` save, `^X`
|
|
53
|
+
exit (asks to save a modified buffer), `^K`/`^U` cut line/uncut, `^W` where
|
|
54
|
+
is, `^Y`/`^V` page up/down, `^A`/`^E` line start/end, `^G` help.
|
|
55
|
+
- **Markdown syntax highlighting in the editor** via tree-sitter.
|
|
56
|
+
- **Auto-copy on select** — highlighting text with the mouse (or
|
|
57
|
+
Shift+arrows) copies it to the system clipboard immediately.
|
|
58
|
+
- **Toggleable preview** — `^P` cycles between the split view, a
|
|
59
|
+
full-screen rendered Markdown page (read mode), and editor-only.
|
|
60
|
+
- **Display modes** — cycle 12 themes including dark and light (`Alt+T`),
|
|
61
|
+
flip dark/light (`Alt+D`), switch color depth between truecolor, ANSI
|
|
62
|
+
(16 colors) and mono (`Alt+C`), and force ASCII-only output for legacy
|
|
63
|
+
terminals (`Alt+A`). All also available as CLI flags.
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
Requires Python 3.9+.
|
|
68
|
+
|
|
69
|
+
pipx install .
|
|
70
|
+
|
|
71
|
+
or, for development:
|
|
72
|
+
|
|
73
|
+
pip install -e .
|
|
74
|
+
|
|
75
|
+
That installs the `nanopeek` command and its dependencies, including Textual,
|
|
76
|
+
tree-sitter grammars, PyYAML, and (on Python older than 3.11) `tomli`.
|
|
77
|
+
YAML and TOML editor highlighting uses their installed tree-sitter grammars;
|
|
78
|
+
the preview remains highlighted if an editor grammar is unavailable.
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
nanopeek # new, unsaved buffer
|
|
83
|
+
nanopeek note.md # open (or create on save) a file
|
|
84
|
+
nanopeek --theme nord # start with a specific theme (--themes lists all)
|
|
85
|
+
nanopeek --color ansi # 16-color mode (truecolor | ansi | mono)
|
|
86
|
+
nanopeek --ascii # ASCII-only output for legacy terminals
|
|
87
|
+
nanopeek data.json # JSON formatter/validator preview
|
|
88
|
+
nanopeek events.jsonl # JSON Lines: one pretty record per line
|
|
89
|
+
nanopeek notes.txt --json # force the JSON view for any file
|
|
90
|
+
nanopeek compose.yaml # YAML source preview and syntax validation
|
|
91
|
+
nanopeek pyproject.toml # TOML source preview and syntax validation
|
|
92
|
+
nanopeek Dockerfile # Dockerfile source preview
|
|
93
|
+
nanopeek config --yaml # force YAML for a file without an extension
|
|
94
|
+
nanopeek config --toml # force TOML
|
|
95
|
+
nanopeek build --dockerfile # force Dockerfile highlighting
|
|
96
|
+
|
|
97
|
+
| Key | Action |
|
|
98
|
+
|-----------------|----------------------------------------------|
|
|
99
|
+
| `^G` | Get help |
|
|
100
|
+
| `^O` | Write out (save, always prompting for name) |
|
|
101
|
+
| `^S` | Save |
|
|
102
|
+
| `^X` | Exit (prompts if the buffer is modified) |
|
|
103
|
+
| `^W` | Where is — Enter jumps to next match |
|
|
104
|
+
| `^K` / `^U` | Cut line (consecutive cuts append) / uncut |
|
|
105
|
+
| `^Y` / `^V` | Previous / next page |
|
|
106
|
+
| `^A` / `^E` | Beginning / end of line |
|
|
107
|
+
| `^P` | Cycle view: split / full rendered page / editor only |
|
|
108
|
+
| `Alt+T` / `Alt+D` | Cycle themes / toggle dark-light |
|
|
109
|
+
| `Alt+C` | Cycle color mode: truecolor / ansi / mono |
|
|
110
|
+
| `Alt+A` | Toggle ASCII-only output |
|
|
111
|
+
| `Tab` | Switch focus between editor and preview |
|
|
112
|
+
| `Ctrl+Shift+X/C/V` | Cut / copy / paste in the editor |
|
|
113
|
+
| `Ctrl+Shift+P` | Textual command palette |
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
Run the headless smoke tests (no TTY needed):
|
|
118
|
+
|
|
119
|
+
python3 tests/smoke_test.py
|
|
120
|
+
|
|
121
|
+
Run the exhaustive keyboard and save/exit-flow tests (32 checks — every
|
|
122
|
+
keybinding in both focus panes, and every save / no-save / exit path
|
|
123
|
+
verified against the real filesystem, content and mtime):
|
|
124
|
+
|
|
125
|
+
python3 tests/keyboard_test.py
|
|
126
|
+
|
|
127
|
+
Run the JSON formatter-mode tests:
|
|
128
|
+
|
|
129
|
+
python3 tests/json_test.py
|
|
130
|
+
|
|
131
|
+
Run the YAML, TOML, and Dockerfile viewer tests:
|
|
132
|
+
|
|
133
|
+
python3 tests/config_test.py
|
|
134
|
+
|
|
135
|
+
Regenerate the screenshot:
|
|
136
|
+
|
|
137
|
+
python3 scripts/screenshot.py
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT — see [LICENSE](https://github.com/grobelr/nanopeek/blob/main/LICENSE).
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nanopeek
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: nano-style terminal editor with live Markdown, JSON, YAML, TOML and Dockerfile previews
|
|
5
|
+
Author: grobelr
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/grobelr/nanopeek
|
|
8
|
+
Keywords: markdown,editor,nano,tui,terminal,preview
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Text Editors
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: textual>=3.0
|
|
17
|
+
Requires-Dist: tree-sitter>=0.23
|
|
18
|
+
Requires-Dist: tree-sitter-markdown>=0.3
|
|
19
|
+
Requires-Dist: tree-sitter-json>=0.21
|
|
20
|
+
Requires-Dist: tree-sitter-yaml>=0.6
|
|
21
|
+
Requires-Dist: tree-sitter-toml>=0.6
|
|
22
|
+
Requires-Dist: PyYAML>=6.0
|
|
23
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# nanopeek
|
|
27
|
+
|
|
28
|
+
A [`nano`](https://www.nano-editor.org/)-style terminal editor with a
|
|
29
|
+
**live, properly rendered preview** — edit on the left, watch it render on
|
|
30
|
+
the right. For Markdown files the right pane shows the rendered document;
|
|
31
|
+
for `.json` files it becomes a live **JSON formatter and validator**.
|
|
32
|
+
YAML, TOML, and Dockerfiles get a **syntax-highlighted source preview**;
|
|
33
|
+
YAML and TOML also show live syntax errors.
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
## What it does
|
|
38
|
+
|
|
39
|
+
- **Split view** — raw text on the left, rendered result on the right:
|
|
40
|
+
for Markdown, headings, **bold**/*italic*, lists (incl. task lists), tables,
|
|
41
|
+
fenced code blocks with syntax highlighting, block quotes, horizontal
|
|
42
|
+
rules, links; for `.json`, a pretty-printed, syntax-highlighted formatter
|
|
43
|
+
that doubles as a live validator (parse errors show the offending line and
|
|
44
|
+
column as you type).
|
|
45
|
+
- **JSON mode is automatic** — open any `.json`, `.jsonl`, `.ndjson` or
|
|
46
|
+
`.jsonc` file (or force it with `--json`; `--markdown` forces the
|
|
47
|
+
Markdown view). The editor switches to JSON syntax highlighting too, and
|
|
48
|
+
saving a buffer out as one of these switches the preview on the fly.
|
|
49
|
+
JSON Lines files render as one pretty-printed, colored record each;
|
|
50
|
+
JSONC comments (`//`, `/* */`) and trailing commas are tolerated —
|
|
51
|
+
commented `.json` files get the same leniency. Broken input shows the
|
|
52
|
+
exact line and column.
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
- **Configuration viewers** — `.yaml`/`.yml` (including Docker Compose)
|
|
56
|
+
and `.toml` files display highlighted source with live syntax validation.
|
|
57
|
+
Comments, ordering, spacing, and YAML document separators stay intact.
|
|
58
|
+
Dockerfiles and Containerfiles are highlighted too, including names such
|
|
59
|
+
as `Dockerfile.dev`, `Containerfile.prod`, and `build.Dockerfile`.
|
|
60
|
+
Dockerfile viewing does not run builds or validate Docker instructions;
|
|
61
|
+
Compose validation checks YAML syntax, not the Compose schema.
|
|
62
|
+
These previews show at most 2,000 lines without changing the buffer.
|
|
63
|
+
- **Live updates** — the preview re-renders ~200 ms after you stop typing.
|
|
64
|
+
The two panes scroll **together, in both directions** (mouse wheel,
|
|
65
|
+
keys, either side). For Markdown the sync is **section-aware**: the
|
|
66
|
+
preview anchors to the rendered heading matching your cursor's source
|
|
67
|
+
section (via markdown-it), so long documents with code blocks and
|
|
68
|
+
tables stay aligned instead of drifting; heading-less documents and
|
|
69
|
+
the JSON views fall back to proportional scrolling.
|
|
70
|
+
- **Scales to large files** — on big buffers the app trims itself
|
|
71
|
+
automatically: the JSON formatter renders at most 2,000 lines and the
|
|
72
|
+
Markdown preview at most 12,000 (with a notice; your file is never
|
|
73
|
+
touched), and for enormous single lines (minified JSON) or
|
|
74
|
+
multi-hundred-KB buffers it turns off soft wrap, cursor blink and
|
|
75
|
+
tree-sitter highlighting — everything comes back once the document is
|
|
76
|
+
small again.
|
|
77
|
+
- **nano keybindings** — feel right at home: `^O` write out, `^S` save, `^X`
|
|
78
|
+
exit (asks to save a modified buffer), `^K`/`^U` cut line/uncut, `^W` where
|
|
79
|
+
is, `^Y`/`^V` page up/down, `^A`/`^E` line start/end, `^G` help.
|
|
80
|
+
- **Markdown syntax highlighting in the editor** via tree-sitter.
|
|
81
|
+
- **Auto-copy on select** — highlighting text with the mouse (or
|
|
82
|
+
Shift+arrows) copies it to the system clipboard immediately.
|
|
83
|
+
- **Toggleable preview** — `^P` cycles between the split view, a
|
|
84
|
+
full-screen rendered Markdown page (read mode), and editor-only.
|
|
85
|
+
- **Display modes** — cycle 12 themes including dark and light (`Alt+T`),
|
|
86
|
+
flip dark/light (`Alt+D`), switch color depth between truecolor, ANSI
|
|
87
|
+
(16 colors) and mono (`Alt+C`), and force ASCII-only output for legacy
|
|
88
|
+
terminals (`Alt+A`). All also available as CLI flags.
|
|
89
|
+
|
|
90
|
+
## Install
|
|
91
|
+
|
|
92
|
+
Requires Python 3.9+.
|
|
93
|
+
|
|
94
|
+
pipx install .
|
|
95
|
+
|
|
96
|
+
or, for development:
|
|
97
|
+
|
|
98
|
+
pip install -e .
|
|
99
|
+
|
|
100
|
+
That installs the `nanopeek` command and its dependencies, including Textual,
|
|
101
|
+
tree-sitter grammars, PyYAML, and (on Python older than 3.11) `tomli`.
|
|
102
|
+
YAML and TOML editor highlighting uses their installed tree-sitter grammars;
|
|
103
|
+
the preview remains highlighted if an editor grammar is unavailable.
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
nanopeek # new, unsaved buffer
|
|
108
|
+
nanopeek note.md # open (or create on save) a file
|
|
109
|
+
nanopeek --theme nord # start with a specific theme (--themes lists all)
|
|
110
|
+
nanopeek --color ansi # 16-color mode (truecolor | ansi | mono)
|
|
111
|
+
nanopeek --ascii # ASCII-only output for legacy terminals
|
|
112
|
+
nanopeek data.json # JSON formatter/validator preview
|
|
113
|
+
nanopeek events.jsonl # JSON Lines: one pretty record per line
|
|
114
|
+
nanopeek notes.txt --json # force the JSON view for any file
|
|
115
|
+
nanopeek compose.yaml # YAML source preview and syntax validation
|
|
116
|
+
nanopeek pyproject.toml # TOML source preview and syntax validation
|
|
117
|
+
nanopeek Dockerfile # Dockerfile source preview
|
|
118
|
+
nanopeek config --yaml # force YAML for a file without an extension
|
|
119
|
+
nanopeek config --toml # force TOML
|
|
120
|
+
nanopeek build --dockerfile # force Dockerfile highlighting
|
|
121
|
+
|
|
122
|
+
| Key | Action |
|
|
123
|
+
|-----------------|----------------------------------------------|
|
|
124
|
+
| `^G` | Get help |
|
|
125
|
+
| `^O` | Write out (save, always prompting for name) |
|
|
126
|
+
| `^S` | Save |
|
|
127
|
+
| `^X` | Exit (prompts if the buffer is modified) |
|
|
128
|
+
| `^W` | Where is — Enter jumps to next match |
|
|
129
|
+
| `^K` / `^U` | Cut line (consecutive cuts append) / uncut |
|
|
130
|
+
| `^Y` / `^V` | Previous / next page |
|
|
131
|
+
| `^A` / `^E` | Beginning / end of line |
|
|
132
|
+
| `^P` | Cycle view: split / full rendered page / editor only |
|
|
133
|
+
| `Alt+T` / `Alt+D` | Cycle themes / toggle dark-light |
|
|
134
|
+
| `Alt+C` | Cycle color mode: truecolor / ansi / mono |
|
|
135
|
+
| `Alt+A` | Toggle ASCII-only output |
|
|
136
|
+
| `Tab` | Switch focus between editor and preview |
|
|
137
|
+
| `Ctrl+Shift+X/C/V` | Cut / copy / paste in the editor |
|
|
138
|
+
| `Ctrl+Shift+P` | Textual command palette |
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
Run the headless smoke tests (no TTY needed):
|
|
143
|
+
|
|
144
|
+
python3 tests/smoke_test.py
|
|
145
|
+
|
|
146
|
+
Run the exhaustive keyboard and save/exit-flow tests (32 checks — every
|
|
147
|
+
keybinding in both focus panes, and every save / no-save / exit path
|
|
148
|
+
verified against the real filesystem, content and mtime):
|
|
149
|
+
|
|
150
|
+
python3 tests/keyboard_test.py
|
|
151
|
+
|
|
152
|
+
Run the JSON formatter-mode tests:
|
|
153
|
+
|
|
154
|
+
python3 tests/json_test.py
|
|
155
|
+
|
|
156
|
+
Run the YAML, TOML, and Dockerfile viewer tests:
|
|
157
|
+
|
|
158
|
+
python3 tests/config_test.py
|
|
159
|
+
|
|
160
|
+
Regenerate the screenshot:
|
|
161
|
+
|
|
162
|
+
python3 scripts/screenshot.py
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT — see [LICENSE](https://github.com/grobelr/nanopeek/blob/main/LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nanopeek
|