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

Support spaces in label names #191

Closed
jan-molak opened this issue Sep 10, 2023 · 4 comments · Fixed by #192
Closed

Support spaces in label names #191

jan-molak opened this issue Sep 10, 2023 · 4 comments · Fixed by #192

Comments

@jan-molak
Copy link

jan-molak commented Sep 10, 2023

Hi @mrazauskas and thanks for your work on this plugin! I'd love to use it for the Serenity/JS website.

Do you think it would be possible for you to make the plugin support spaces in label names?

For example, below:

    ```json title="spec/config.json" tab={"label":"Chrome headless"}
    // some config
    ```
    
    ```json title="spec/config.json" tab={"label":"Chrome non-headless"}
    // some config
    ```
    
    ```json title="spec/config.json" tab={"label":"Firefox"}
    // some config
    ```

Results in the following error:

ERROR in ./docs/test-runners/cucumber.mdx
Module build failed (from ../../node_modules/@docusaurus/mdx-loader/lib/index.js):
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseMeta (/Users/jan/Projects/serenity-js/serenity-js/node_modules/docusaurus-remark-plugin-tab-blocks/src/plugin.js:21:29)
    at collectTabNodes (/Users/jan/Projects/serenity-js/serenity-js/node_modules/docusaurus-remark-plugin-tab-blocks/src/plugin.js:64:20)
    at /Users/jan/Projects/serenity-js/serenity-js/node_modules/docusaurus-remark-plugin-tab-blocks/src/plugin.js:114:24
    at overload (/Users/jan/Projects/serenity-js/serenity-js/node_modules/unist-util-visit/index.js:27:12)
    at visit (/Users/jan/Projects/serenity-js/serenity-js/node_modules/unist-util-visit-parents/index.js:56:27)
    at visit (/Users/jan/Projects/serenity-js/serenity-js/node_modules/unist-util-visit-parents/index.js:67:75)
    at visitParents (/Users/jan/Projects/serenity-js/serenity-js/node_modules/unist-util-visit-parents/index.js:29:26)
    at visit (/Users/jan/Projects/serenity-js/serenity-js/node_modules/unist-util-visit/index.js:22:3)
    at transformer (/Users/jan/Projects/serenity-js/serenity-js/node_modules/docusaurus-remark-plugin-tab-blocks/src/plugin.js:107:5)
    at wrapped (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:25:19)
    at next (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/index.js:57:24)
    at done (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:55:16)
    at then (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:62:5)
    at wrapped (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:45:9)
    at next (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/index.js:57:24)
    at done (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:55:16)
    at then (/Users/jan/Projects/serenity-js/serenity-js/node_modules/trough/wrap.js:62:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I think the issue is caused by the implicit assumption made in parseMeta that label names have no spaces:

const tabTag = nodeMeta.split(" ").filter((tag) => tag.startsWith("tab"));

Thanks!

@mrazauskas
Copy link
Owner

Thanks! Glad you find the plugin useful.

This is obviously a bug. I will fix it.

Do you need this for Docusaurus 2? I was about to publish stable version for Docusaurus 3 in a week or two. For instance, it is already used in production on Jest website (see jestjs/jest#14463).

@jan-molak
Copy link
Author

A patch for Docusaurus 2 would be brilliant, thank you!

@mrazauskas
Copy link
Owner

Fix it on main. It targets Docusaurus 3 already. Now I have to figure out how to back port that to v1. Never did something like this before ;D

@jan-molak
Copy link
Author

Thanks! And good luck! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants