Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot]
c009801164 Version Packages 2022-03-08 14:41:55 +01:00
Thomas Allmer
60310ab3dd fix: improve performance by loading sax-wasm only once 2022-03-08 14:37:31 +01:00
github-actions[bot]
db03f69210 Version Packages 2022-03-07 19:27:03 +01:00
Thomas Allmer
e6c3d274cf feat(mdjs-core): support js client as an alias to js script 2022-03-07 19:19:24 +01:00
10 changed files with 53 additions and 9 deletions

View File

@@ -1,5 +1,13 @@
# @rocket/cli
## 0.10.2
### Patch Changes
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
- Updated dependencies [60310ab]
- @rocket/eleventy-rocket-nav@0.3.1
## 0.10.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@rocket/cli",
"version": "0.10.1",
"version": "0.10.2",
"publishConfig": {
"access": "public"
},
@@ -60,7 +60,7 @@
"@rocket/building-rollup": "^0.4.0",
"@rocket/core": "^0.1.2",
"@rocket/eleventy-plugin-mdjs-unified": "^0.6.0",
"@rocket/eleventy-rocket-nav": "^0.3.0",
"@rocket/eleventy-rocket-nav": "^0.3.1",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-node-resolve": "^11.0.1",
"@web/config-loader": "^0.1.3",

View File

@@ -243,9 +243,9 @@ async function insertResponsiveImages(html) {
const config = getComputedConfig();
if (!isSetup) {
await parser.prepareWasm(saxWasmBuffer);
isSetup = true;
isSetup = parser.prepareWasm(saxWasmBuffer);
}
await isSetup;
const options = {
inputPath: this.inputPath,

View File

@@ -1,5 +1,11 @@
# @rocket/eleventy-rocket-nav
## 0.3.1
### Patch Changes
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
## 0.3.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@rocket/eleventy-rocket-nav",
"version": "0.3.0",
"version": "0.3.1",
"publishConfig": {
"access": "public"
},

View File

@@ -97,6 +97,7 @@ function getHeadingsOfHtml(html) {
return { headings, insertPoint };
}
/** @type {boolean | Promise<unknown>} */
let isSetup = false;
/**
@@ -104,9 +105,9 @@ let isSetup = false;
*/
async function addPageAnchors(content) {
if (!isSetup) {
await parser.prepareWasm(saxWasmBuffer);
isSetup = true;
isSetup = parser.prepareWasm(saxWasmBuffer);
}
await isSetup;
const { headings, insertPoint } = getHeadingsOfHtml(content);
const pageAnchorsHtml = [];

View File

@@ -1,5 +1,11 @@
# Change Log
## 0.9.4
### Patch Changes
- e6c3d27: Support `js client` as an alias to `js script`
## 0.9.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@mdjs/core",
"version": "0.9.3",
"version": "0.9.4",
"publishConfig": {
"access": "public"
},

View File

@@ -16,6 +16,9 @@ function mdjsParse() {
if (node.lang === 'js' && node.meta === 'script') {
jsCode += node.value;
}
if (node.lang === 'js' && node.meta === 'client') {
jsCode += node.value;
}
});
// we can only return/modify the tree but jsCode should not be part of the tree
// so we attach it globally to the file.data
@@ -26,7 +29,9 @@ function mdjsParse() {
* @param {Node} node
*/
const removeFunction = node =>
node.type === 'code' && node.lang === 'js' && node.meta === 'script';
node.type === 'code' &&
node.lang === 'js' &&
(node.meta === 'script' || node.meta === 'client');
remove(tree, removeFunction);
return tree;

View File

@@ -28,6 +28,24 @@ describe('mdjsParse', () => {
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
});
it('extracts "js client" code blocks', async () => {
const input = [
'## Intro',
'```js',
'const foo = 1;',
'```',
'```js client',
'const bar = 22;',
'```',
].join('\n');
const parser = unified().use(markdown).use(mdjsParse).use(html, { sanitize: false });
const result = await parser.process(input);
expect(result.contents).to.equal(
'<h2>Intro</h2>\n<pre><code class="language-js">const foo = 1;\n</code></pre>\n',
);
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
});
// TODO: fix this bug - maybe something in unified itself 🤔
it.skip('handling only "js script" code blocks', async () => {
const input = [