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

Allow setting a custom LinkReferenceDefinitions in Parser.Builder #285

Open
pron opened this issue Feb 15, 2023 · 1 comment
Open

Allow setting a custom LinkReferenceDefinitions in Parser.Builder #285

pron opened this issue Feb 15, 2023 · 1 comment

Comments

@pron
Copy link

pron commented Feb 15, 2023

An application employing Markdown may want to resolve "naked links" ([foo]) -- i.e. links with no inline destination -- based on contextual knowledge rather than definitions in the text. A custom LinkReferenceDefinition would allow for that.

@robinst
Copy link
Collaborator

robinst commented Feb 11, 2024

Hmm that's an interesting idea. So you would set all the known LinkReferenceDefinition in the parser builder beforehand? I wonder if it would be even more useful to provide a callback instead, then you'd have more flexibility and e.g. be able to only look up a definition for which there were actual references in the document.

Something like:

ReferenceLinkResolver resolver = (label) -> {
    if (label.equals("foo")) {
        return new LinkReferenceDefinition("Foo", "https://example.org", "Title");
    } else {
        return null;
    }
};
var parser = Parser.builder().referenceLinkResolver(resolver).build();

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

No branches or pull requests

2 participants