Comments (4)
Two ideas to solve this without having to do any changes to md-to-pdf
:
-
a custom
.js
script that does the embedding within the page which you either set with thescript
config, or add to the end of the markdown content (you can just add<script>
tag in the markdown); any sync handlers that you attach to the load or DOMContentLoaded event would automatically be awaited; if it's async with network requests, i think it should also work because of this:
md-to-pdf/src/lib/generate-output.ts
Line 98 in 9ab307b
-
set a custom Marked renderer (https://marked.js.org/using_pro#renderer) to do the transformation, e.g. overwrite the
link
method, sth like:
const renderer = {
link(string href, string title, string text) {
const url = new URL(href)
if (url.hostname === 'instagram.com') {
// do sth fancy here that returns html to embed the post, could even fetch the html content here
return <div>...</div>
}
return false // default renderer kicks in
}
}
For the latter one it would be really useful to finally finish the stuff around the marked.use
API, i.e. allowing to configure Marked plugins/extensions via the config, which is mainly about finishing #228 and #140. Sadly I didn't really find any time to work on it (I also don't have any sponsors for this project so it's hard for me to justify spending much time on it).
from md-to-pdf.
willing to do the work for this
from md-to-pdf.
Ok, i'll have a dig around and see if I can locate a suitable renderer, i.e. option 2.
Save that, I can come up with a custom script i.e. option 1... there isn't any mention of a script
config entry in the docs, maybe there should be?
Also, a template for such a script would be useful, if I go with 1, maybe I can provide this
from md-to-pdf.
You're right, it's missing from the docs, but it's there in the types:
Lines 85 to 90 in 95502c5
Using --script
flag should also work (same as --stylesheet
/stylesheet
option).
from md-to-pdf.
Related Issues (20)
- bug: Failed to launch the browser process! HOT 1
- bug: HOT 1
- feature: Support for footnote, as Github-Flavored-Markdown now supports footnote HOT 1
- Improve documentation around Marked plugins
- feature: embedded tweets HOT 2
- feature: embedded mastodon posts HOT 2
- ProtocolTimeout change via the Commandline HOT 1
- bug: Puppeteer reports a weird warning HOT 5
- feature: Bookmarks HOT 1
- bug: Links to images now contain http://localhost:port prefix when using --as-html flag HOT 5
- feature: add --dest option to the CLI HOT 4
- bug: mathjax test is flaky
- feature: add language to body-tag HOT 3
- bug: HOT 1
- Can not find highlight style HOT 1
- feature: option to import other files for headerTemplate
- feature: ability to keep the browser window open (for testing & debugging) HOT 1
- bug: No such file or directory, open 'C:\workspace\angular-demo\pdf\**\*.md' HOT 3
- feature: Supporting marked plugins HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from md-to-pdf.