Repository navigation
How can I display [link-id]: https://url.tld "title" links automatically where they're defined? #734
|
I want to have something like: my county's population was about [110,000 in 2010][2010-population] and blah blah
then at the bottom
[2010-population]: http://the_url "Census population counts 2010 - 2019"And of course render the link in the body of the article. But then ALSO render a link at the bottom, to have like a ... sources section. But the I'm doing this to render: $cmark = new \League\CommonMark\CommonMarkConverter();
$convertedToHtml = $cmark->convertToHtml($md);Are there configuration options, or an extension I can use that would auto-render the id-style-links into the html? |
Replies: 2 comments 1 reply
|
Of course, it would be pretty easy to re-use the [link-id] to make a sources section myself ... but I'm lazy & who wants to do that? lol |
|
There are currently two different ways that (kind of) support what you're looking for:
But to get the exact functionality you described, you would need to write a small extension. The heart of that extension would be an event listener for the |
There are currently two different ways that (kind of) support what you're looking for:
FootnotesExtension: https://commonmark.thephpleague.com/2.0/extensions/footnotes/But to get the exact functionality you described, you would need to write a small extension. The heart of that extension would be an event listener for the
DocumentParsedEventthat takes the parsedDocument, iterates through all the references inside of itsReferenceMap, and appends link nodes (perhaps in a list?) to the bottom of theDocumentnode so that they get rendered. I think that should give you what you're looking for :)