mdshelf 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.
- mdshelf-0.1.0/.gitignore +9 -0
- mdshelf-0.1.0/CHANGELOG.md +7 -0
- mdshelf-0.1.0/LICENSE +21 -0
- mdshelf-0.1.0/PKG-INFO +103 -0
- mdshelf-0.1.0/README.md +82 -0
- mdshelf-0.1.0/licenses/inter-OFL.txt +93 -0
- mdshelf-0.1.0/licenses/jetbrains-mono-OFL.txt +93 -0
- mdshelf-0.1.0/licenses/marked-LICENSE.md +44 -0
- mdshelf-0.1.0/licenses/mermaid-LICENSE.txt +21 -0
- mdshelf-0.1.0/pyproject.toml +39 -0
- mdshelf-0.1.0/src/mdshelf/__init__.py +3 -0
- mdshelf-0.1.0/src/mdshelf/__main__.py +3 -0
- mdshelf-0.1.0/src/mdshelf/cli.py +75 -0
- mdshelf-0.1.0/src/mdshelf/server.py +237 -0
- mdshelf-0.1.0/src/mdshelf/static/index.html +1013 -0
- mdshelf-0.1.0/src/mdshelf/static/vendor/inter-latin-wght-normal.woff2 +0 -0
- mdshelf-0.1.0/src/mdshelf/static/vendor/jetbrains-mono-latin-wght-normal.woff2 +0 -0
- mdshelf-0.1.0/src/mdshelf/static/vendor/marked-12.0.2.min.js +6 -0
- mdshelf-0.1.0/src/mdshelf/static/vendor/mermaid-10.9.1.min.js +2029 -0
- mdshelf-0.1.0/tests/test_server.py +112 -0
mdshelf-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
First release: sidebar with filter and collapsible folders, outline, adjustable page width, light and
|
|
6
|
+
dark themes, Mermaid diagrams, text highlights, margin comments, share (WhatsApp, Teams, Slack, email,
|
|
7
|
+
Markdown), and archive/restore with confirmation. Python standard library only.
|
mdshelf-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shamiq The Dev
|
|
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.
|
mdshelf-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mdshelf
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Browse a folder of Markdown files locally: sidebar, outline, highlights, margin comments, share and archive. No dependencies, works offline.
|
|
5
|
+
Author: Shamiq The Dev
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: licenses/inter-OFL.txt
|
|
9
|
+
License-File: licenses/jetbrains-mono-OFL.txt
|
|
10
|
+
License-File: licenses/marked-LICENSE.md
|
|
11
|
+
License-File: licenses/mermaid-LICENSE.txt
|
|
12
|
+
Keywords: docs,local,markdown,mermaid,viewer
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Web Environment
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Documentation
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# mdshelf
|
|
23
|
+
|
|
24
|
+
Browse the Markdown files in any folder, locally. Point it at a repo or a docs folder and read it
|
|
25
|
+
like a small docs site, with the tools you want when you're reviewing, not just reading.
|
|
26
|
+
|
|
27
|
+
- Sidebar with filter and collapsible folders (collapse it fully, or drag its edge to resize)
|
|
28
|
+
- Page width you control: S / M / L / Full, or a slider
|
|
29
|
+
- "On this page" outline that follows your reading position
|
|
30
|
+
- Mermaid diagrams, tables, task lists, code blocks with a copy button
|
|
31
|
+
- Light, dark or automatic theme; adjustable text size
|
|
32
|
+
- **Highlights** in four colours, listed in the outline panel
|
|
33
|
+
- **Comments** shown in the right margin, level with the text they refer to
|
|
34
|
+
- **Share** selected text to WhatsApp, Teams, Email, or copy it as a Slack or Markdown quote
|
|
35
|
+
- **Archive / restore** a doc with confirmation (moves it into an `archived/` folder and back)
|
|
36
|
+
|
|
37
|
+
Python standard library only. Works offline: the Markdown renderer, Mermaid and fonts ship inside the
|
|
38
|
+
package. Nothing is uploaded anywhere.
|
|
39
|
+
|
|
40
|
+
## Install and run
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install mdshelf # or: pipx install mdshelf / uvx mdshelf
|
|
44
|
+
mdshelf # browse the current folder
|
|
45
|
+
mdshelf ~/path/to/project --port 9000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Python 3.9 or newer.
|
|
49
|
+
|
|
50
|
+
| Option | Meaning |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `FOLDER` | folder to browse (default: current directory) |
|
|
53
|
+
| `-p, --port` | port on 127.0.0.1 (default 8780) |
|
|
54
|
+
| `--no-open` | don't open a browser tab |
|
|
55
|
+
| `--title` | name in the sidebar (default: the folder's name) |
|
|
56
|
+
| `--archive-dir` | where Archive moves files, relative to `FOLDER` (default `archived`) |
|
|
57
|
+
| `--exclude DIR` | extra directory name to skip everywhere (repeatable) |
|
|
58
|
+
| `--read-only` | disable Archive/Restore so the server never changes a file |
|
|
59
|
+
|
|
60
|
+
`.git`, `node_modules`, `.venv`, `dist`, `build`, `vendor` and cache folders are always skipped.
|
|
61
|
+
|
|
62
|
+
## Where your notes live
|
|
63
|
+
|
|
64
|
+
Highlights and comments are saved **in your browser** (localStorage), per folder and per file, not in
|
|
65
|
+
your repo. They survive reloads and edits to the Markdown, because each one is stored as the quoted
|
|
66
|
+
text plus a little context rather than a position. If the quoted text is deleted, the note stays in the
|
|
67
|
+
list marked "not found" so you can remove it. Clearing site data or using another browser or machine
|
|
68
|
+
starts you with no notes. Archive and restore carry a file's notes along.
|
|
69
|
+
|
|
70
|
+
## Archive
|
|
71
|
+
|
|
72
|
+
Archive moves a doc to `<folder>/archived/<same path>` and Restore moves it back, refusing if something
|
|
73
|
+
already exists at the destination. If the folder is under git, add `archived/` to `.gitignore` to keep
|
|
74
|
+
archived files out of commits (git will show them as deleted). Use `--read-only` to turn this off.
|
|
75
|
+
|
|
76
|
+
## Security model
|
|
77
|
+
|
|
78
|
+
- Binds to `127.0.0.1` only. There is no option to listen on other interfaces.
|
|
79
|
+
- Serves only `.md` files under the folder you pass, plus its bundled assets. Paths that escape the
|
|
80
|
+
folder, or point into skipped folders, are refused.
|
|
81
|
+
- The only write is Archive/Restore. It accepts requests only from its own page: the `Host` and `Origin`
|
|
82
|
+
headers must be local and a custom header must be present, which blocks DNS-rebinding and cross-site
|
|
83
|
+
requests.
|
|
84
|
+
- Share opens a link to the chosen service (WhatsApp, Teams, mail) with the selected text in the URL, only
|
|
85
|
+
when you press the button. Slack and Markdown copy to the clipboard. Check what you select before sharing.
|
|
86
|
+
- Rendered Markdown is shown as HTML without sanitising, so only browse folders you trust.
|
|
87
|
+
|
|
88
|
+
## Develop
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
git clone https://github.com/ShamiqTheDev/mdshelf && cd mdshelf
|
|
92
|
+
python -m venv .venv && . .venv/bin/activate
|
|
93
|
+
pip install -e .
|
|
94
|
+
python -m unittest discover -s tests -v
|
|
95
|
+
mdshelf tests --no-open # or any folder
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The viewer is one HTML file, `src/mdshelf/static/index.html`, with no build step. Bundled third-party
|
|
99
|
+
files and licences are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
100
|
+
|
|
101
|
+
## Licence
|
|
102
|
+
|
|
103
|
+
MIT, see [LICENSE](LICENSE). Bundled fonts are under the SIL Open Font License 1.1; see `licenses/`.
|
mdshelf-0.1.0/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# mdshelf
|
|
2
|
+
|
|
3
|
+
Browse the Markdown files in any folder, locally. Point it at a repo or a docs folder and read it
|
|
4
|
+
like a small docs site, with the tools you want when you're reviewing, not just reading.
|
|
5
|
+
|
|
6
|
+
- Sidebar with filter and collapsible folders (collapse it fully, or drag its edge to resize)
|
|
7
|
+
- Page width you control: S / M / L / Full, or a slider
|
|
8
|
+
- "On this page" outline that follows your reading position
|
|
9
|
+
- Mermaid diagrams, tables, task lists, code blocks with a copy button
|
|
10
|
+
- Light, dark or automatic theme; adjustable text size
|
|
11
|
+
- **Highlights** in four colours, listed in the outline panel
|
|
12
|
+
- **Comments** shown in the right margin, level with the text they refer to
|
|
13
|
+
- **Share** selected text to WhatsApp, Teams, Email, or copy it as a Slack or Markdown quote
|
|
14
|
+
- **Archive / restore** a doc with confirmation (moves it into an `archived/` folder and back)
|
|
15
|
+
|
|
16
|
+
Python standard library only. Works offline: the Markdown renderer, Mermaid and fonts ship inside the
|
|
17
|
+
package. Nothing is uploaded anywhere.
|
|
18
|
+
|
|
19
|
+
## Install and run
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install mdshelf # or: pipx install mdshelf / uvx mdshelf
|
|
23
|
+
mdshelf # browse the current folder
|
|
24
|
+
mdshelf ~/path/to/project --port 9000
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Python 3.9 or newer.
|
|
28
|
+
|
|
29
|
+
| Option | Meaning |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `FOLDER` | folder to browse (default: current directory) |
|
|
32
|
+
| `-p, --port` | port on 127.0.0.1 (default 8780) |
|
|
33
|
+
| `--no-open` | don't open a browser tab |
|
|
34
|
+
| `--title` | name in the sidebar (default: the folder's name) |
|
|
35
|
+
| `--archive-dir` | where Archive moves files, relative to `FOLDER` (default `archived`) |
|
|
36
|
+
| `--exclude DIR` | extra directory name to skip everywhere (repeatable) |
|
|
37
|
+
| `--read-only` | disable Archive/Restore so the server never changes a file |
|
|
38
|
+
|
|
39
|
+
`.git`, `node_modules`, `.venv`, `dist`, `build`, `vendor` and cache folders are always skipped.
|
|
40
|
+
|
|
41
|
+
## Where your notes live
|
|
42
|
+
|
|
43
|
+
Highlights and comments are saved **in your browser** (localStorage), per folder and per file, not in
|
|
44
|
+
your repo. They survive reloads and edits to the Markdown, because each one is stored as the quoted
|
|
45
|
+
text plus a little context rather than a position. If the quoted text is deleted, the note stays in the
|
|
46
|
+
list marked "not found" so you can remove it. Clearing site data or using another browser or machine
|
|
47
|
+
starts you with no notes. Archive and restore carry a file's notes along.
|
|
48
|
+
|
|
49
|
+
## Archive
|
|
50
|
+
|
|
51
|
+
Archive moves a doc to `<folder>/archived/<same path>` and Restore moves it back, refusing if something
|
|
52
|
+
already exists at the destination. If the folder is under git, add `archived/` to `.gitignore` to keep
|
|
53
|
+
archived files out of commits (git will show them as deleted). Use `--read-only` to turn this off.
|
|
54
|
+
|
|
55
|
+
## Security model
|
|
56
|
+
|
|
57
|
+
- Binds to `127.0.0.1` only. There is no option to listen on other interfaces.
|
|
58
|
+
- Serves only `.md` files under the folder you pass, plus its bundled assets. Paths that escape the
|
|
59
|
+
folder, or point into skipped folders, are refused.
|
|
60
|
+
- The only write is Archive/Restore. It accepts requests only from its own page: the `Host` and `Origin`
|
|
61
|
+
headers must be local and a custom header must be present, which blocks DNS-rebinding and cross-site
|
|
62
|
+
requests.
|
|
63
|
+
- Share opens a link to the chosen service (WhatsApp, Teams, mail) with the selected text in the URL, only
|
|
64
|
+
when you press the button. Slack and Markdown copy to the clipboard. Check what you select before sharing.
|
|
65
|
+
- Rendered Markdown is shown as HTML without sanitising, so only browse folders you trust.
|
|
66
|
+
|
|
67
|
+
## Develop
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/ShamiqTheDev/mdshelf && cd mdshelf
|
|
71
|
+
python -m venv .venv && . .venv/bin/activate
|
|
72
|
+
pip install -e .
|
|
73
|
+
python -m unittest discover -s tests -v
|
|
74
|
+
mdshelf tests --no-open # or any folder
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The viewer is one HTML file, `src/mdshelf/static/index.html`, with no build step. Bundled third-party
|
|
78
|
+
files and licences are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
79
|
+
|
|
80
|
+
## Licence
|
|
81
|
+
|
|
82
|
+
MIT, see [LICENSE](LICENSE). Bundled fonts are under the SIL Open Font License 1.1; see `licenses/`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# License information
|
|
2
|
+
|
|
3
|
+
## Contribution License Agreement
|
|
4
|
+
|
|
5
|
+
If you contribute code to this project, you are implicitly allowing your code
|
|
6
|
+
to be distributed under the MIT license. You are also implicitly verifying that
|
|
7
|
+
all code is your original work. `</legalese>`
|
|
8
|
+
|
|
9
|
+
## Marked
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
|
12
|
+
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in
|
|
22
|
+
all copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
## Markdown
|
|
33
|
+
|
|
34
|
+
Copyright © 2004, John Gruber
|
|
35
|
+
http://daringfireball.net/
|
|
36
|
+
All rights reserved.
|
|
37
|
+
|
|
38
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
39
|
+
|
|
40
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
41
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
42
|
+
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
43
|
+
|
|
44
|
+
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 - 2022 Knut Sveidqvist
|
|
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,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mdshelf"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Browse a folder of Markdown files locally: sidebar, outline, highlights, margin comments, share and archive. No dependencies, works offline."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [{ name = "Shamiq The Dev" }]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE", "licenses/*"]
|
|
14
|
+
keywords = ["markdown", "viewer", "docs", "mermaid", "local"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Web Environment",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Topic :: Documentation",
|
|
21
|
+
"Topic :: Text Processing :: Markup :: Markdown",
|
|
22
|
+
]
|
|
23
|
+
dependencies = []
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
mdshelf = "mdshelf.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.version]
|
|
29
|
+
path = "src/mdshelf/__init__.py"
|
|
30
|
+
|
|
31
|
+
[tool.hatch.build.targets.wheel]
|
|
32
|
+
packages = ["src/mdshelf"]
|
|
33
|
+
|
|
34
|
+
[tool.hatch.build.targets.sdist]
|
|
35
|
+
include = ["src", "tests", "licenses", "LICENSE", "README.md", "CHANGELOG.md"]
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
line-length = 100
|
|
39
|
+
target-version = "py39"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Command line entry point: `mdshelf [FOLDER]`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import contextlib
|
|
7
|
+
import errno
|
|
8
|
+
import sys
|
|
9
|
+
import webbrowser
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from . import __version__
|
|
13
|
+
from .server import DEFAULT_EXCLUDES, Config, make_server
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main(argv: list[str] | None = None) -> None:
|
|
17
|
+
p = argparse.ArgumentParser(
|
|
18
|
+
prog="mdshelf",
|
|
19
|
+
description="Browse the Markdown files in a folder: sidebar, outline, highlights, "
|
|
20
|
+
"margin comments, share and archive. Local only; nothing leaves your machine.",
|
|
21
|
+
)
|
|
22
|
+
p.add_argument("folder", nargs="?", default=".", help="folder to browse (default: current)")
|
|
23
|
+
p.add_argument("-p", "--port", type=int, default=8780, help="port on 127.0.0.1 (default 8780)")
|
|
24
|
+
p.add_argument("--no-open", action="store_true", help="don't open a browser tab")
|
|
25
|
+
p.add_argument("--title", default="", help="name shown in the sidebar (default: folder name)")
|
|
26
|
+
p.add_argument(
|
|
27
|
+
"--archive-dir",
|
|
28
|
+
default="archived",
|
|
29
|
+
help="folder, relative to FOLDER, that Archive moves files into (default: archived)",
|
|
30
|
+
)
|
|
31
|
+
p.add_argument(
|
|
32
|
+
"--exclude",
|
|
33
|
+
action="append",
|
|
34
|
+
default=[],
|
|
35
|
+
metavar="DIR",
|
|
36
|
+
help="extra directory name to skip anywhere (repeatable)",
|
|
37
|
+
)
|
|
38
|
+
p.add_argument(
|
|
39
|
+
"--read-only",
|
|
40
|
+
action="store_true",
|
|
41
|
+
help="disable Archive/Restore, so the server never changes any file",
|
|
42
|
+
)
|
|
43
|
+
p.add_argument("--version", action="version", version=f"mdshelf {__version__}")
|
|
44
|
+
args = p.parse_args(argv)
|
|
45
|
+
|
|
46
|
+
root = Path(args.folder).expanduser()
|
|
47
|
+
if not root.is_dir():
|
|
48
|
+
sys.exit(f"mdshelf: {root} is not a folder.")
|
|
49
|
+
archive = args.archive_dir.strip("/")
|
|
50
|
+
if not archive or ".." in Path(archive).parts or Path(archive).is_absolute():
|
|
51
|
+
sys.exit("mdshelf: --archive-dir must be a plain folder name inside FOLDER.")
|
|
52
|
+
|
|
53
|
+
cfg = Config(
|
|
54
|
+
root=root,
|
|
55
|
+
title=args.title,
|
|
56
|
+
archive_name=archive,
|
|
57
|
+
exclude=DEFAULT_EXCLUDES | frozenset(args.exclude),
|
|
58
|
+
read_only=args.read_only,
|
|
59
|
+
)
|
|
60
|
+
try:
|
|
61
|
+
server = make_server(cfg, args.port)
|
|
62
|
+
except OSError as exc:
|
|
63
|
+
if exc.errno != errno.EADDRINUSE:
|
|
64
|
+
raise
|
|
65
|
+
sys.exit(
|
|
66
|
+
f"mdshelf: port {args.port} is already in use (maybe another mdshelf).\n"
|
|
67
|
+
f" Use another port: mdshelf --port {args.port + 1}"
|
|
68
|
+
)
|
|
69
|
+
url = f"http://127.0.0.1:{args.port}/"
|
|
70
|
+
print(f"mdshelf: serving {cfg.root}\n {url} (Ctrl+C to stop)")
|
|
71
|
+
if not args.no_open:
|
|
72
|
+
webbrowser.open(url)
|
|
73
|
+
with contextlib.suppress(KeyboardInterrupt):
|
|
74
|
+
server.serve_forever()
|
|
75
|
+
server.server_close()
|