Metadata-Version: 2.5
Name: mdshelf
Version: 0.1.0
Summary: Browse a folder of Markdown files locally: sidebar, outline, highlights, margin comments, share and archive. No dependencies, works offline.
Author: Shamiq The Dev
License-Expression: MIT
License-File: LICENSE
License-File: licenses/inter-OFL.txt
License-File: licenses/jetbrains-mono-OFL.txt
License-File: licenses/marked-LICENSE.md
License-File: licenses/mermaid-LICENSE.txt
Keywords: docs,local,markdown,mermaid,viewer
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Documentation
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# mdshelf

Browse the Markdown files in any folder, locally. Point it at a repo or a docs folder and read it
like a small docs site, with the tools you want when you're reviewing, not just reading.

- Sidebar with filter and collapsible folders (collapse it fully, or drag its edge to resize)
- Page width you control: S / M / L / Full, or a slider
- "On this page" outline that follows your reading position
- Mermaid diagrams, tables, task lists, code blocks with a copy button
- Light, dark or automatic theme; adjustable text size
- **Highlights** in four colours, listed in the outline panel
- **Comments** shown in the right margin, level with the text they refer to
- **Share** selected text to WhatsApp, Teams, Email, or copy it as a Slack or Markdown quote
- **Archive / restore** a doc with confirmation (moves it into an `archived/` folder and back)

Python standard library only. Works offline: the Markdown renderer, Mermaid and fonts ship inside the
package. Nothing is uploaded anywhere.

## Install and run

```bash
pip install mdshelf        # or: pipx install mdshelf   /   uvx mdshelf
mdshelf                    # browse the current folder
mdshelf ~/path/to/project --port 9000
```

Python 3.9 or newer.

| Option | Meaning |
|---|---|
| `FOLDER` | folder to browse (default: current directory) |
| `-p, --port` | port on 127.0.0.1 (default 8780) |
| `--no-open` | don't open a browser tab |
| `--title` | name in the sidebar (default: the folder's name) |
| `--archive-dir` | where Archive moves files, relative to `FOLDER` (default `archived`) |
| `--exclude DIR` | extra directory name to skip everywhere (repeatable) |
| `--read-only` | disable Archive/Restore so the server never changes a file |

`.git`, `node_modules`, `.venv`, `dist`, `build`, `vendor` and cache folders are always skipped.

## Where your notes live

Highlights and comments are saved **in your browser** (localStorage), per folder and per file, not in
your repo. They survive reloads and edits to the Markdown, because each one is stored as the quoted
text plus a little context rather than a position. If the quoted text is deleted, the note stays in the
list marked "not found" so you can remove it. Clearing site data or using another browser or machine
starts you with no notes. Archive and restore carry a file's notes along.

## Archive

Archive moves a doc to `<folder>/archived/<same path>` and Restore moves it back, refusing if something
already exists at the destination. If the folder is under git, add `archived/` to `.gitignore` to keep
archived files out of commits (git will show them as deleted). Use `--read-only` to turn this off.

## Security model

- Binds to `127.0.0.1` only. There is no option to listen on other interfaces.
- Serves only `.md` files under the folder you pass, plus its bundled assets. Paths that escape the
  folder, or point into skipped folders, are refused.
- The only write is Archive/Restore. It accepts requests only from its own page: the `Host` and `Origin`
  headers must be local and a custom header must be present, which blocks DNS-rebinding and cross-site
  requests.
- Share opens a link to the chosen service (WhatsApp, Teams, mail) with the selected text in the URL, only
  when you press the button. Slack and Markdown copy to the clipboard. Check what you select before sharing.
- Rendered Markdown is shown as HTML without sanitising, so only browse folders you trust.

## Develop

```bash
git clone https://github.com/ShamiqTheDev/mdshelf && cd mdshelf
python -m venv .venv && . .venv/bin/activate
pip install -e .
python -m unittest discover -s tests -v
mdshelf tests --no-open      # or any folder
```

The viewer is one HTML file, `src/mdshelf/static/index.html`, with no build step. Bundled third-party
files and licences are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).

## Licence

MIT, see [LICENSE](LICENSE). Bundled fonts are under the SIL Open Font License 1.1; see `licenses/`.
