惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - xemantic/markanywhere: Incremental Markdown pars...
morisil · 2026-05-15 · via Hacker News: Show HN

Incremental Markdown parser that emits streams of semantic events, plus tools to manipulate them — designed for real-time rendering of streamed LLM output.

Maven Central Version GitHub Release Date license

GitHub Actions Workflow Status GitHub branch check runs GitHub commits since latest release GitHub last commit

GitHub contributors GitHub commit activity GitHub code size in bytes GitHub Created At kotlin version discord users online Bluesky

Use cases

Markdown Parsing

val markdown = """
# Hello

A *streaming* parser.
"""

flowOf(markdown).parse().collect {
    println(it)
}

Will print:

{"type":"mark","name":"h1"}
{"type":"text","text":"Hello"}
{"type":"unmark","name":"h1"}
{"type":"mark","name":"p"}
{"type":"text","text":"A"}
{"type":"text","text":" "}
{"type":"mark","name":"em"}
{"type":"text","text":"streaming"}
{"type":"unmark","name":"em"}
{"type":"text","text":" "}
{"type":"text","text":"parser."}
{"type":"unmark","name":"p"}

The stream is append-only: each event is emitted as soon as the parser commits to it, so <h1> opens before Hello arrives and <em> opens the moment the * resolves.

Rendering Markdown as HTML

println(flowOf(markdown).parse().render())

Will print:

<h1>
  Hello
</h1>
<p>
  A <em>streaming</em> parser.
</p>

Rendering Markdown as DOM (Kotlin JS)

val markdownFlow = flowOf(markdown)
document.body!!.appendSemanticEvents(
    markdownFlow.parse()
)

Renders equivalent HTML into the browser's DOM tree.

Note: Typically markdownFlow: Flow<String> represents a Markdown text stream, for example from LLM inference.

Transforming the event stream

val emphasizeToStrong = Transformer {
    match("em") {
        "strong" {
            children()
        }
    }
}

println(
    flowOf(markdown)
        .parse()
        .transform(emphasizeToStrong)
        .render()
)

Will print:

<h1>
  Hello
</h1>
<p>
  A <strong>streaming</strong> parser.
</p>

The Transformer DSL rewrites the event stream on the fly — match marks by name (or expression), emit replacement marks, wrap or unwrap nested content, or rewrite text. Transformations compose, so the same pipeline can normalize HTML to Markdown, redact spans, or route <thinking> blocks to a separate sink.

If you have transformed XML trees with XSLT, the model should feel familiar — match { ... } plays the role of an XSLT template, children() mirrors <xsl:apply-templates/>, and emitted marks/text replace <xsl:element> / <xsl:text>. The difference: it operates on a streaming event flow rather than a buffered document tree, and the source is Markdown (or mixed Markdown + HTML) rather than XML.

Supported Markdown features

GFM is the dialect LLMs were trained on, which is why we take it as the baseline — not as a conformance target. The parser diverges where spec-correct behaviour would force buffering past the next emitted event (which would break streaming, the whole point of the library), and those divergent shapes are ones LLMs effectively never emit. The long-term aim is a separate spec, anchored on this parser, defined to fit the streaming model rather than the document model.

GFM baseline

Feature Syntax
ATX headings # H1###### H6
Paragraphs plain text blocks
Hard line break two trailing spaces or \ before newline
Thematic break --- / *** / ___
Fenced code block ```lang```
Indented code block 4-space indent
Block quote > text
Unordered list - item / * item / + item
Ordered list 1. item
Task list - [x] done / - [ ] todo
Table | col | col | with separator row
Inline code `code`
Strong **bold** or __bold__
Emphasis *italic* or _italic_
Strikethrough ~~text~~
Inline link [text](url) / [text](url "title")
Inline image ![alt](src)
Autolink <https://example.com> / <user@example.com>
Extended autolink www.example.com / https://… (GFM §6.9)
Raw HTML (block) HTML type 1–7 blocks pass through
Raw HTML (inline) <tag attr="val">…</tag>
Entity references &amp; / &#42; / &#x2A;
Backslash escapes \* → literal *
Link reference definitions [label]: url "title" (back-references only — see divergences)

Extensions beyond GFM

