md-collab-editor 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.
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ dist/
@@ -0,0 +1,10 @@
1
+ # MD Collaborative Editor
2
+
3
+ Local GitHub-style markdown editor shared between the user (browser) and Claude (terminal). See README.md.
4
+
5
+ - Package layout: code in `src/md_collab_editor/` (`server.py`, `static/`), installed as the `md-editor` command via `pyproject.toml` (hatchling, no dependencies). `docs/` is just a sample folder, not packaged.
6
+ - Run: `uv run md-editor [folder-or-file]` (or `md-editor` once installed with `uv tool install`), serves http://127.0.0.1:8765. Default document root is the current folder; the user can switch the root at runtime with the in-app file browser (`/api/root`), so check the status bar or `/api/config` for the folder currently open.
7
+ - **Collaborating on a document:** edit the `.md` file on disk directly with Edit/Write. The open editor reloads it live and flashes the change, so there is no need to go through the browser. Avoid rewriting the whole file while the user is typing; prefer targeted edits.
8
+ - In-browser "Ask Claude" requests run `claude -p` from `src/md_collab_editor/server.py` (`ask_claude`, `SYSTEM_PROMPT`), with tools restricted to Skill and Read.
9
+ - Front end: no build step; libraries come from CDNs (marked 12, CodeMirror 5, DOMPurify, highlight.js, KaTeX, mermaid 10, github-markdown-css).
10
+ - Gotchas: DOMPurify strips attributes containing `-->` (so mermaid source is kept as element text); mermaid.render is not re-entrant (renders are queued); blur CodeMirror before calling setSelection from preview code, or its input poll re-types the selection and wipes markers.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gareth Nisbet
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.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.5
2
+ Name: md-collab-editor
3
+ Version: 0.1.0
4
+ Summary: Local GitHub-style markdown editor shared between you and Claude Code
5
+ Project-URL: Repository, https://github.com/garethnisbet/MDColaboritiveEditor
6
+ Project-URL: Issues, https://github.com/garethnisbet/MDColaboritiveEditor/issues
7
+ Author: Gareth Nisbet
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: claude,claude-code,editor,gfm,markdown
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Text Editors
17
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+
21
+ # MD Collaborative Editor
22
+
23
+ A local markdown editor that renders exactly like GitHub, with Claude built in. You can highlight any passage and ask Claude to rewrite, tighten, restyle or critique it, then accept the suggestion or keep the original.
24
+
25
+ ## Install
26
+
27
+ Install it as a command with [uv](https://docs.astral.sh/uv/):
28
+
29
+ ```bash
30
+ uv tool install git+https://github.com/garethnisbet/MDColaboritiveEditor
31
+ ```
32
+
33
+ Or run it once without installing:
34
+
35
+ ```bash
36
+ uvx --from git+https://github.com/garethnisbet/MDColaboritiveEditor md-editor
37
+ ```
38
+
39
+ `pipx install git+https://github.com/garethnisbet/MDColaboritiveEditor` works too. Upgrade later with `uv tool upgrade md-collab-editor`.
40
+
41
+ ## Run
42
+
43
+ ```bash
44
+ md-editor # edit the .md files in the current folder
45
+ md-editor ~/notes # edit any folder
46
+ md-editor ~/proj/README.md # edit one file (its folder becomes the root)
47
+ md-editor --port 9000 --no-browser
48
+ ```
49
+
50
+ It needs only Python 3.9+ (standard library, no dependencies) and the `claude` CLI on your PATH; uv can't install `claude`, because it isn't a Python package. Without it, everything except *Ask Claude* still works. The page loads its libraries from a CDN, so the browser needs internet access.
51
+
52
+ To work on the editor itself, clone the repo and run `uv run md-editor docs`, which uses the code in the checkout.
53
+
54
+ ## Working with Claude
55
+
56
+ 1. **Highlight** text in the editor or in the rendered preview. In the preview a pop-up opens straight away; in the editor click the small *✦ Ask Claude* pill or press <kbd>Ctrl</kbd>+<kbd>J</kbd>.
57
+ 2. **Choose** a preset (*My style*, *Improve*, *Tighten*, *Expand*, *Simplify*, *Fix grammar*, *More formal/casual*, *To bullets/prose*, *Critique*) or type your own instruction. An instruction ending in `?` is treated as a question: Claude replies with a comment and leaves the text alone.
58
+ 3. A **card** appears in the Claude panel, and the passage is highlighted in purple while Claude works and in amber when the suggestion is ready. Each card offers:
59
+ - **Changes / Preview / Edit**: a word-level diff, the rendered result, or a text box for tweaking it by hand;
60
+ - **Accept**: replace the passage (Ctrl+Z undoes it);
61
+ - **Keep original**: discard the suggestion;
62
+ - **Retry**: ask for a different version;
63
+ - **Refine…**: give feedback such as "shorter" or "keep the first sentence" and get a revised version.
64
+ 4. With nothing selected, the request applies to the whole document.
65
+
66
+ You can run several requests at once, and you can keep editing while Claude works, because each card tracks its passage as the text moves. *My style* uses the `nisbet-writing-style` skill; any skill in `~/.claude/skills` appears as a preset. The model menu in the top bar picks Opus, Sonnet or Haiku.
67
+
68
+ Requests run through `claude -p` (headless Claude Code), so they use your existing Claude login and no API key is needed.
69
+
70
+ ## Working with Claude Code in a terminal
71
+
72
+ Documents are plain `.md` files on disk. When Claude Code, or anything else, edits a file, the open editor updates within about a second and briefly flashes the changed text. If you had unsaved edits at that moment, a banner asks which version to keep. The editor autosaves shortly after you stop typing (<kbd>Ctrl</kbd>+<kbd>S</kbd> saves at once).
73
+
74
+ ## Rendering
75
+
76
+ Rendering covers GitHub-flavoured markdown: tables, task lists (click the boxes in the preview to tick them), strikethrough, autolinks, `> [!NOTE]`-style alerts, syntax-highlighted code, `$…$` and `$$…$$` maths (KaTeX), ```` ```math ```` blocks, ```` ```mermaid ```` diagrams, heading anchors and inline HTML (sanitised). The preview uses `github-markdown-css` in light or dark (◐ button).
77
+
78
+ ## Editing
79
+
80
+ The toolbar covers headings, bold, italic, strikethrough, quotes, code, links, images, lists, task lists, tables and rules. Shortcuts: <kbd>Ctrl</kbd>+<kbd>B</kbd>/<kbd>I</kbd>/<kbd>K</kbd>, <kbd>Ctrl</kbd>+<kbd>F</kbd> to search, <kbd>Tab</kbd> to indent, and <kbd>Enter</kbd> to continue lists. Scrolling in the editor and the preview stays in sync, and clicking a preview block moves the cursor to it.
81
+
82
+ ## Opening files elsewhere
83
+
84
+ Click **📂** in the top bar (or *Open…* in the file list, or press <kbd>Ctrl</kbd>+<kbd>O</kbd>) to browse the disk. Click folders to move through them (↑ goes to the parent, ⌂ goes home), or type or paste a path and press Enter. Clicking a `.md` file opens it and makes its folder the working folder, so the sidebar lists its neighbours and live sync keeps working. *Use this folder* switches to the current folder without picking a file. The arrow keys and Enter also work in the list.
85
+
86
+ ## Exporting to PDF
87
+
88
+ Click **⬇ PDF** in the top bar. The document is rendered in GitHub's light style (even in dark mode) on A4 pages, with maths and diagrams included and without Claude's highlights. It is saved as `<name>.pdf` beside the markdown file and downloaded by the browser. Relative image links resolve because the page is printed from the markdown file's folder. This uses headless Google Chrome or Chromium; set `MDEDIT_CHROME=/path/to/chrome` if it isn't found on the PATH. For the browser's own print dialog, press <kbd>Ctrl</kbd>+<kbd>P</kbd>; the print stylesheet prints only the rendered document.
89
+
90
+ ## Files
91
+
92
+ All code lives in `src/md_collab_editor/`:
93
+
94
+ - `server.py`: HTTP server (file API, folder browsing and root switching, change events, `/api/ask` → `claude -p`, `/api/pdf` → headless Chrome)
95
+ - `static/index.html`, `static/app.css`: layout and GitHub-style theme
96
+ - `static/render.js`: markdown → HTML, with source offsets on every block so preview selections map back to the source
97
+ - `static/app.js`: editor, sync, selection mapping, ask bar, suggestion cards and word diff
@@ -0,0 +1,77 @@
1
+ # MD Collaborative Editor
2
+
3
+ A local markdown editor that renders exactly like GitHub, with Claude built in. You can highlight any passage and ask Claude to rewrite, tighten, restyle or critique it, then accept the suggestion or keep the original.
4
+
5
+ ## Install
6
+
7
+ Install it as a command with [uv](https://docs.astral.sh/uv/):
8
+
9
+ ```bash
10
+ uv tool install git+https://github.com/garethnisbet/MDColaboritiveEditor
11
+ ```
12
+
13
+ Or run it once without installing:
14
+
15
+ ```bash
16
+ uvx --from git+https://github.com/garethnisbet/MDColaboritiveEditor md-editor
17
+ ```
18
+
19
+ `pipx install git+https://github.com/garethnisbet/MDColaboritiveEditor` works too. Upgrade later with `uv tool upgrade md-collab-editor`.
20
+
21
+ ## Run
22
+
23
+ ```bash
24
+ md-editor # edit the .md files in the current folder
25
+ md-editor ~/notes # edit any folder
26
+ md-editor ~/proj/README.md # edit one file (its folder becomes the root)
27
+ md-editor --port 9000 --no-browser
28
+ ```
29
+
30
+ It needs only Python 3.9+ (standard library, no dependencies) and the `claude` CLI on your PATH; uv can't install `claude`, because it isn't a Python package. Without it, everything except *Ask Claude* still works. The page loads its libraries from a CDN, so the browser needs internet access.
31
+
32
+ To work on the editor itself, clone the repo and run `uv run md-editor docs`, which uses the code in the checkout.
33
+
34
+ ## Working with Claude
35
+
36
+ 1. **Highlight** text in the editor or in the rendered preview. In the preview a pop-up opens straight away; in the editor click the small *✦ Ask Claude* pill or press <kbd>Ctrl</kbd>+<kbd>J</kbd>.
37
+ 2. **Choose** a preset (*My style*, *Improve*, *Tighten*, *Expand*, *Simplify*, *Fix grammar*, *More formal/casual*, *To bullets/prose*, *Critique*) or type your own instruction. An instruction ending in `?` is treated as a question: Claude replies with a comment and leaves the text alone.
38
+ 3. A **card** appears in the Claude panel, and the passage is highlighted in purple while Claude works and in amber when the suggestion is ready. Each card offers:
39
+ - **Changes / Preview / Edit**: a word-level diff, the rendered result, or a text box for tweaking it by hand;
40
+ - **Accept**: replace the passage (Ctrl+Z undoes it);
41
+ - **Keep original**: discard the suggestion;
42
+ - **Retry**: ask for a different version;
43
+ - **Refine…**: give feedback such as "shorter" or "keep the first sentence" and get a revised version.
44
+ 4. With nothing selected, the request applies to the whole document.
45
+
46
+ You can run several requests at once, and you can keep editing while Claude works, because each card tracks its passage as the text moves. *My style* uses the `nisbet-writing-style` skill; any skill in `~/.claude/skills` appears as a preset. The model menu in the top bar picks Opus, Sonnet or Haiku.
47
+
48
+ Requests run through `claude -p` (headless Claude Code), so they use your existing Claude login and no API key is needed.
49
+
50
+ ## Working with Claude Code in a terminal
51
+
52
+ Documents are plain `.md` files on disk. When Claude Code, or anything else, edits a file, the open editor updates within about a second and briefly flashes the changed text. If you had unsaved edits at that moment, a banner asks which version to keep. The editor autosaves shortly after you stop typing (<kbd>Ctrl</kbd>+<kbd>S</kbd> saves at once).
53
+
54
+ ## Rendering
55
+
56
+ Rendering covers GitHub-flavoured markdown: tables, task lists (click the boxes in the preview to tick them), strikethrough, autolinks, `> [!NOTE]`-style alerts, syntax-highlighted code, `$…$` and `$$…$$` maths (KaTeX), ```` ```math ```` blocks, ```` ```mermaid ```` diagrams, heading anchors and inline HTML (sanitised). The preview uses `github-markdown-css` in light or dark (◐ button).
57
+
58
+ ## Editing
59
+
60
+ The toolbar covers headings, bold, italic, strikethrough, quotes, code, links, images, lists, task lists, tables and rules. Shortcuts: <kbd>Ctrl</kbd>+<kbd>B</kbd>/<kbd>I</kbd>/<kbd>K</kbd>, <kbd>Ctrl</kbd>+<kbd>F</kbd> to search, <kbd>Tab</kbd> to indent, and <kbd>Enter</kbd> to continue lists. Scrolling in the editor and the preview stays in sync, and clicking a preview block moves the cursor to it.
61
+
62
+ ## Opening files elsewhere
63
+
64
+ Click **📂** in the top bar (or *Open…* in the file list, or press <kbd>Ctrl</kbd>+<kbd>O</kbd>) to browse the disk. Click folders to move through them (↑ goes to the parent, ⌂ goes home), or type or paste a path and press Enter. Clicking a `.md` file opens it and makes its folder the working folder, so the sidebar lists its neighbours and live sync keeps working. *Use this folder* switches to the current folder without picking a file. The arrow keys and Enter also work in the list.
65
+
66
+ ## Exporting to PDF
67
+
68
+ Click **⬇ PDF** in the top bar. The document is rendered in GitHub's light style (even in dark mode) on A4 pages, with maths and diagrams included and without Claude's highlights. It is saved as `<name>.pdf` beside the markdown file and downloaded by the browser. Relative image links resolve because the page is printed from the markdown file's folder. This uses headless Google Chrome or Chromium; set `MDEDIT_CHROME=/path/to/chrome` if it isn't found on the PATH. For the browser's own print dialog, press <kbd>Ctrl</kbd>+<kbd>P</kbd>; the print stylesheet prints only the rendered document.
69
+
70
+ ## Files
71
+
72
+ All code lives in `src/md_collab_editor/`:
73
+
74
+ - `server.py`: HTTP server (file API, folder browsing and root switching, change events, `/api/ask` → `claude -p`, `/api/pdf` → headless Chrome)
75
+ - `static/index.html`, `static/app.css`: layout and GitHub-style theme
76
+ - `static/render.js`: markdown → HTML, with source offsets on every block so preview selections map back to the source
77
+ - `static/app.js`: editor, sync, selection mapping, ask bar, suggestion cards and word diff
@@ -0,0 +1,47 @@
1
+ # Welcome
2
+
3
+ This editor renders markdown the way GitHub does, and it has Claude built in. Highlight any passage, in the source or in the preview, and ask Claude to rewrite it, tighten it, change its style or just comment on it. Every suggestion arrives as a card with a word-level diff that you can **accept**, **keep the original**, retry or refine.
4
+
5
+ ## Things to try
6
+
7
+ - [x] Open this file
8
+ - [ ] Highlight the paragraph above in the preview and choose *Tighten*
9
+ - [ ] Select some text and press <kbd>Ctrl</kbd>+<kbd>J</kbd> to type your own instruction
10
+ - [ ] Edit this file from a terminal and watch the change appear here
11
+
12
+ > [!NOTE]
13
+ > Files live on disk, so Claude Code in a terminal can edit them too. The editor picks up changes within a second.
14
+
15
+ > [!WARNING]
16
+ > If both of you edit at once, the editor asks which version to keep.
17
+
18
+ ## Formatting
19
+
20
+ | Feature | Syntax | Shown as |
21
+ | --- | --- | --- |
22
+ | Emphasis | `**bold**`, `_italic_`, `~~strike~~` | **bold**, _italic_, ~~strike~~ |
23
+ | Inline maths | `$E = mc^2$` | $E = mc^2$ |
24
+ | Link | `[GitHub](https://github.com)` | [GitHub](https://github.com) |
25
+
26
+ Display maths:
27
+
28
+ $$
29
+ \mathbf{Q} = \mathbf{k}_f - \mathbf{k}_i, \qquad |\mathbf{Q}| = \frac{4\pi}{\lambda}\sin\theta
30
+ $$
31
+
32
+ ```python
33
+ def bragg(d, wavelength):
34
+ """Return the Bragg angle in degrees."""
35
+ return math.degrees(math.asin(wavelength / (2 * d)))
36
+ ```
37
+
38
+ ```mermaid
39
+ flowchart LR
40
+ A[Highlight text] --> B[Ask Claude]
41
+ B --> C{Suggestion}
42
+ C -->|Accept| D[Document updated]
43
+ C -->|Keep original| E[No change]
44
+ C -->|Refine| B
45
+ ```
46
+
47
+ Footnote-style asides and HTML such as <sup>superscript</sup> also work.
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "md-collab-editor"
3
+ dynamic = ["version"]
4
+ description = "Local GitHub-style markdown editor shared between you and Claude Code"
5
+ readme = "README.md"
6
+ requires-python = ">=3.9"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Gareth Nisbet" }]
10
+ keywords = ["markdown", "editor", "claude", "claude-code", "gfm"]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Environment :: Web Environment",
14
+ "Intended Audience :: End Users/Desktop",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Topic :: Text Editors",
18
+ "Topic :: Text Processing :: Markup :: Markdown",
19
+ ]
20
+ dependencies = []
21
+
22
+ [project.scripts]
23
+ md-editor = "md_collab_editor.server:main"
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/garethnisbet/MDColaboritiveEditor"
27
+ Issues = "https://github.com/garethnisbet/MDColaboritiveEditor/issues"
28
+
29
+ [tool.hatch.version]
30
+ path = "src/md_collab_editor/__init__.py"
31
+
32
+ [build-system]
33
+ requires = ["hatchling>=1.27"]
34
+ build-backend = "hatchling.build"
@@ -0,0 +1,3 @@
1
+ """MD Collaborative Editor."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,3 @@
1
+ from .server import main
2
+
3
+ main()