Skip to content

v2.4.0

Latest

Choose a tag to compare

@github-actions github-actions released this 13 Jul 04:19

Quarkdown 2.4 is one of the most impactful releases in the history of the project, introducing a new system for extending Markdown elements behavior and styling.
You can read in detail about this powerful feature in its blog post.

 

Added

 

Element styling (show-rules)

Note

This feature is experimental.

When .extend is applied to a function of the Primitives module, its new behavior is reflected on its Markdown counterpart. For example, extending the .heading function affects the # Heading Markdown element.

This is one of the biggest milestones for Quarkdown, on par with Typst's #show rules.

.extend {heading}
    content:
    .super foreground:{blue}
        *.content*

## A heading <!-- Renders blue and italic -->

This release ships with a handful of primitives as an experimental feature: headings, paragraphs, links, figures, images, math, page breaks. The plan is to eventually have every Markdown element type backed by a primitive function.

 

New primitives: .paragraph, .math, .link

The new .paragraph primitive backs Markdown paragraphs, .math backs $-delimited math blocks, and .link backs Markdown links, enabling extensions via .extend.

 

Full styling options on .heading, .paragraph, .math and .link

.container's styling options, such as foreground, background, border, padding, and fontsize, are now available on .heading, .paragraph, .math and .link as well. This allows for full customization without needing to wrap the element in a container.

.heading {Introduction} depth:{1} background:{blue} radius:{8px}

This plays particularly well with the new primitive extension system:

.extend {heading}
    content:
    .super background:{red} foreground:{white} padding:{10px}

 

Conditional .extend

.extend's new where parameter defines a condition to meet. If not met, the behavior falls back to the original function definition.

The following snippet applies a teal background to all headings of depth 1 and 2, while leaving deeper headings unchanged:

.extend {heading} where:{depth: .depth::islower than:{3}}
    .super background:{teal}

The following snippet adds an icon to all external links:

.extend {link} where:{url: .url::startswith {https://quarkdown.com}::not}
    content:
    .super
        .content .icon {box-arrow-up-right}

 

Regex match

The new .match function finds every substring of inline content that matches a regular expression and replaces each match with the inline content produced by a lambda.

.match {Quarkdown takes its name from quarks} pattern:{[Qq]uark(down|s)?}
    **.1**

Output:

Quarkdown takes its name from quarks

This is particularly useful for element styling:

.extend {paragraph}
    content:
    .super
        .content::match {[Qq]uark(down|s)?}
            **.1**

Quarkdown takes its name from quarks

 

Changed

 

Inline lambdas without @lambda

Inline lambdas passed as arguments no longer require the @lambda prefix. When the target parameter is a Lambda, the argument is parsed as a lambda directly.

.num::takeif {x: .x::equals {5}}
.mydictionary::sorted by:{name value: .value}
.extend {heading} where:{depth: .depth::islower than:{3}}
    .super background:{teal}

The @lambda prefix is still accepted for backward compatibility with older documents.

 

Body argument binding

Native functions can now explicitly designate a body parameter. Previously, the body argument of a function call always bound to the last parameter of the function.

Affected functions are .text and .heading.

This means the following now works as expected:

.text size:{large} weight:{bold}
    Inline content

Inline binding keeps working as before, so the following is still valid:

.text {Inline content} size:{large} weight:{bold}

 

Optimized argument binding

Parameter lookup now performs a single pass over the arguments, improving performance.

 

Body arguments for inline function calls

Inline function calls now accept body arguments, just like block-level calls do.

The following is now valid:

.heading depth:{1}
    .text size:{large}
        Content

Whereas previously, this was the only valid form:

.heading {.text {Content} size:{large}} depth:{1}

Sponsors

Thanks to our sponsors! 🎉

@vitto4

@aaditkamat

Falconer