mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-08 13:54:54 +00:00
Is there a recommended pipeline for "printable" (PDF-able) HTML? #371
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @daiplusplus on GitHub (Jun 10, 2020).
I'm using MarkDig in an application that will render the Markdown as HTML for a page viewed in a browser, but also in a page which is converted into a printable PDF (using
wkhtmltopdfand/or Puppeteer), so things like embedded videos usingUseMediaLinks()won't work.One of the main things I'd like to change is rendering Markdown hyperlinks as plaintext but keeping the link target in parentheses after the link-text (but still keeping it clickable as users may open the PDF on their computer).
If there isn't a built-in way to do this, I'll be happy to contribute a PR.
@markjerz commented on GitHub (Jan 9, 2023):
I've just had to do something similar. Taking inspiration from
MediaLinkExtensionsyou can add your own extension which makes use of theTryWriterson theLinkInlineRenderer.These functions are executed before rendering links. You can render the link yourself there and prevent the default rendering.
Set up your pipeline with your extension:
This code is what
Markdown.ToPlainText()does (using your pipeline instead of the default):