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

WIP: Add Markdown Plugin #3384

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/configs/default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@parcel/transformer-html"
],
"*.coffee": ["@parcel/transformer-coffeescript"],
"*.md": ["@parcel/transformer-markdown"],
"*": ["@parcel/transformer-raw"]
},
"namers": ["@parcel/namer-default"],
Expand Down
1 change: 1 addition & 0 deletions packages/configs/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@parcel/transformer-html": "^2.0.0-alpha.1.1",
"@parcel/transformer-js": "^2.0.0-alpha.1.1",
"@parcel/transformer-json": "^2.0.0-alpha.1.1",
"@parcel/transformer-markdown": "^2.0.0-alpha.1.1",
"@parcel/transformer-postcss": "^2.0.0-alpha.1.1",
"@parcel/transformer-posthtml": "^2.0.0-alpha.1.1",
"@parcel/transformer-raw": "^2.0.0-alpha.1.1",
Expand Down
27 changes: 13 additions & 14 deletions packages/core/integration-tests/test/markdown.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
const assert = require('assert');
const path = require('path');
const {bundle, assertBundleTree, outputFS} = require('@parcel/test-utils');
const {bundle, assertBundles, outputFS} = require('@parcel/test-utils');

describe.skip('markdown', function() {
it('should support bundling Markdown', async function() {
describe('markdown', function() {
it.only('should support bundling Markdown', async function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I have also found helpful is using the --grep feature in mocha to regex to the specific test I want to run.

let b = await bundle(
path.join(__dirname, '/integration/markdown/index.md')
);

await assertBundleTree(b, {
name: 'index.html',
assets: ['index.md'],
childBundles: [
{
type: 'png',
assets: ['100x100.png'],
childBundles: []
}
]
});
await assertBundles(b, [
{
name: 'index.html',
assets: ['index.md']
},
{
type: 'png',
assets: ['100x100.png']
}
]);

let files = await outputFS.readdir(path.join(__dirname, '/dist'));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails at this line with

FSError: ENOENT: /..../parcel/packages/core/integration-tests/test/dist does not exist

Where exactly is the output supposed to be? Is the the Markdown Plugin I converted not configured properly? Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the distDir variable from @parcel/test-utils here instead.

let html = await outputFS.readFile(
Expand Down
17 changes: 17 additions & 0 deletions packages/transformers/markdown/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@parcel/transformer-markdown",
"version": "2.0.0-alpha.1.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/parcel.git"
},
"main": "src/MarkdownTransformer",
"engines": {
"parcel": "^2.0.0-alpha.1.1"
},
"dependencies": {
"@parcel/plugin": "^2.0.0-alpha.1.1",
"marked": "^0.7.0"
}
}
13 changes: 13 additions & 0 deletions packages/transformers/markdown/src/MarkdownTransformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @flow

import {Transformer} from '@parcel/plugin';
import marked from 'marked';

export default new Transformer({
async transform({asset}) {
asset.type = 'html';
let code = await asset.getCode();
asset.setCode(marked(code));
return [asset];
}
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8018,6 +8018,11 @@ marked@^0.6.1:
resolved "https://registry.yarnpkg.com/marked/-/marked-0.6.3.tgz#79babad78af638ba4d522a9e715cdfdd2429e946"
integrity sha512-Fqa7eq+UaxfMriqzYLayfqAE40WN03jf+zHjT18/uXNuzjq3TY0XTbrAoPeqSJrAmPz11VuUA+kBPYOhHt9oOQ==

marked@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.7.0.tgz#b64201f051d271b1edc10a04d1ae9b74bb8e5c0e"
integrity sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==

matchdep@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/matchdep/-/matchdep-2.0.0.tgz#c6f34834a0d8dbc3b37c27ee8bbcb27c7775582e"
Expand Down