Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
f562ce6
commit 03fdcfd
Showing
6 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+255 Bytes
packages/core/integration-tests/test/integration/markdown/100x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
packages/core/integration-tests/test/integration/markdown/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# heading1 | ||
|
||
content content content | ||
|
||
[image](./100x100.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const fs = require('@parcel/fs'); | ||
const {bundle, run, assertBundleTree} = require('./utils'); | ||
|
||
describe('markdown', function() { | ||
it('should support bundling Markdown', async function() { | ||
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: [] | ||
} | ||
] | ||
}); | ||
|
||
let files = await fs.readdir(path.join(__dirname, '/dist')); | ||
let html = await fs.readFile(path.join(__dirname, '/dist/index.html')); | ||
for (let file of files) { | ||
let ext = file.match(/\.([0-9a-z]+)(?:[?#]|$)/i)[0]; | ||
if (file !== 'index.html' && ext !== '.map') { | ||
assert(html.includes(file)); | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const localRequire = require('../utils/localRequire'); | ||
const Asset = require('../Asset'); | ||
|
||
class MarkdownAsset extends Asset { | ||
constructor(name, options) { | ||
super(name, options); | ||
this.type = 'html'; | ||
this.hmrPageReload = true; | ||
} | ||
async generate() { | ||
let marked = await localRequire('marked', this.name); | ||
return marked(this.contents); | ||
} | ||
} | ||
module.exports = MarkdownAsset; |