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

Block anchors #332

Merged
merged 9 commits into from
Nov 30, 2023
Merged

Block anchors #332

merged 9 commits into from
Nov 30, 2023

Conversation

main-kun
Copy link
Contributor

Add a plugin to support {#my-anchor} syntax for anchors detached from content

@main-kun main-kun marked this pull request as ready for review November 13, 2023 12:27
@main-kun main-kun requested a review from moki November 13, 2023 12:27
@moki
Copy link
Member

moki commented Nov 14, 2023

let's go for the syntax: {% anchor anchor-id %}

regexp: ^{%[^\S\r\n]*anchor[^\S\r\n]+[\w-]+[^\S\r\n]*%}

since we want to make leaf block node plugin, let's match only paragraphs with that syntax exclusively.

fair example would be:

function matchOpenToken(tokens: Token[], i: number) {
return (
tokens[i].type === 'paragraph_open' &&
tokens[i + 1].type === 'inline' &&
tokens[i + 1].content.match(pattern)
);
}

@main-kun main-kun requested a review from moki November 17, 2023 15:44
@main-kun main-kun requested a review from moki November 22, 2023 12:27
@main-kun main-kun changed the title Detached-anchors Block anchors Nov 22, 2023
@moki moki merged commit 589c357 into master Nov 30, 2023
1 check passed
@moki moki deleted the detached-anchors branch November 30, 2023 11:34
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

Successfully merging this pull request may close these issues.

3 participants