zestedesavoir / zmarkdown

Live demo: https://zestedesavoir.github.io/zmarkdown/
MIT License
226 stars 52 forks source link

Remark-captions not rendering table caption #513

Open alexander-turner opened 1 month ago

alexander-turner commented 1 month ago

When I run node on the following code:

import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import remarkCaptions from "remark-captions";

const processor = unified()
  .use(remarkParse)
  .use(remarkCaptions)
  .use(remarkRehype)
  .use(rehypeStringify);

const markdown = `
head1| head2
-----|------
bla|bla
Table: figcapt1`;

processor.process(markdown, (err, file) => {
  if (err) throw err;
  console.log(String(file));
});

The following is produced:

<p>head1| head2
-----|------
bla|bla
Table: figcapt1</p>

However, according to the remark-captions README, it should produce:

<figure>
  <table>
    <thead>
      <tr>
        <th>head1</th>
        <th>head2</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>bla</td>
        <td>bla</td>
      </tr>
    </tbody>
  </table>
  <figcaption>figcapt1</figcaption>
</figure>
StaloneLab commented 4 weeks ago

Just in case, could you tell which version of remark-parse you are using? Captions work for images at least on latest remark, but support for tables might have been broken at some point, unsure if it might be linked to new remark@13 or not. It shouldn't, but who knows?

alexander-turner commented 4 weeks ago

(It works for images on mine too)