1

May I ask you about my problem? I am trying to apply remark-math to my elder.js blog. It is not rendered properly. Like this.

markdown

$$
\sin^2x + \cos^2x = 1
h \circ (g \circ f) = (h \circ g) \circ f = h \circ g \circ f
$$

rendered html

<div class="math math-display">
\sin^2x + \cos^2x = 1
h \circ (g \circ f) = (h \circ g) \circ f = h \circ g \circ f
</div>

now my blog's link

https://twinstae.github.io/category-for-functional/

I did followings.

  • npm install remark-math remark-katex
  • add katex css to head
  • add all default pipeline and remarkMath, remarkKatex to elder.config.js

elder.config.js

plugins: {
  '@elderjs/plugin-markdown': {
    routes: ['blog'],
    remarkPlugins: [
      frontmatter, // 'remark-frontmatter' package
      [extractFrontmatter, { name: 'frontmatter', yaml: yaml.parse }], // 'remark-extract-frontmatter'       and 'yaml' packages.
      remarkSlug, // 'remark-slug' package
      remarkMath,
      remarkKatex,
      remarkHtml, // 'remark-html' package
    ],
  },
  ...
}

elder.config.js link https://github.com/twinstae/twinstae.github.io/blob/master/elder.config.js

docs for remark-plugin link

https://www.npmjs.com/package/@elderjs/plugin-markdown#remark-plugins

I am trying several plugins orders, searching, reading Elder.js docs again...

Thank you for reading. :)

Stelo
  • 21
  • 4

1 Answers1

1

I found the answer! rehype-katex is a plugin for rehype

new elder.config.js

const remarkMath = require('remark-math');
const remark2rehype = require('remark-rehype');
const rehypeKatex = require('rehype-katex');
const rehypeStringify = require('rehype-stringify');

... (default plugins),
remarkMath,
remark2rehype, <- I missed this
rehypeKatex,
rehypeStringify, <- I missed this too
Stelo
  • 21
  • 4