next-theme / hexo-filter-mathjax

💯 Server side MathJax renderer plugin for Hexo.
https://www.npmjs.com/package/hexo-filter-mathjax
MIT License
105 stars 6 forks source link

如何添加mathjax的components组件支持 #60

Closed hiltay closed 12 months ago

hiltay commented 1 year ago

想使用Contextual Menu Options组件,请问应该怎么配置?提供的配置参数里没有找到。

stevenjoezhang commented 1 year ago

这个原理上不支持,它需要前端组件,而本插件是纯后端渲染

hiltay commented 1 year ago

看了下filter.js部分代码,如果想模仿这里的配置写法 https://github.com/next-theme/hexo-filter-mathjax/blob/bf65a9c2a4b0b161fb381e287e868c581251d593/lib/filter.js#L42-L45

使用官方文档的Developer Options,类似于如下:

const { Menu } = require('mathjax-full/js/ui/menu/Menu.js');
module.exports = function(config) {
    const menu = new Menu({
        texHints: true,        // put TeX-related attributes on MathML
        semantics: false,      // put original format in <semantic> tag in MathML
        zoom: 'NoZoom',        // or 'Click' or 'DoubleClick' as zoom trigger
        zscale: '200%',        // zoom scaling factor
        renderer: 'CHTML',     // or 'SVG'
        alt: false,            // true if ALT required for zooming
        cmd: false,            // true if CMD required for zooming
        ctrl: false,           // true if CTRL required for zooming
        shift: false,          // true if SHIFT required for zooming
        scale: 1,              // scaling factor for all math
        inTabOrder: true,      // true if tabbing includes math

        assistiveMml: true,    // true if hidden assistive MathML should be generated for screen readers
        collapsible: false,    // true if complex math should be collapsible
        explorer: false,       // true if the expression explorer should be active
      });
    const html = mathjax.document(content, {
      InputJax : tex,
      OutputJax: svg,
      ???: menu,
    });
}

但是不知道上述代码中的???应该填什么,这样写是否可行? 如果此方法不可行,可以提供一些其它的customise的方案吗,谢谢!!

hiltay commented 12 months ago

又研究了一下,使用前端渲染可以添加我想要的组件效果,再次感谢:)