-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[T-290] Markdown transformer #3936
Conversation
This pull request has been linked to T-290. |
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold BundlesNo bundle changes detected. Cached Bundles
AtlasKit Editor 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... Three.js x4 🚨
Timings
Cold BundlesNo bundles found, this is probably a failed build... Cached BundlesNo bundles found, this is probably a failed build... |
// @flow | ||
import {Transformer} from '@parcel/plugin'; | ||
import {promisify} from '@parcel/utils'; | ||
import marked from 'marked'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to look into using something like remark for markdown since it supports all kinds of plugins for different things. For example, syntax highlighting could be done by a plugin for remark however people like without needing Parcel to build it into the transformer. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, wouldn't that require a javasrcript based config?
packages/packagers/markdown-html/src/MarkdownHtmlTransformer.js
Outdated
Show resolved
Hide resolved
This pull request has been linked to and will mark 1 task as "Done" when merged:
|
The ability to use parcel 2 as a static site generator with code highlighting built in would be awesome! What's the status of this PR? |
@bradenhs it's ready for a merge just awaiting a review |
|
@mischnic I haven't really found a way around relative paths except running posthtml over the template and rewriting all relative imports to be relative to markdown instead of the template. I agree with dynamically using the markdown and highlight libraries. Will refactor everything and hack in the relative support once Devon has reviewed this. My main question about remark vs marked is there no point in changing except for the config but that might require a js config? Which we are actively trying to prevent everywhere. |
True, but we could do use a
Do you mean "remark doesn't have any benefits" or "remark doesn't have any benefits if we don't allow a config file" |
@mischnic with no point in changing that I mean it would/should output the same as marked anyway if there's no config. So the only reason I see was the config as it's main selling point is the plugins |
I think we need to come up with something that's extensible, or people will just run into issues pretty quickly. Remark has a great plugin ecosystem around it that people can use to extend it. We just need a way of letting people specify those. I think things like syntax highlighting should also be done in plugins too so it can be customizable. We just need a way to run remark and load plugins inside parcel. I'm also thinking that maybe part of this should be done in a packager too. As @mischnic said, we'll need a way of generating a list of links between pages and such. If we ran all of the pages through a packager at the end, that could inject the markdown into a template or something to generate the full HTML page with the list of links, which could come from the bundle graph. We're doing something similar at work for our docs website, except using MDX and React. I think we'd want a way to specify layouts at the page level along with other metadata like title, description, etc. This could be done using frontmatter perhaps, or however plugins wanted, and stored in I'm not saying all that has to happen in this PR, but I think we should move in this direction. In my experience so far it's been awesome to use Parcel as a static site generator, so I'd like for it to be as extensible as possible. |
Might recreate this PR at some point in the future, for now gonna close it |
↪️ Pull Request
This PR adds a markdown transformer for Parcel 2, the aim of this PR is to get parcel to become a fully functional static site generator from markdown files, by allowing specification of a layout file and metadata through frontmatter.
We can probably use this to generate the Parcel 2 docs site?
For code highlighting this uses highlight.js and for markdown parsing it uses marked.
Loosely based on #2882
Closes #3357
Close T-290
✔️ PR Todo