clickmd 1.0.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.
- clickmd-1.0.0/.gitignore +180 -0
- clickmd-1.0.0/CHANGELOG.md +40 -0
- clickmd-1.0.0/LICENSE +21 -0
- clickmd-1.0.0/Makefile +89 -0
- clickmd-1.0.0/PKG-INFO +262 -0
- clickmd-1.0.0/README.md +219 -0
- clickmd-1.0.0/__init__.py +117 -0
- clickmd-1.0.0/decorators.py +59 -0
- clickmd-1.0.0/docs/API.md +209 -0
- clickmd-1.0.0/docs/CONTRIBUTING.md +164 -0
- clickmd-1.0.0/examples/basic.py +88 -0
- clickmd-1.0.0/examples/cli_app.py +141 -0
- clickmd-1.0.0/examples/custom_renderer.py +79 -0
- clickmd-1.0.0/examples/logger_usage.py +221 -0
- clickmd-1.0.0/examples/logging.py +82 -0
- clickmd-1.0.0/logger.py +302 -0
- clickmd-1.0.0/py.typed +0 -0
- clickmd-1.0.0/pyproject.toml +85 -0
- clickmd-1.0.0/renderer.py +300 -0
- clickmd-1.0.0/tests/__init__.py +1 -0
- clickmd-1.0.0/tests/test_core.py +70 -0
- clickmd-1.0.0/tests/test_decorators.py +78 -0
- clickmd-1.0.0/tests/test_logger.py +186 -0
- clickmd-1.0.0/tests/test_renderer.py +192 -0
clickmd-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
test-verify/
|
|
2
|
+
output_p3_verify2/
|
|
3
|
+
output_*/
|
|
4
|
+
output_p3_*/
|
|
5
|
+
output/
|
|
6
|
+
output*/
|
|
7
|
+
my-app/
|
|
8
|
+
my-crm/
|
|
9
|
+
express/
|
|
10
|
+
LegacyApp/
|
|
11
|
+
src-reproduction/
|
|
12
|
+
setup/
|
|
13
|
+
generated*/
|
|
14
|
+
generated2/
|
|
15
|
+
my-app
|
|
16
|
+
refactor-workspace/
|
|
17
|
+
*.egg-info
|
|
18
|
+
test-todo-prompt
|
|
19
|
+
test-lifecycle
|
|
20
|
+
test-lifecycle-*
|
|
21
|
+
test-prompt-*
|
|
22
|
+
.test-output
|
|
23
|
+
test-guide
|
|
24
|
+
test-docs
|
|
25
|
+
test-notes
|
|
26
|
+
test-verify
|
|
27
|
+
.test-output-e2e
|
|
28
|
+
target
|
|
29
|
+
.idea
|
|
30
|
+
venv
|
|
31
|
+
contracts/venv
|
|
32
|
+
pycontracts/venv
|
|
33
|
+
__pycache__/
|
|
34
|
+
*.pyc
|
|
35
|
+
generated/
|
|
36
|
+
reclapp.egg-info/
|
|
37
|
+
pycontracts.egg-info/
|
|
38
|
+
package-lock.json
|
|
39
|
+
# Logs
|
|
40
|
+
logs
|
|
41
|
+
*.log
|
|
42
|
+
npm-debug.log*
|
|
43
|
+
yarn-debug.log*
|
|
44
|
+
yarn-error.log*
|
|
45
|
+
lerna-debug.log*
|
|
46
|
+
|
|
47
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
48
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
49
|
+
|
|
50
|
+
# Runtime data
|
|
51
|
+
pids
|
|
52
|
+
*.pid
|
|
53
|
+
*.seed
|
|
54
|
+
*.pid.lock
|
|
55
|
+
|
|
56
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
57
|
+
lib-cov
|
|
58
|
+
|
|
59
|
+
# Coverage directory used by tools like istanbul
|
|
60
|
+
coverage
|
|
61
|
+
*.lcov
|
|
62
|
+
|
|
63
|
+
# nyc test coverage
|
|
64
|
+
.nyc_output
|
|
65
|
+
|
|
66
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
67
|
+
.grunt
|
|
68
|
+
|
|
69
|
+
# Bower dependency directory (https://bower.io/)
|
|
70
|
+
bower_components
|
|
71
|
+
|
|
72
|
+
# node-waf configuration
|
|
73
|
+
.lock-wscript
|
|
74
|
+
|
|
75
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
76
|
+
build/Release
|
|
77
|
+
|
|
78
|
+
# Dependency directories
|
|
79
|
+
node_modules/
|
|
80
|
+
jspm_packages/
|
|
81
|
+
|
|
82
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
83
|
+
web_modules/
|
|
84
|
+
|
|
85
|
+
# TypeScript cache
|
|
86
|
+
*.tsbuildinfo
|
|
87
|
+
|
|
88
|
+
# Optional npm cache directory
|
|
89
|
+
.npm
|
|
90
|
+
|
|
91
|
+
# Optional eslint cache
|
|
92
|
+
.eslintcache
|
|
93
|
+
|
|
94
|
+
# Optional stylelint cache
|
|
95
|
+
.stylelintcache
|
|
96
|
+
|
|
97
|
+
# Optional REPL history
|
|
98
|
+
.node_repl_history
|
|
99
|
+
|
|
100
|
+
# Output of 'npm pack'
|
|
101
|
+
*.tgz
|
|
102
|
+
|
|
103
|
+
# Yarn Integrity file
|
|
104
|
+
.yarn-integrity
|
|
105
|
+
|
|
106
|
+
# dotenv environment variable files
|
|
107
|
+
.env
|
|
108
|
+
.env.*
|
|
109
|
+
!.env.example
|
|
110
|
+
!.env.examples
|
|
111
|
+
!examples/**/.env.examples
|
|
112
|
+
!studio/.env.example
|
|
113
|
+
|
|
114
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
115
|
+
.cache
|
|
116
|
+
.parcel-cache
|
|
117
|
+
|
|
118
|
+
# Next.js build output
|
|
119
|
+
.next
|
|
120
|
+
out
|
|
121
|
+
|
|
122
|
+
# Nuxt.js build / generate output
|
|
123
|
+
.nuxt
|
|
124
|
+
dist
|
|
125
|
+
|
|
126
|
+
# Gatsby files
|
|
127
|
+
.cache/
|
|
128
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
129
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
130
|
+
# public
|
|
131
|
+
|
|
132
|
+
# vuepress build output
|
|
133
|
+
.vuepress/dist
|
|
134
|
+
|
|
135
|
+
# vuepress v2.x temp and cache directory
|
|
136
|
+
.temp
|
|
137
|
+
.cache
|
|
138
|
+
|
|
139
|
+
# Sveltekit cache directory
|
|
140
|
+
.svelte-kit/
|
|
141
|
+
|
|
142
|
+
# vitepress build output
|
|
143
|
+
**/.vitepress/dist
|
|
144
|
+
|
|
145
|
+
# vitepress cache directory
|
|
146
|
+
**/.vitepress/cache
|
|
147
|
+
|
|
148
|
+
# Docusaurus cache and generated files
|
|
149
|
+
.docusaurus
|
|
150
|
+
|
|
151
|
+
# Serverless directories
|
|
152
|
+
.serverless/
|
|
153
|
+
|
|
154
|
+
# FuseBox cache
|
|
155
|
+
.fusebox/
|
|
156
|
+
|
|
157
|
+
# DynamoDB Local files
|
|
158
|
+
.dynamodb/
|
|
159
|
+
|
|
160
|
+
# Firebase cache directory
|
|
161
|
+
.firebase/
|
|
162
|
+
|
|
163
|
+
# TernJS port file
|
|
164
|
+
.tern-port
|
|
165
|
+
|
|
166
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
167
|
+
.vscode-test
|
|
168
|
+
|
|
169
|
+
# yarn v3
|
|
170
|
+
.pnp.*
|
|
171
|
+
.yarn/*
|
|
172
|
+
!.yarn/patches
|
|
173
|
+
!.yarn/plugins
|
|
174
|
+
!.yarn/releases
|
|
175
|
+
!.yarn/sdks
|
|
176
|
+
!.yarn/versions
|
|
177
|
+
|
|
178
|
+
# Vite logs files
|
|
179
|
+
vite.config.js.timestamp-*
|
|
180
|
+
vite.config.ts.timestamp-*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2024-01-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release
|
|
12
|
+
- `md()` function for markdown rendering
|
|
13
|
+
- `echo()` smart function with auto-detection
|
|
14
|
+
- `MarkdownRenderer` class for advanced usage
|
|
15
|
+
- Syntax highlighting for:
|
|
16
|
+
- Python (keywords, decorators, strings, comments)
|
|
17
|
+
- TypeScript/JavaScript (keywords, strings, template literals)
|
|
18
|
+
- JSON (keys, values, numbers, booleans)
|
|
19
|
+
- YAML (keys, values, comments, lists)
|
|
20
|
+
- Bash/Shell (commands, comments)
|
|
21
|
+
- Markdown (headers, bold, links)
|
|
22
|
+
- Log (status emojis, errors, warnings)
|
|
23
|
+
- Click decorators re-export (optional dependency)
|
|
24
|
+
- Zero-dependency core functionality
|
|
25
|
+
- Full test suite
|
|
26
|
+
- Examples and documentation
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
- Works without Click installed
|
|
30
|
+
- Auto-detects TTY for color output
|
|
31
|
+
- Supports custom output streams
|
|
32
|
+
- Type hints (py.typed marker)
|
|
33
|
+
|
|
34
|
+
## [Unreleased]
|
|
35
|
+
|
|
36
|
+
### Planned
|
|
37
|
+
- Table rendering
|
|
38
|
+
- Progress bars
|
|
39
|
+
- Box/panel rendering
|
|
40
|
+
- More language highlighters
|
clickmd-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Reclapp Team
|
|
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.
|
clickmd-1.0.0/Makefile
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.PHONY: help install dev test lint format type-check clean build publish publish-test docs
|
|
2
|
+
|
|
3
|
+
PYTHON := python3
|
|
4
|
+
PIP := pip
|
|
5
|
+
PYTEST := pytest
|
|
6
|
+
RUFF := ruff
|
|
7
|
+
BLACK := black
|
|
8
|
+
MYPY := mypy
|
|
9
|
+
|
|
10
|
+
help:
|
|
11
|
+
@echo "clickmd - Markdown rendering for CLI applications"
|
|
12
|
+
@echo ""
|
|
13
|
+
@echo "Usage: make <target>"
|
|
14
|
+
@echo ""
|
|
15
|
+
@echo "Development:"
|
|
16
|
+
@echo " install Install package in development mode"
|
|
17
|
+
@echo " dev Install with all development dependencies"
|
|
18
|
+
@echo " test Run tests with pytest"
|
|
19
|
+
@echo " test-cov Run tests with coverage report"
|
|
20
|
+
@echo " lint Run ruff linter"
|
|
21
|
+
@echo " format Format code with black and ruff"
|
|
22
|
+
@echo " type-check Run mypy type checker"
|
|
23
|
+
@echo " check Run all checks (lint, type-check, test)"
|
|
24
|
+
@echo ""
|
|
25
|
+
@echo "Build & Publish:"
|
|
26
|
+
@echo " clean Remove build artifacts"
|
|
27
|
+
@echo " build Build package (sdist and wheel)"
|
|
28
|
+
@echo " publish-test Publish to TestPyPI"
|
|
29
|
+
@echo " publish Publish to PyPI"
|
|
30
|
+
@echo ""
|
|
31
|
+
@echo "Documentation:"
|
|
32
|
+
@echo " docs Generate documentation"
|
|
33
|
+
|
|
34
|
+
install:
|
|
35
|
+
$(PIP) install -e .
|
|
36
|
+
|
|
37
|
+
dev:
|
|
38
|
+
$(PIP) install -e ".[dev,click]"
|
|
39
|
+
|
|
40
|
+
test:
|
|
41
|
+
$(PYTEST) tests/ -v
|
|
42
|
+
|
|
43
|
+
test-cov:
|
|
44
|
+
$(PYTEST) tests/ -v --cov=. --cov-report=term-missing --cov-report=html
|
|
45
|
+
|
|
46
|
+
lint:
|
|
47
|
+
$(RUFF) check .
|
|
48
|
+
$(RUFF) format --check .
|
|
49
|
+
|
|
50
|
+
format:
|
|
51
|
+
$(RUFF) format .
|
|
52
|
+
$(RUFF) check --fix .
|
|
53
|
+
|
|
54
|
+
type-check:
|
|
55
|
+
$(MYPY) --ignore-missing-imports .
|
|
56
|
+
|
|
57
|
+
check: lint type-check test
|
|
58
|
+
|
|
59
|
+
clean:
|
|
60
|
+
rm -rf build/
|
|
61
|
+
rm -rf dist/
|
|
62
|
+
rm -rf *.egg-info/
|
|
63
|
+
rm -rf .pytest_cache/
|
|
64
|
+
rm -rf .mypy_cache/
|
|
65
|
+
rm -rf .ruff_cache/
|
|
66
|
+
rm -rf htmlcov/
|
|
67
|
+
rm -rf .coverage
|
|
68
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
69
|
+
find . -type f -name "*.pyc" -delete
|
|
70
|
+
|
|
71
|
+
build: clean
|
|
72
|
+
$(PYTHON) -m build
|
|
73
|
+
|
|
74
|
+
publish-test: build
|
|
75
|
+
$(PYTHON) -m twine upload --repository testpypi dist/*
|
|
76
|
+
|
|
77
|
+
publish: build
|
|
78
|
+
$(PYTHON) -m twine upload dist/*
|
|
79
|
+
|
|
80
|
+
docs:
|
|
81
|
+
@echo "Documentation is in README.md and docs/"
|
|
82
|
+
@echo "For API docs, consider using pdoc or sphinx"
|
|
83
|
+
|
|
84
|
+
# Development shortcuts
|
|
85
|
+
.PHONY: t l f c
|
|
86
|
+
t: test
|
|
87
|
+
l: lint
|
|
88
|
+
f: format
|
|
89
|
+
c: check
|
clickmd-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clickmd
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Markdown rendering for CLI applications with syntax highlighting
|
|
5
|
+
Project-URL: Homepage, https://github.com/wronai/clickmd
|
|
6
|
+
Project-URL: Documentation, https://github.com/wronai/clickmd#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/wronai/clickmd
|
|
8
|
+
Project-URL: Issues, https://github.com/wronai/clickmd/issues
|
|
9
|
+
Author-email: Reclapp Team <contact@reclapp.io>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ansi,cli,colors,markdown,syntax-highlighting,terminal
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Terminals
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: black>=23.0; extra == 'all'
|
|
29
|
+
Requires-Dist: click>=8.0; extra == 'all'
|
|
30
|
+
Requires-Dist: mypy>=1.0; extra == 'all'
|
|
31
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'all'
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == 'all'
|
|
33
|
+
Requires-Dist: ruff>=0.1.0; extra == 'all'
|
|
34
|
+
Provides-Extra: click
|
|
35
|
+
Requires-Dist: click>=8.0; extra == 'click'
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: black>=23.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# clickmd
|
|
45
|
+
|
|
46
|
+
[](https://badge.fury.io/py/clickmd)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](https://opensource.org/licenses/MIT)
|
|
49
|
+
[](https://github.com/wronai/clickmd/actions)
|
|
50
|
+
[](https://codecov.io/gh/wronai/clickmd)
|
|
51
|
+
|
|
52
|
+
**Markdown rendering for CLI applications with syntax highlighting.**
|
|
53
|
+
|
|
54
|
+
`clickmd` provides beautiful terminal output with:
|
|
55
|
+
- 🎨 **Syntax highlighting** for code blocks (Python, TypeScript, JSON, YAML, Bash, etc.)
|
|
56
|
+
- 📝 **Markdown rendering** with headers, bold, links, and more
|
|
57
|
+
- 🔧 **Zero dependencies** for core functionality
|
|
58
|
+
- 🖱️ **Optional Click integration** for CLI decorators
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Core package (no dependencies)
|
|
64
|
+
pip install clickmd
|
|
65
|
+
|
|
66
|
+
# With Click support
|
|
67
|
+
pip install clickmd[click]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
### Basic Usage (No Dependencies)
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from clickmd import md, echo
|
|
76
|
+
|
|
77
|
+
# Render markdown with syntax highlighting
|
|
78
|
+
md("""
|
|
79
|
+
# Hello World
|
|
80
|
+
|
|
81
|
+
This is **bold** and this is a [link](https://example.com).
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
def greet(name: str) -> str:
|
|
85
|
+
return f"Hello, {name}!"
|
|
86
|
+
```
|
|
87
|
+
""")
|
|
88
|
+
|
|
89
|
+
# Smart echo - auto-detects markdown
|
|
90
|
+
echo("## Status Update")
|
|
91
|
+
echo("Regular text without markdown")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### With Click Integration
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import clickmd as click
|
|
98
|
+
|
|
99
|
+
@click.group()
|
|
100
|
+
def cli():
|
|
101
|
+
"""My awesome CLI tool"""
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
@cli.command()
|
|
105
|
+
@click.option("--name", "-n", default="World")
|
|
106
|
+
def hello(name: str):
|
|
107
|
+
"""Say hello"""
|
|
108
|
+
click.md(f"""
|
|
109
|
+
## 👋 Hello, {name}!
|
|
110
|
+
|
|
111
|
+
Welcome to **clickmd** - making CLIs beautiful.
|
|
112
|
+
""")
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
cli()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Features
|
|
119
|
+
|
|
120
|
+
### Syntax Highlighting
|
|
121
|
+
|
|
122
|
+
`clickmd` provides syntax highlighting for multiple languages:
|
|
123
|
+
|
|
124
|
+
| Language | Extensions | Highlight Features |
|
|
125
|
+
|----------|------------|-------------------|
|
|
126
|
+
| Python | `.py` | Keywords, strings, comments, decorators |
|
|
127
|
+
| TypeScript/JavaScript | `.ts`, `.js` | Keywords, strings, template literals |
|
|
128
|
+
| JSON | `.json` | Keys, strings, numbers, booleans |
|
|
129
|
+
| YAML | `.yaml`, `.yml` | Keys, values, comments |
|
|
130
|
+
| Bash/Shell | `.sh`, `.bash` | Commands, comments |
|
|
131
|
+
| Markdown | `.md` | Headers, bold, links |
|
|
132
|
+
| Log | `.log` | Errors (red), warnings (yellow), success (green) |
|
|
133
|
+
|
|
134
|
+
### Markdown Elements
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from clickmd import md
|
|
138
|
+
|
|
139
|
+
md("""
|
|
140
|
+
# Heading 1
|
|
141
|
+
## Heading 2
|
|
142
|
+
### Heading 3
|
|
143
|
+
|
|
144
|
+
**Bold text** and regular text.
|
|
145
|
+
|
|
146
|
+
[Links](https://example.com) are supported.
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
# Code blocks with syntax highlighting
|
|
150
|
+
print("Hello, World!")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- List items
|
|
154
|
+
- Are rendered
|
|
155
|
+
- Correctly
|
|
156
|
+
""")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### MarkdownRenderer Class
|
|
160
|
+
|
|
161
|
+
For more control, use the `MarkdownRenderer` class directly:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from clickmd import MarkdownRenderer
|
|
165
|
+
import sys
|
|
166
|
+
|
|
167
|
+
renderer = MarkdownRenderer(use_colors=True, stream=sys.stdout)
|
|
168
|
+
renderer.heading(1, "My Title")
|
|
169
|
+
renderer.codeblock("python", 'print("Hello!")')
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Progress and Status Output
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from clickmd import md
|
|
176
|
+
|
|
177
|
+
# Log-style output with automatic coloring
|
|
178
|
+
md("""
|
|
179
|
+
```log
|
|
180
|
+
🚀 Starting process...
|
|
181
|
+
📦 Installing dependencies...
|
|
182
|
+
✅ Build successful!
|
|
183
|
+
⚠️ Warning: deprecated API
|
|
184
|
+
🛑 Error: connection failed
|
|
185
|
+
```
|
|
186
|
+
""")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## API Reference
|
|
190
|
+
|
|
191
|
+
### Core Functions
|
|
192
|
+
|
|
193
|
+
#### `md(text: str) -> None`
|
|
194
|
+
Render markdown text with syntax highlighting.
|
|
195
|
+
|
|
196
|
+
#### `echo(message, file=None, nl=True, err=False, color=None) -> None`
|
|
197
|
+
Smart echo that auto-detects markdown and renders it.
|
|
198
|
+
|
|
199
|
+
#### `render_markdown(text, text_lang="markdown", stream=None, use_colors=True) -> None`
|
|
200
|
+
Low-level markdown rendering function.
|
|
201
|
+
|
|
202
|
+
#### `get_renderer(stream=None, use_colors=True) -> MarkdownRenderer`
|
|
203
|
+
Get a `MarkdownRenderer` instance.
|
|
204
|
+
|
|
205
|
+
### Click Decorators (requires `click` package)
|
|
206
|
+
|
|
207
|
+
When `click` is installed, these decorators are available:
|
|
208
|
+
|
|
209
|
+
- `@clickmd.group()` - Create a command group
|
|
210
|
+
- `@clickmd.command()` - Create a command
|
|
211
|
+
- `@clickmd.option()` - Add an option
|
|
212
|
+
- `@clickmd.argument()` - Add an argument
|
|
213
|
+
- `@clickmd.pass_context` - Pass Click context
|
|
214
|
+
- `clickmd.Choice` - Choice type
|
|
215
|
+
- `clickmd.Path` - Path type
|
|
216
|
+
|
|
217
|
+
### Constants
|
|
218
|
+
|
|
219
|
+
- `CLICK_AVAILABLE: bool` - Whether Click is installed
|
|
220
|
+
|
|
221
|
+
## Examples
|
|
222
|
+
|
|
223
|
+
See the [examples/](examples/) directory for more usage examples:
|
|
224
|
+
|
|
225
|
+
- `examples/basic.py` - Basic markdown rendering
|
|
226
|
+
- `examples/cli_app.py` - Full CLI application with Click
|
|
227
|
+
- `examples/custom_renderer.py` - Custom renderer configuration
|
|
228
|
+
- `examples/logging.py` - Log-style colored output
|
|
229
|
+
|
|
230
|
+
## Development
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Clone the repository
|
|
234
|
+
git clone https://github.com/wronai/clickmd.git
|
|
235
|
+
cd clickmd
|
|
236
|
+
|
|
237
|
+
# Install development dependencies
|
|
238
|
+
pip install -e ".[dev]"
|
|
239
|
+
|
|
240
|
+
# Run tests
|
|
241
|
+
make test
|
|
242
|
+
|
|
243
|
+
# Run linter
|
|
244
|
+
make lint
|
|
245
|
+
|
|
246
|
+
# Format code
|
|
247
|
+
make format
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
253
|
+
|
|
254
|
+
## Contributing
|
|
255
|
+
|
|
256
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) first.
|
|
257
|
+
|
|
258
|
+
## Related Projects
|
|
259
|
+
|
|
260
|
+
- [Click](https://click.palletsprojects.com/) - Python CLI framework
|
|
261
|
+
- [Rich](https://github.com/Textualize/rich) - Rich text and beautiful formatting
|
|
262
|
+
- [Reclapp](https://github.com/wronai/contract) - Contract-first development platform
|