Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

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.3.0
to
0.3.1
+7
tests/sources/spacing/triple_in_double_inline.md
This code block starts with `` ```zig``!
```py
print(1)
```
```zig
const std = @import("std");
```
+1
-2

@@ -22,2 +22,3 @@ # This file is autogenerated by maturin v1.8.3

strategy:
fail-fast: false
matrix:

@@ -32,4 +33,2 @@ platform:

- runner: ubuntu-22.04
target: s390x
- runner: ubuntu-22.04
target: ppc64le

@@ -36,0 +35,0 @@ steps:

@@ -21,2 +21,8 @@ # This file is automatically @generated by Cargo.

[[package]]
name = "bitflags"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "cc"

@@ -27,2 +33,4 @@ version = "1.2.16"

dependencies = [
"jobserver",
"libc",
"shlex",

@@ -44,2 +52,14 @@ ]

[[package]]
name = "getrandom"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasi",
]
[[package]]
name = "hashbrown"

@@ -79,2 +99,12 @@ version = "0.15.2"

[[package]]
name = "jobserver"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
dependencies = [
"getrandom",
"libc",
]
[[package]]
name = "libc"

@@ -86,2 +116,8 @@ version = "0.2.171"

[[package]]
name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "memchr"

@@ -108,2 +144,30 @@ version = "2.7.4"

[[package]]
name = "pcre2"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3be55c43ac18044541d58d897e8f4c55157218428953ebd39d86df3ba0286b2b"
dependencies = [
"libc",
"log",
"pcre2-sys",
]
[[package]]
name = "pcre2-sys"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "550f5d18fb1b90c20b87e161852c10cde77858c3900c5059b5ad2a1449f11d8a"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "pkg-config"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "portable-atomic"

@@ -206,2 +270,8 @@ version = "1.11.0"

[[package]]
name = "r-efi"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "regex"

@@ -346,7 +416,25 @@ version = "1.11.1"

[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [
"wit-bindgen-rt",
]
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags",
]
[[package]]
name = "zig_codeblocks"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"pcre2",
"pyo3",
"regex",
"serde",

@@ -353,0 +441,0 @@ "serde_json",

[package]
name = "zig_codeblocks"
version = "0.3.0"
version = "0.3.1"
edition = "2021"

@@ -12,6 +12,7 @@

[dependencies]
pcre2 = "0.2.9"
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
# "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
# "generate-import-lib" helps with building on Windows
pyo3 = { version = "0.24.0", features = ["extension-module", "abi3-py39", "generate-import-lib"] }
regex = "1.11.1"
tree-sitter = "0.25.3"

@@ -18,0 +19,0 @@ tree-sitter-zig = "1.1.2"

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

## [v0.3.1] - 2025-04-25
### Fixed
- Fixed ` ``` ` in inline code blocks being treated as a fenced code block
starter
## [v0.3.0] - 2025-04-15

@@ -104,1 +110,2 @@

[v0.3.0]: https://github.com/trag1c/zig-codeblocks/compare/v0.2.3...v0.3.0
[v0.3.1]: https://github.com/trag1c/zig-codeblocks/compare/v0.3.0...v0.3.1
Metadata-Version: 2.4
Name: zig-codeblocks
Version: 0.3.0
Version: 0.3.1
Requires-Dist: typer-slim>=0.15.2 ; extra == 'cli'

@@ -5,0 +5,0 @@ Provides-Extra: cli

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

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

use std::{borrow::Cow, sync::LazyLock};
use pcre2::bytes::{Match, Regex};
use pyo3::prelude::*;
use regex::bytes::{Match, Regex};

@@ -59,2 +59,5 @@ #[derive(Debug, PartialEq, Eq)]

});
static INLINE_CODE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"(?<!`)(``?)(?:[^`]|[^`].*?[^`])\1(?!`)").expect("guaranteed to be valid")
});

@@ -105,5 +108,22 @@ fn get_parser() -> tree_sitter::Parser {

pub fn extract_codeblocks(source: &[u8]) -> Vec<CodeBlock> {
let slices: Vec<_> = INLINE_CODE_PATTERN
.find_iter(source)
.map(|m| {
let m = m.expect("there should be a match");
(m.start(), m.end())
})
.collect();
let source: Cow<'_, [u8]> = if slices.is_empty() {
Cow::Borrowed(source)
} else {
let mut source = source.to_vec();
for (a, b) in slices.iter().rev() {
source.drain(a..b);
}
Cow::Owned(source)
};
CODE_BLOCK_PATTERN
.captures_iter(source)
.captures_iter(&source)
.map(|m| {
let m = m.expect("capture should be ok");
let (lang, body, no_lang_body) = (m.get(1), m.get(2), m.get(3));

@@ -110,0 +130,0 @@ if lang.is_some() {

@@ -54,3 +54,7 @@ use std::{collections::HashMap, sync::LazyLock};

const fn python_bool_repr(value: bool) -> &'static str {
if value { "True" } else { "False" }
if value {
"True"
} else {
"False"
}
}

@@ -57,0 +61,0 @@

@@ -20,2 +20,3 @@ from __future__ import annotations

("squished_no_gap.md"),
("triple_in_double_inline.md"),
],

@@ -22,0 +23,0 @@ )

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

name = "zig-codeblocks"
version = "0.3.0"
version = "0.3.1"
source = { editable = "." }

@@ -223,0 +223,0 @@

from zig_codeblocks import highlight_zig_code
print(highlight_zig_code("const stdip@0'sirjgoicjgoii gueve up"))