mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 05:16:23 +10:00
This commit is contained in:
@@ -24,7 +24,7 @@ module.exports = function snippet (md, options = {}) {
|
||||
const start = pos + 3
|
||||
const end = state.skipSpacesBack(max, pos)
|
||||
const rawPath = state.src.slice(start, end).trim().replace(/^@/, root)
|
||||
const filename = rawPath.split(/[{\s]/).shift()
|
||||
const filename = rawPath.split(/{/).shift().trim()
|
||||
const content = fs.existsSync(filename) ? fs.readFileSync(filename).toString() : 'Not found: ' + filename
|
||||
const meta = rawPath.replace(filename, '')
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`snippet import snipets when the file has a space in the file path 1`] = `
|
||||
<div class="highlight-lines">
|
||||
<div class="highlighted"> </div>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</div>export default function () { // .. }
|
||||
`;
|
||||
|
||||
exports[`snippet import snippet 1`] = `
|
||||
<pre><code class="language-js">export default function () {
|
||||
// ..
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<<< @/test/markdown/fragments/snippet with spaces.js {1}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function () {
|
||||
// ..
|
||||
}
|
||||
@@ -23,4 +23,10 @@ describe('snippet', () => {
|
||||
const output = mdH.render(input)
|
||||
expect(output).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('import snipets when the file has a space in the file path', async () => {
|
||||
const input = await getFragment('code-snippet-with-space-in-path')
|
||||
const output = mdH.render(input)
|
||||
expect(output).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user