🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

zig-codeblocks

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zig-codeblocks - pypi Package Compare versions

Comparing version
0.2.1
to
0.2.2
.coverage

Sorry, the diff of this file is not supported yet

+5
import zig_codeblocks as zc
print(
zc.highlight_zig_code("a", {"identifiers": zc.Style(zc.Color.RED, underline=True)})
)
+7
-0

@@ -8,2 +8,8 @@ # Changelog

## [v0.2.2] - 2025-02-15
### Fixed
- Code blocks with 1-char-long bodies are now correctly detected
- Zig sources ending with an identifier token no longer crash the highlighter
## [v0.2.1] - 2025-02-11

@@ -60,1 +66,2 @@

[v0.2.1]: https://github.com/trag1c/ixia/compare/v0.2.0...v0.2.1
[v0.2.2]: https://github.com/trag1c/ixia/compare/v0.2.1...v0.2.2
+1
-1
Metadata-Version: 2.4
Name: zig-codeblocks
Version: 0.2.1
Version: 0.2.2
Summary: Zig ANSI syntax highlighting library

@@ -5,0 +5,0 @@ Project-URL: repository, https://github.com/trag1c/zig-codeblocks

[project]
name = "zig-codeblocks"
version = "0.2.1"
version = "0.2.2"
description = "Zig ANSI syntax highlighting library"

@@ -5,0 +5,0 @@ readme = "README.md"

@@ -38,4 +38,4 @@ from __future__ import annotations

def _peek(iterator: Iterator[T]) -> T:
return next(tee(iterator, 1)[0])
def _peek(iterator: Iterator[T]) -> T | None:
return next(tee(iterator, 1)[0], None)

@@ -93,3 +93,5 @@

theme.get("calls")
if token.kind == "identifier" and _peek(tokens).kind == "("
if token.kind == "identifier"
and (next_token := _peek(tokens))
and next_token.kind == "("
else _get_style(token.kind, theme)

@@ -96,0 +98,0 @@ )

@@ -10,3 +10,3 @@ import re

CODE_BLOCK_PATTERN = re.compile(
r"```(?:([A-Za-z0-9\-_\+\.#]+)(?:\r?\n)+([^\r\n].+?)|(.*?))```", re.DOTALL
r"```(?:([A-Za-z0-9\-_\+\.#]+)(?:\r?\n)+([^\r\n].*?)|(.*?))```", re.DOTALL
)

@@ -13,0 +13,0 @@

@@ -65,6 +65,14 @@ import json

theme = Theme(
identifiers=Style(Color.RED),
keywords=Style(Color.BLUE, underline=True),
identifiers=(red := Style(Color.RED)),
keywords=(blue_u := Style(Color.BLUE, underline=True)),
)
expected_highlighting = " \033[34;4mconst\033[0m \033[31mx\033[0m = 0xff;"
expected_highlighting = f" {blue_u}const\033[0m {red}x\033[0m = 0xff;"
assert highlight_zig_code(source, theme) == expected_highlighting
def test_safe_peek() -> None:
src = "just_an_identifier"
assert highlight_zig_code(src) == src
theme = Theme(identifiers=(red := Style(Color.RED)))
assert highlight_zig_code(src, theme) == f"{red}{src}"

@@ -36,2 +36,5 @@ import json

("rust\nfn", ("rust", "fn")),
("zig\na", ("zig", "a")),
("zig\naa", ("zig", "aa")),
("zig\na\n", ("zig", "a")),
("rust\n\n\n\n\n\n", (None, "rust")),

@@ -38,0 +41,0 @@ ("ruśt\nfn", (None, "ruśt\nfn")),

@@ -316,3 +316,3 @@ version = 1

name = "zig-codeblocks"
version = "0.2.1"
version = "0.2.2"
source = { editable = "." }

@@ -319,0 +319,0 @@ dependencies = [