Feature Syntax Output element
Highlight ==text== <mark>
Superscript ^text^ <sup>
Inline math $E=mc^2$ <math>
Display math $$$$ on own lines <math display="block">
Front matter ---/+++ fence at document start `<frontmatter format="yaml
Namespaced tags <ns:tag attr="val"> Mark(name="ns:tag", isTagged=true)
DOCTYPE declaration <!DOCTYPE html> (case-insensitive) Mark(name="doctype", isTagged=true)

Namespaced tags let you embed arbitrary custom markup in a Markdown document. Any <namespace:tagname …> / </namespace:tagname> pair passes through as Mark/Unmark events with isTagged = true and parsed attributes — your renderer handles them however it wants. This covers use cases like custom card components, alert boxes, or any domain-specific block type without requiring new parser syntax.

GFM features not supported

Feature Reason
Setext headings (=== / --- underline) Requires one-line look-ahead to distinguish from paragraph + thematic break
Forward reference links ([text][label] before [label]: url) Definition must precede usage — the append-only stream cannot revisit emitted events
Tight vs. loose lists Tight/loose can only be decided after the full list closes
Mid-paragraph tables Tables only start at a fresh block boundary
Multi-line inline constructs flushInline force-closes inline state (code/em/strong/etc.) at every line/block boundary
Image inside link ([![alt](src)](url)) Nested inline constructs require speculative recursive parsing
Nested inline links ([foo [bar](/u)](/u)) Inner link is treated as label content; spec requires parser unwinding
Multi-line link parsing Link destination, title, or label spanning newlines is not supported

See markanywhere-parse/README.md for a full list of divergences and their rationale.

Modules

Module Purpose
markanywhere-api SemanticEvent sealed type — the only interface between modules
markanywhere-parse Streaming parser: Flow<String>Flow<SemanticEvent>
markanywhere-render HTML renderer: Flow<SemanticEvent> → HTML string
markanywhere-transform DSL for rewriting event streams on the fly
markanywhere-flow Utilities for composing and splitting event flows
markanywhere-extract Utilities for extracting structured data from event streams
markanywhere-js Kotlin/JS DOM renderer

You can depend only on markanywhere-parse and consume the Flow<SemanticEvent> with your own renderer — the API surface is a single three-variant sealed class. The markanywhere-transform module additionally lets you intercept and rewrite events before they reach any renderer.

Elaborate rationale

We use language to convey meaning, and we use text to express language. The document-whether scroll, codex, or book-established a paradigm for how text is preserved as a packaged unit. Documents also introduced formatting: visual and structural conventions that signal the intent behind particular fragments of text within a larger context.

When we built machines to process text, we formalized this into "document formats". These formats naturally inherited the hierarchical structure of books-parts, chapters, sections, paragraphs-and the software we built assumed that documents exist as complete artifacts to be parsed, transformed, and rendered.

But something new has emerged. We started texting each other, and text became a stream of information: received, comprehended, and often discarded in the moment of reception. This is also the communication paradigm between humans and LLMs. The text is not a document to be opened and read-it is an unfolding stream, with alternating modalities, comprehended while being generated.

Structured documents are not the right abstraction here. What we need instead is an ontology of expressive meaning as a stream of events: each event signaling either an incremental fragment of text or a transition between modalities of linguistic expression (from prose to code, from paragraph to heading, from plain text to emphasis). markanywhere inverts the traditional document processing flow. Rather than consuming complete documents and producing structure, it consumes streaming tokens and emits semantic events in real-time. These events can then be transformed-also as a stream-into various output formats: HTML, Markdown, XML, or whatever the receiving context requires.

The ontology of a meaningful stream of text

The SemanticEvent can be a:

  • Text: a chunk of characters
  • Mark (e.g. <em> tag, with optional attributes)
  • Unmark (e.g. </div>, indicating that previously opened mark is closed)

Mark and Unmark carry an isTagged flag distinguishing the origin of the event: true when it comes from an actual HTML/XML tag in the source, false when it is derived from Markdown syntax (e.g. *text* yields an em mark with isTagged = false, while <em>text</em> yields isTagged = true). The same SemanticEvent stream can therefore represent pure Markdown, pure HTML/XML (everything isTagged = true), or HTML embedded in Markdown — with the distinction preserved end-to-end so downstream renderers can treat each origin appropriately.

See the SemanticEvent definition.

Usage

In build.gradle.kts add:

dependencies {
    implementation("com.xemantic.markanywhere:markanywhere:0.1.3")
}