Skip to content

[Discussion]: Inline macro with \macro style #54

@boltlessengineer

Description

@boltlessengineer

I'm opening this issue as discussion instead of suggestion because it is incomplete proposal. I want to share some idea to implement inline macro.

I know, it smells like LaTeX.

Idea

Inline macro syntax needs macro identifier and list of arguments.
We already have good way to represent key-value arguments inline with attached modifier extensions; (key value;key;key). So we only need syntax to represent macro identifier.

In v1 spec, escaped normal character (not whitespace nor punctuation) doesn't have any additional meanings.
We can use that.

\macro-name(key value;params)

As some inline macros might need raw markup text as an argument, we an provide that with existing [...] grammar:

\macro-name[*markup* argument](key value;params)

I'm not sure if [...] should be free-form or not.

If it is free-form, we can replace $...$ syntax with this:

\latex[c = \sqrt{a^2 + b^2}]
\typst[c = sqrt(a^2 + b^2)]

If it is not free-form, we can nest the inline macros:

\my-macro[some text with \emoji(thinking)]

2nd case also shares same syntax with anchor

Example

\u(1f600) -> (unicode 1f600)

\gh[neovim/neovim] -> {https://github.com/neovim/neovim}[neovim/neovim]

\nvimhelp[:h 'shiftwidth'] -> {https://neovim.io/doc/user/options.html#'shiftwidth'}[`:h 'shiftwidth'`]

\latex[\alpha + \beta = \gamma] -> (Abstract Object representing LaTeX math equiation)

Cons

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions