use of 'meta' fields

John Clements's Avatar

John Clements

09 Dec, 2022 10:20 AM

My code — the first two lines are 'meta' fields, invisible on the preview document (using Marked 2)

Title:   Document title
Domain: https://relevant-domain.com

[Document title]([%domain])

The aim is that the title will include an embedded link to the domain, using the meta field. But it produces a null response.

By contrast, If I insert the domain as text:

[Document title](https://relevant-domain.com)

It works. Anyone know why / solution / workaround.

For the record: using '[domain]' alone returns a working link. It's only when I use it as an embedded link, behind text that it doesn't work. Marked 2 reports: Unknown [%domain]

This is a proof case question; not a single use issue: I will re-use this syntax device elsewhere if I can get it working. So just telling me to use the text version isn't a help. Thanks!

  1. Support Staff 1 Posted by Fletcher on 09 Dec, 2022 12:35 PM

    Fletcher's Avatar

    There are a couple of things going on here.

    MultiMarkdown parses in a single pass, so you can't "nest" things that
    have to be resolved sequentially.

    Metadata variables (the '[%foo]' construct) have to be a "top-level"
    element within a span of plain text in order to be converted into the
    value from the metadata.

    Additionally, the URL construction (`[foo](URL)`) does not interpret
    Markdown inside the `(URL)` section -- that text is used as is.

    In this case, you are saying that the URL is literally `[%domain]`.

    You can test something similar with `[Foo **bar**](Foo **bar**)`. The
    strong attribute is applied to the link text, but not the URL.

    The one exception to the "single pass" rule is that there is a
    pre-processing step that handles the `mmd header` and `mmd footer`
    metadata, and performs file transclusion to create the final plain text
    source, and *then* the MultiMarkdown parser does it's thing.

    Fletcher

  2. 2 Posted by John Clements on 09 Dec, 2022 01:48 PM

    John Clements's Avatar

    No dice then. Thanks for explaining principles.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac