mdsyntax 0.1.0__tar.gz → 0.2.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.
- mdsyntax-0.2.0/CHANGELOG.md +44 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/CONTRIBUTING.md +1 -1
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/LICENSE +1 -1
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/PKG-INFO +62 -7
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/README.md +57 -2
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/pyproject.toml +5 -5
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/src/mdsyntax/__init__.py +12 -1
- mdsyntax-0.2.0/src/mdsyntax/renderer.py +637 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/tests/test_renderer.py +111 -1
- mdsyntax-0.1.0/CHANGELOG.md +0 -23
- mdsyntax-0.1.0/src/mdsyntax/renderer.py +0 -368
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/.github/workflows/ci.yml +0 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/.github/workflows/release.yml +0 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/.gitignore +0 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/src/mdsyntax/cli.py +0 -0
- {mdsyntax-0.1.0 → mdsyntax-0.2.0}/src/mdsyntax/py.typed +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
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.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.0] - 2025-XX-XX
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- New `Style` class for styling arbitrary text
|
|
15
|
+
- Static methods: `Style.bold_text()`, `Style.italic_text()`, `Style.color()`, etc.
|
|
16
|
+
- Chainable API: `style("text").bold().italic().fg("red")`
|
|
17
|
+
- RGB color support via `Style.color(text, fg=(255, 0, 0))`
|
|
18
|
+
- `Ansi` class now exported for direct access to ANSI codes
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Switched from `colorama.init(autoreset=True)` to `colorama.just_fix_windows_console()` for better compatibility
|
|
23
|
+
- Code blocks now expand width to fit long lines instead of truncating
|
|
24
|
+
- Use targeted ANSI resets instead of full reset for better style preservation
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Inline code in blockquotes no longer breaks italic styling for subsequent text
|
|
29
|
+
- Code block width now properly constrains content
|
|
30
|
+
|
|
31
|
+
## [0.1.0] - 2025-01-XX
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Initial release
|
|
36
|
+
- Markdown rendering with ANSI formatting
|
|
37
|
+
- Syntax highlighting for code blocks (powered by Pygments)
|
|
38
|
+
- Support for headers, bold, italic, strikethrough, inline code
|
|
39
|
+
- Support for lists (ordered, unordered, task lists)
|
|
40
|
+
- Support for blockquotes and horizontal rules
|
|
41
|
+
- Support for links
|
|
42
|
+
- CLI tool (`mdsyntax`)
|
|
43
|
+
- Auto-detection of 24-bit true color support
|
|
44
|
+
- Configurable code block styling and width
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdsyntax
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Render markdown with syntax highlighting in the terminal
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL: Repository, https://github.com/
|
|
7
|
-
Project-URL: Issues, https://github.com/
|
|
8
|
-
Author-email:
|
|
5
|
+
Project-URL: Homepage, https://github.com/yourusername/mdsyntax
|
|
6
|
+
Project-URL: Repository, https://github.com/yourusername/mdsyntax
|
|
7
|
+
Project-URL: Issues, https://github.com/yourusername/mdsyntax/issues
|
|
8
|
+
Author-email: Your Name <you@example.com>
|
|
9
9
|
License-Expression: MIT
|
|
10
10
|
License-File: LICENSE
|
|
11
11
|
Keywords: ansi,cli,console,markdown,syntax-highlighting,terminal
|
|
@@ -86,6 +86,35 @@ mdsyntax --style dracula document.md
|
|
|
86
86
|
mdsyntax --list-styles
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
## Styling API
|
|
90
|
+
|
|
91
|
+
Style arbitrary text without markdown:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from mdsyntax import Style, style
|
|
95
|
+
|
|
96
|
+
# Static methods
|
|
97
|
+
print(Style.bold_text("important"))
|
|
98
|
+
print(Style.italic_text("emphasis"))
|
|
99
|
+
print(Style.color("warning", fg="red"))
|
|
100
|
+
print(Style.color("highlight", fg="white", bg="blue"))
|
|
101
|
+
|
|
102
|
+
# Chainable API
|
|
103
|
+
print(style("hello").bold().italic())
|
|
104
|
+
print(style("fancy").fg("cyan").underline())
|
|
105
|
+
print(style("rgb").fg((255, 100, 50))) # RGB colors
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Available styles:
|
|
109
|
+
- `bold()` / `Style.bold_text()`
|
|
110
|
+
- `dim()` / `Style.dim_text()`
|
|
111
|
+
- `italic()` / `Style.italic_text()`
|
|
112
|
+
- `underline()` / `Style.underline_text()`
|
|
113
|
+
- `strikethrough()` / `Style.strike_text()`
|
|
114
|
+
- `fg(color)` / `bg(color)` - named colors or RGB tuples
|
|
115
|
+
|
|
116
|
+
Named colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
|
117
|
+
|
|
89
118
|
## Features
|
|
90
119
|
|
|
91
120
|
- Headers (h1-h6) with color coding
|
|
@@ -114,7 +143,7 @@ Any [Pygments style](https://pygments.org/styles/) is supported. Popular options
|
|
|
114
143
|
|
|
115
144
|
### True Color
|
|
116
145
|
|
|
117
|
-
By default,
|
|
146
|
+
By default, mdsyntax auto-detects 24-bit color support via the `COLORTERM` environment variable. You can override this:
|
|
118
147
|
|
|
119
148
|
```python
|
|
120
149
|
# Force 256-color mode
|
|
@@ -166,11 +195,37 @@ print(hl.highlight("print('hello')", "python"))
|
|
|
166
195
|
print(SyntaxHighlighter.available_styles())
|
|
167
196
|
```
|
|
168
197
|
|
|
198
|
+
### `Style` / `style()`
|
|
199
|
+
|
|
200
|
+
Style text without markdown parsing:
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from mdsyntax import Style, style
|
|
204
|
+
|
|
205
|
+
# Static (returns string directly)
|
|
206
|
+
Style.bold_text("text")
|
|
207
|
+
Style.color("text", fg="red", bg="white")
|
|
208
|
+
|
|
209
|
+
# Chainable (call str() or print directly)
|
|
210
|
+
style("text").bold().fg("blue")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### `Ansi`
|
|
214
|
+
|
|
215
|
+
Direct access to ANSI escape codes:
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
from mdsyntax import Ansi
|
|
219
|
+
|
|
220
|
+
print(f"{Ansi.BOLD}Bold{Ansi.BOLD_OFF}")
|
|
221
|
+
print(f"{Ansi.FG_RED}Red{Ansi.FG_DEFAULT}")
|
|
222
|
+
print(f"{Ansi.rgb_fg(255, 100, 50)}RGB{Ansi.FG_DEFAULT}")
|
|
223
|
+
```
|
|
224
|
+
|
|
169
225
|
## License
|
|
170
226
|
|
|
171
227
|
MIT
|
|
172
228
|
|
|
173
|
-
|
|
174
229
|
## Contributing
|
|
175
230
|
|
|
176
231
|
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
@@ -52,6 +52,35 @@ mdsyntax --style dracula document.md
|
|
|
52
52
|
mdsyntax --list-styles
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
## Styling API
|
|
56
|
+
|
|
57
|
+
Style arbitrary text without markdown:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from mdsyntax import Style, style
|
|
61
|
+
|
|
62
|
+
# Static methods
|
|
63
|
+
print(Style.bold_text("important"))
|
|
64
|
+
print(Style.italic_text("emphasis"))
|
|
65
|
+
print(Style.color("warning", fg="red"))
|
|
66
|
+
print(Style.color("highlight", fg="white", bg="blue"))
|
|
67
|
+
|
|
68
|
+
# Chainable API
|
|
69
|
+
print(style("hello").bold().italic())
|
|
70
|
+
print(style("fancy").fg("cyan").underline())
|
|
71
|
+
print(style("rgb").fg((255, 100, 50))) # RGB colors
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Available styles:
|
|
75
|
+
- `bold()` / `Style.bold_text()`
|
|
76
|
+
- `dim()` / `Style.dim_text()`
|
|
77
|
+
- `italic()` / `Style.italic_text()`
|
|
78
|
+
- `underline()` / `Style.underline_text()`
|
|
79
|
+
- `strikethrough()` / `Style.strike_text()`
|
|
80
|
+
- `fg(color)` / `bg(color)` - named colors or RGB tuples
|
|
81
|
+
|
|
82
|
+
Named colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
|
83
|
+
|
|
55
84
|
## Features
|
|
56
85
|
|
|
57
86
|
- Headers (h1-h6) with color coding
|
|
@@ -80,7 +109,7 @@ Any [Pygments style](https://pygments.org/styles/) is supported. Popular options
|
|
|
80
109
|
|
|
81
110
|
### True Color
|
|
82
111
|
|
|
83
|
-
By default,
|
|
112
|
+
By default, mdsyntax auto-detects 24-bit color support via the `COLORTERM` environment variable. You can override this:
|
|
84
113
|
|
|
85
114
|
```python
|
|
86
115
|
# Force 256-color mode
|
|
@@ -132,11 +161,37 @@ print(hl.highlight("print('hello')", "python"))
|
|
|
132
161
|
print(SyntaxHighlighter.available_styles())
|
|
133
162
|
```
|
|
134
163
|
|
|
164
|
+
### `Style` / `style()`
|
|
165
|
+
|
|
166
|
+
Style text without markdown parsing:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from mdsyntax import Style, style
|
|
170
|
+
|
|
171
|
+
# Static (returns string directly)
|
|
172
|
+
Style.bold_text("text")
|
|
173
|
+
Style.color("text", fg="red", bg="white")
|
|
174
|
+
|
|
175
|
+
# Chainable (call str() or print directly)
|
|
176
|
+
style("text").bold().fg("blue")
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `Ansi`
|
|
180
|
+
|
|
181
|
+
Direct access to ANSI escape codes:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from mdsyntax import Ansi
|
|
185
|
+
|
|
186
|
+
print(f"{Ansi.BOLD}Bold{Ansi.BOLD_OFF}")
|
|
187
|
+
print(f"{Ansi.FG_RED}Red{Ansi.FG_DEFAULT}")
|
|
188
|
+
print(f"{Ansi.rgb_fg(255, 100, 50)}RGB{Ansi.FG_DEFAULT}")
|
|
189
|
+
```
|
|
190
|
+
|
|
135
191
|
## License
|
|
136
192
|
|
|
137
193
|
MIT
|
|
138
194
|
|
|
139
|
-
|
|
140
195
|
## Contributing
|
|
141
196
|
|
|
142
197
|
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
@@ -4,13 +4,13 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mdsyntax"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "Render markdown with syntax highlighting in the terminal"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
requires-python = ">=3.10"
|
|
12
12
|
authors = [
|
|
13
|
-
{ name = "
|
|
13
|
+
{ name = "Your Name", email = "you@example.com" }
|
|
14
14
|
]
|
|
15
15
|
keywords = [
|
|
16
16
|
"markdown",
|
|
@@ -49,9 +49,9 @@ dev = [
|
|
|
49
49
|
]
|
|
50
50
|
|
|
51
51
|
[project.urls]
|
|
52
|
-
Homepage = "https://github.com/
|
|
53
|
-
Repository = "https://github.com/
|
|
54
|
-
Issues = "https://github.com/
|
|
52
|
+
Homepage = "https://github.com/yourusername/mdsyntax"
|
|
53
|
+
Repository = "https://github.com/yourusername/mdsyntax"
|
|
54
|
+
Issues = "https://github.com/yourusername/mdsyntax/issues"
|
|
55
55
|
|
|
56
56
|
[project.scripts]
|
|
57
57
|
mdsyntax = "mdsyntax.cli:main"
|
|
@@ -5,22 +5,33 @@ Usage:
|
|
|
5
5
|
>>> from mdsyntax import md_print, md_render
|
|
6
6
|
>>> md_print("# Hello **world**")
|
|
7
7
|
>>> output = md_render("Some `code` here")
|
|
8
|
+
|
|
9
|
+
# Styling API
|
|
10
|
+
>>> from mdsyntax import Style, style
|
|
11
|
+
>>> print(Style.bold_text("important"))
|
|
12
|
+
>>> print(style("hello").italic().fg("red"))
|
|
8
13
|
"""
|
|
9
14
|
|
|
10
15
|
from mdsyntax.renderer import (
|
|
11
16
|
LANG_ALIASES,
|
|
17
|
+
Ansi,
|
|
12
18
|
MarkdownRenderer,
|
|
19
|
+
Style,
|
|
13
20
|
SyntaxHighlighter,
|
|
14
21
|
md_print,
|
|
15
22
|
md_render,
|
|
23
|
+
style,
|
|
16
24
|
)
|
|
17
25
|
|
|
18
|
-
__version__ = "0.
|
|
26
|
+
__version__ = "0.2.0"
|
|
19
27
|
__all__ = [
|
|
20
28
|
"md_print",
|
|
21
29
|
"md_render",
|
|
22
30
|
"MarkdownRenderer",
|
|
23
31
|
"SyntaxHighlighter",
|
|
24
32
|
"LANG_ALIASES",
|
|
33
|
+
"Style",
|
|
34
|
+
"style",
|
|
35
|
+
"Ansi",
|
|
25
36
|
"__version__",
|
|
26
37
|
]
|