Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
boltlessengineer opened this issue Jan 22, 2025 · 0 comments
Open

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

boltlessengineer opened this issue Jan 22, 2025 · 0 comments

Comments

@boltlessengineer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant