hexojs / hexo-renderer-marked

Markdown renderer for Hexo
MIT License
179 stars 94 forks source link

chore(deps): adapt to marked@12 #280

Closed stevenjoezhang closed 7 months ago

stevenjoezhang commented 8 months ago

Marked has undergone significant upgrades in the past year (the version number quickly jumped from 4 to 12), and many old customization methods no longer apply. This pull request is intended to adapt to the new versions of marked. It's important to note that I have only ensured that all current unit tests can pass; whether it works properly in a real Hexo environment still needs further testing.

Issue resolved: https://github.com/hexojs/hexo-renderer-marked/issues/209 Issue resolved: https://github.com/hexojs/hexo-renderer-marked/issues/263

coveralls commented 8 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling 4d07ec6a072892a0070b27c7d8f7b594398c66fa on marked into 680f3aeac89e8b5dd3282664b0793a9a8dd143f4 on master.

tomap commented 8 months ago

Many options were removed in version 8. https://marked.js.org/using_advanced#options The doc should probably be re adapted.

Also we have our own implementation of headerid, while there is a plugin for that. We could remove our code for that

stevenjoezhang commented 8 months ago

hexo-renderer-marked has custom implementation of many options, so it's not affected much by the breaking changes since marked 8.0. I'll check again if some options are no longer working.

stevenjoezhang commented 8 months ago

marked's official headerid plugin does not support headerlink like <a href="#example" class="headerlink" title="Example"></a>, we may still need to use our own implementation

Ours: https://github.com/hexojs/hexo-renderer-marked/blob/680f3aeac89e8b5dd3282664b0793a9a8dd143f4/lib/renderer.js#L59 Theirs: https://github.com/markedjs/marked-gfm-heading-id/blob/e214c9091ce5770b416ebede1f5076cc8026d5d7/lib/index.cjs#L107

stevenjoezhang commented 8 months ago

Node.js 16.x is End-of-Life since September 2023, we can consider raising the minimum supported Node.js version for Hexo-related repositories.

uiolee commented 8 months ago

Personally, I think we should start to drop Node.js 14 & 16. However, we have a lot of repositories... 😫

I think if there are no changes of code or dependencies , then there is no need to update the version numbers of all repositories.

yoshinorin commented 7 months ago

then there is no need to update the version numbers of all repositories.

I'm concerned about the tedious PRs of just rewriting 'engines' and 'CI settings' in many repositories.

It may demotivate us (maintainers). I think this will be resolved in the migration to monorepo of https://github.com/hexojs/hexo/pull/5273 in the future, but I don't think we can do that before the drop of Node.js 14 and 16.

Anyway, I think it's okay to start to drop Node.js 14 and 16.

tomap commented 7 months ago

CI is green, so adding node 20 and dropping node 14 and 16 can be done later

stevenjoezhang commented 7 months ago

We might consider whether we can automate the process of upgrading the Node.js version used in actions/setup-node, for example, always testing with the latest three Node.js LTS versions.

For example, we can use tools like https://github.com/msimerson/node-lts-versions

stevenjoezhang commented 7 months ago

By looking at the https://node.green website, I found that the recent Node.js versions haven't introduced many new features that are widely used. Therefore, even if marked raises its minimum supported version, it would still work fine on older versions like Node.js 14.

Update: The newer version of JSDOM is incompatible with Node.js 14, as it uses an operator that is not supported.