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

marked v13's token renderer #73

Open
emmercm opened this issue Nov 16, 2024 · 2 comments
Open

marked v13's token renderer #73

emmercm opened this issue Nov 16, 2024 · 2 comments

Comments

@emmercm
Copy link

emmercm commented Nov 16, 2024

Unfortunately marked changed the function signatures on the renderer object.

I have some code to alter renderer behavior:

import {marked} from 'marked';
const markdownRenderer = new marked.Renderer();
markdownRenderer.heading = (text, level, raw) => {
    // ... 
};
markdownRenderer.table = (header, body) => {
    // ...
};
markdownRenderer.code = (_code, infostring, escaped) => {
    // ...
};

and then I provide that renderer like this:

import markdown from '@metalsmith/markdown';
Metalsmith(path.resolve())
    // ...
    .use(markdown({
        renderer: markdownRenderer
    }))
    // ...

markedjs/marked#3291 made it so renderers created with marked v13+ code are incompatible with <v13 versions of marked, and this plugin's version is quite old.


Maybe a warning about compatible versions of marked would suffice? I suspect this plugin's version of marked is being held back intentionally based on #70.

An eventual major upgrade of this plugin might be nice, and I'm sure you had other items for its roadmap.

@webketje
Copy link
Member

I attempted to update this plugin a year ago and got into contact with the newer maintainer of marked to address issues with the release process and the new extensions ecosystem: https://github.com/search?q=org%3Amarkedjs+type%3Aissue+commenter%3Awebketje&type=issues.

It became clear to me that we are totally at odds about how an open-source project should be managed, see a.o. markedjs/marked#3186 (comment). Metalsmith as a project with regard for backward-compatibility and stability cannot rely on a core plugin that breaks as frequently as bot-automated marked + extension releases. I attempted an upgrade but there were just too many incompatibilities and open questions: https://github.com/metalsmith/markdown/commits/release/2.x. I did a deeper dive in some of the marked extensions and found that for ex the smartypants dependency used has code of dubious quality.

For these reasons I concluded it would be better to switch to an alternative dependency, and stuck with https://github.com/remarkjs/remark, for which I also started work at https://github.com/metalsmith/markdown/commits/poc/remark. Remark can do much more than just markdown, including MDX. I discontinued work on this after 2 hard drive crashes made me lose local progress and I had to focus on home renovations.

@emmercm
Copy link
Author

emmercm commented Dec 6, 2024

@webketje this was a very thoughtful answer, thank you. I agree with your viewpoint on breaking changes.

Maybe it could be worth a quick README note about this plugin only being compatible with <v13. I'm totally fine with keeping my versions held back.

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

No branches or pull requests

2 participants