Skip to content

v0.15.0 — LinkBlock + anchor recursion

Choose a tag to compare

@sunholo-voight-kampff sunholo-voight-kampff released this 14 May 05:32
· 366 commits to main since this release

Capture hyperlinks and rescue images inside anchors

Anchor handling was the biggest gap in v0.14.x: <a> branches in the HTML parser fell through to text-only mode, which silently dropped any <img>/heading/structured content inside them, and <a href> URLs were never surfaced anywhere — 62 anchor URLs in www.sunholo.com → 0 in JSON output.

New LinkBlock ADT variant

LinkBlock({text: string, href: string, title: string})

JSON output shape:

{"type":"link","text":"Try it free","href":"/ailang-parse/","title":""}

Every match site that pattern-matches on Block gained a sensible arm:

  • output_formatter.ail: JSON, console pretty-print ([link] text → href), markdown ([text](href)).
  • html_generator.ail: round-trips to <a href=\"...\">text</a>, preserving title if present.
  • qmd_generator.ail: markdown link syntax.
  • odt_generator.ail: proper <text:a xlink:href> ODF link.
  • docx_generator.ail/pptx_generator.ail/odp_generator.ail/xlsx_generator.ail: text + (url) downgrade (full <w:hyperlink> / <a:hlinkClick> round-trip deferred to a write-back release).
  • a2ui_formatter.ail: callout with href/title metadata.
  • unstructured_compat.ail: NarrativeText with link_urls metadata field (matches unstructured.io's hyperlink schema).
  • layout_ai.ail: compact [link] text → href representation for LLM context.

HTML parser anchor handling rewritten

The <a> branch now treats anchors as HTML5 transparent elements: recurses into children to surface block content (images, headings, nested structure), then additionally emits a LinkBlock when href is present.

Measured on www.sunholo.com

Metric v0.14.1 v0.15.0 Source HTML
Images captured 4 10 12 <img>
Anchor URLs captured 0 31 62 <a href>
LinkBlock support none full ADT —

The remaining 2 images / 31 anchors are inside constructs not yet handled (<picture> elements, anchors with no visible text). Deferred.

Known limitations (not addressed)

  • <img> attributes beyond src + alt (width, height, srcset, loading, title) and <picture>/<source> are still ignored. Schema change to ImageBlock cascades through every parser; deferred.
  • DOCX/PPTX hyperlink round-trip: writers downgrade to plain text + (url). Proper <w:hyperlink> / <a:hlinkClick> round-tripping is a write-back concern.

Changelog

Full v0.15.0 entry


Package registry: sunholo/ailang_parse@0.15.0 published.

SDKs: unchanged.