pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/textproc/treemd



Module Name:    pkgsrc
Committed By:   pin
Date:           Mon Dec  1 20:35:29 UTC 2025

Modified Files:
        pkgsrc/textproc/treemd: Makefile cargo-depends.mk distinfo

Log Message:
textproc/treemd: update to 0.4.1

[0.4.1] - 2025-12-01
Fixed

    Config file color_mode setting ignored - The color_mode setting in config.toml is now properly respected (#5)
        Priority order: CLI flags > config file > auto-detection
        Set color_mode = "rgb" or color_mode = "256" in config to override auto-detection
        color_mode = "auto" (default) uses improved auto-detection

    RGB auto-detection fails for truecolor terminals - Improved terminal color detection for Kitty, Alacritty, WezTerm, and other RGB-capable terminals (#5)
        Now checks COLORTERM environment variable for truecolor or 24bit (primary standard per termstandard/colors)
        Checks TERM for known truecolor terminals (kitty, alacritty, wezterm) and suffixes (-truecolor, -direct)
        Checks TERM_PROGRAM for known apps (iTerm, Kitty, VS Code, Hyper, etc.)
        Falls back to supports_color crate detection

Technical

    Enhanced color detection (src/tui/terminal_compat.rs)
        New detect_truecolor_support() method with multi-method detection
        Environment variable checks before crate-based detection
        Better compatibility with terminals that set COLORTERM=truecolor

    Config priority in main (src/main.rs)
        Color mode selection now checks config file before auto-detection
        Clear priority: CLI args (highest) > config file > auto-detection (lowest)

Acknowledgements

    Special thanks to https://github.com/jinks908 for identifying and opening #5

[0.4.0] - 2025-11-30
Added

    Query Language (tql) - A comprehensive jq-like query language for navigating and extracting markdown structure
        Element selectors: .h, .h1-.h6, .code, .link, .img, .table, .list, .blockquote
        Filters and indexing: [Features] (fuzzy), ["exact"], [0], [-1], [1:3], [:3]
        Hierarchy operators: > (direct child), >> (descendant)
        Pipes for chaining: .h2 | text | upper
        Multiple output formats: plain, json, json-pretty, jsonl, markdown, tree
        50+ built-in functions with extensive aliases for discoverability

    CLI Query Flags
        -q, --query <EXPR> - Execute a query expression
        --query-help - Display comprehensive query language documentation
        --query-output <FORMAT> - Set output format (plain, json, jsonl, etc.)

    Query Functions - Collections
        count, length (aliases: len, size) - Count elements
        first, last (alias: head) - Get first/last element
        limit(n), skip(n) (aliases: take, drop) - Pagination
        nth(n) - Get element at index (supports negative)
        reverse, sort, sort_by(key) - Ordering
        unique, flatten - Array operations
        group_by(key) - Group elements by property
        keys, values - Object access
        min, max, add - Numeric/string aggregation
        any, all - Boolean aggregation

    Query Functions - Strings
        text - Get text representation
        upper, lower (aliases: ascii_upcase, ascii_downcase) - Case conversion
        trim - Strip whitespace
        split(sep), join(sep) - Split/join
        replace(from, to) - Substring replacement
        slugify - URL-friendly slug
        lines, words, chars - Count lines/words/characters

    Query Functions - Filtering
        select(cond) (aliases: where, filter) - Keep elements matching condition
        contains(s) (alias: includes) - Check for substring
        startswith(s), endswith(s) (aliases: starts_with, ends_with) - Prefix/suffix check
        matches(regex) - Regex matching
        has(key) - Check for property
        not - Negate boolean
        type - Get value type

    Query Functions - Content
        content - Section content (for headings)
        md (alias: markdown) - Raw markdown
        url (aliases: href, src) - Get URL/link/image source
        lang (alias: language) - Code block language

    Query Functions - Aggregation
        stats - Document statistics (headings, code blocks, links, etc.)
        levels - Heading count by level
        langs - Code block count by language
        types - Link types count

    Element Selector Aliases - Multiple names for discoverability
        .heading, .headers → .h
        .codeblock, .pre → .code
        .a, .anchor → .link
        .ul, .ol → .list
        .bq, .quotes → .blockquote
        .para, .paragraph, .p → .para
        .fm, .meta, .yaml → .frontmatter

    Stdin/Pipe Support - Read markdown from stdin for CLI workflows
        cat doc.md | treemd -q '.h2' - Pipe markdown content
        tree | treemd - Pipe tree output (auto-converted to markdown)
        treemd - - Explicit stdin reading
        Security limits: 100MB max input, 10MB max line length
        UTF-8 validation with clear error messages

    TTY Handling for Piped Input - TUI mode works even when stdin is piped
        Opens /dev/tty for keyboard input when stdin is piped
        Enables raw mode on correct terminal device
        Seamless tree | treemd workflow with full interactivity

Technical

    New Query Module (src/query/ - ~3000 lines)
        mod.rs - Public API: execute(), parse(), engine(), format_output()
        lexer.rs - Tokenizer with span tracking
        parser.rs - Recursive descent parser with operator precedence
        ast.rs - Complete AST types (Query, Expr, ElementKind, Filter, IndexOp, etc.)
        eval.rs - Evaluator with pluggable function registry
        registry.rs - Function and extractor registry with Levenshtein suggestions
        value.rs - Runtime value types (Heading, Code, Link, Image, Table, etc.)
        builtins/mod.rs - 50+ built-in functions
        output.rs - Multi-format output rendering
        error.rs - Rich error messages with source spans and suggestions
        extractors.rs - Pluggable element extraction (reserved for future)

    New Input Module (src/input.rs - 195 lines)
        InputSource enum for file vs stdin sources
        InputError with descriptive messages
        determine_input_source() - Smart source detection
        process_input() - Content processing with format detection
        Security limits to prevent DoS attacks

    New TTY Module (src/tui/tty.rs - 229 lines)
        enable_raw_mode() / disable_raw_mode() - TTY-aware raw mode
        read_event() - Event reading from correct source
        Uses MaybeUninit for safer uninitialized memory handling
        Cross-platform support (Unix with /dev/tty, Windows fallback)

    New Dependencies
        indexmap 2.7 - Ordered maps for predictable output
        regex 1.11 - Regex matching in queries

    Architecture
        Pluggable function registry for custom extensions
        Trait-based extractor system for future element types
        Comprehensive test suite (35 query tests)

Examples

# List all h2 headings
treemd -q '.h2' doc.md

# Get heading text only
treemd -q '.h2 | text' doc.md

# Count headings
treemd -q '[.h2] | count' doc.md

# First 5 headings
treemd -q '[.h] | limit(5)' doc.md

# Filter headings (three equivalent ways)
treemd -q '.h | select(contains("API"))' doc.md
treemd -q '.h | where(contains("API"))' doc.md
treemd -q '.h[API]' doc.md

# All Rust code blocks
treemd -q '.code[rust]' doc.md

# External link URLs
treemd -q '.link[external] | url' doc.md

# h2s under "Features" section
treemd -q '.h1[Features] > .h2' doc.md

# Group headings by level
treemd -q '[.h] | group_by("level")' --query-output json doc.md

# Document statistics
treemd -q '. | stats' doc.md

# Pipe from tree command
tree | treemd -q '.h'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 pkgsrc/textproc/treemd/Makefile \
    pkgsrc/textproc/treemd/cargo-depends.mk pkgsrc/textproc/treemd/distinfo

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/textproc/treemd/Makefile
diff -u pkgsrc/textproc/treemd/Makefile:1.5 pkgsrc/textproc/treemd/Makefile:1.6
--- pkgsrc/textproc/treemd/Makefile:1.5 Sun Nov 23 09:12:47 2025
+++ pkgsrc/textproc/treemd/Makefile     Mon Dec  1 20:35:29 2025
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.5 2025/11/23 09:12:47 pin Exp $
+# $NetBSD: Makefile,v 1.6 2025/12/01 20:35:29 pin Exp $
 
-DISTNAME=      treemd-0.3.2
+DISTNAME=      treemd-0.4.1
 CATEGORIES=    textproc
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=Epistates/}
 GITHUB_TAG=    v${PKGVERSION_NOREV}
Index: pkgsrc/textproc/treemd/cargo-depends.mk
diff -u pkgsrc/textproc/treemd/cargo-depends.mk:1.5 pkgsrc/textproc/treemd/cargo-depends.mk:1.6
--- pkgsrc/textproc/treemd/cargo-depends.mk:1.5 Sun Nov 23 09:12:47 2025
+++ pkgsrc/textproc/treemd/cargo-depends.mk     Mon Dec  1 20:35:29 2025
@@ -1,4 +1,4 @@
-# $NetBSD: cargo-depends.mk,v 1.5 2025/11/23 09:12:47 pin Exp $
+# $NetBSD: cargo-depends.mk,v 1.6 2025/12/01 20:35:29 pin Exp $
 
 CARGO_CRATE_DEPENDS+=  addr2line-0.25.1
 CARGO_CRATE_DEPENDS+=  adler2-2.0.1
Index: pkgsrc/textproc/treemd/distinfo
diff -u pkgsrc/textproc/treemd/distinfo:1.5 pkgsrc/textproc/treemd/distinfo:1.6
--- pkgsrc/textproc/treemd/distinfo:1.5 Sun Nov 23 09:12:47 2025
+++ pkgsrc/textproc/treemd/distinfo     Mon Dec  1 20:35:29 2025
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.5 2025/11/23 09:12:47 pin Exp $
+$NetBSD: distinfo,v 1.6 2025/12/01 20:35:29 pin Exp $
 
 BLAKE2s (addr2line-0.25.1.crate) = cc5c422ec48ccef5c2c46379d2f600644609490afafea5020f2020815d1146e6
 SHA512 (addr2line-0.25.1.crate) = c400f3b6ccaff8a1c0d7d82c708a1784b8fd5ba64b6e420e85819d59b1cadb55fa59c852925093b921469f272d1d5140cf12f013ae75d1e1bc85021097df8fc2
@@ -627,9 +627,9 @@ Size (tracing-subscriber-0.3.20.crate) =
 BLAKE2s (tree_magic_mini-3.2.0.crate) = e3c62f82f8c429d5628526addb79cc9cce1ab85a82c92a54f7d2b63473d13668
 SHA512 (tree_magic_mini-3.2.0.crate) = 7151639da4a20f3e0da8059f0b6b05dbb497462ce0ca23df8b07c5e515d49dbb905371259a51f5cba634f62b1dfb9d79aa0ee212e31a74f46f30715a82ee4e8d
 Size (tree_magic_mini-3.2.0.crate) = 15962 bytes
-BLAKE2s (treemd-0.3.2.tar.gz) = 397166d83d7b39d07de2cd7568fe0ff8a7b2923122c8e830618f499f4b0976ac
-SHA512 (treemd-0.3.2.tar.gz) = 0ba651d61dfebd51df24290350d9db3c457eb23c608438df668483c6b800f2f1fa0c24e36b3385b2d6f33f7bb796d354fe9ea5f971596890af38a3c928c5ad37
-Size (treemd-0.3.2.tar.gz) = 329262 bytes
+BLAKE2s (treemd-0.4.1.tar.gz) = 4d17cce48a14bdad0b1e767b7893216673cd55f79cd8c06484f5a77a7836a449
+SHA512 (treemd-0.4.1.tar.gz) = e92f8be766fb55c3f49f49b5f9bb5f9cef82f949301ea623402b25b5d4cbd0a5b6a62e95e41e9944b291f2d7ec4f600a007e45d3a1259d3f5f4e5eec16e6d6c4
+Size (treemd-0.4.1.tar.gz) = 373679 bytes
 BLAKE2s (unicase-2.8.1.crate) = 6a87002c4bd702bb961347b5ecac9404f9a65359b563c199608a3eaaf66195ea
 SHA512 (unicase-2.8.1.crate) = 99a3944a5c987376bdea5fe6c0797e881bc8e6f629c56120ce811c8ebbed0a3ba24617decb74d6939699c8fc994c662eb292869ab407c0ba0ec460a32ede0190
 Size (unicase-2.8.1.crate) = 24088 bytes



Home | Main Index | Thread Index | Old Index