Skip to content

Add per-link configuration attributes to L<> markup code #14

@zag

Description

@zag

Problem

L<> currently accepts only URL and display text. No way to specify per-link metadata like "open in new tab" or "this is a download".

=config L<> sets defaults for entire document, but often need different behavior for specific links.

Solution

Extend L<> syntax to accept attributes after URL:

L<text|url :attr<value>>

Boundary: first space + colon starts config section. URLs don't contain this sequence, so parsing is unambiguous.

Syntax

L<API docs|https://api.example.com :new>
L<Download SDK|file:sdk.tar.gz :download>
L<French docs|doc:Guide :lang<fr> :title('Version française')>

Attributes

Four core attributes:

Attr Type What it does
:new bool open in new context (tab/window/pane)
:title string tooltip / advisory text
:lang string language of target
:download bool/string mark as download; string = filename

Precedence

Inline overrides =config:

=config L<> :new

L<external|https://x.com>           # gets :new from config
L<internal|doc:Local :!new>         # override: no new context

Edge cases

File paths with spaces must be quoted:

L<file:'my doc.pdf' :download>      # correct
L<file:my doc.pdf :download>        # wrong — parser error

URL path params (:id) distinguished by no preceding space:

L<https://api.com/users/:id :new>
                       ^^^^ ^^^^
                       URL  attr

Notes

No breaking changes . Existing L<> without attributes works exactly as before.
Same syntax applies to W<> contextual backlinks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions