takeLabel

fun <T : Any> Scanner.takeLabel(closes: Scanner.() -> T?): Pair<String, T>?

Consumes the bracketed label shared by links, reference links, images and reference images.

The label is lazy: at every candidate closing bracket it asks closes whether the rest of the construct parses, and stops at the first bracket where it does. closes runs on this same scanner, positioned just past that bracket, and returning null from it rewinds and keeps scanning.

Return

the raw label and what closes produced, or null when no label closes here

Parameters

closes

parses the rest of the construct, returning null to reject this closing bracket