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

Can't get metadata. #7

Closed
4 tasks done
guillevg opened this issue Feb 29, 2024 · 3 comments
Closed
4 tasks done

Can't get metadata. #7

guillevg opened this issue Feb 29, 2024 · 3 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@guillevg
Copy link

Initial checklist

Affected packages and versions

2.0.0

Link to runnable example

No response

Steps to reproduce

I am trying to extract metadata from the frontmatter of a markdown file. The following code does work, but I only get the HTML from the markdown.

import {micromark} from 'https://esm.sh/micromark@3?bundle'
import {frontmatter, frontmatterHtml} from 'https://esm.sh/micromark-extension-frontmatter@2?bundle'
import {math, mathHtml} from 'https://esm.sh/micromark-extension-math@3?bundle'

fetch('math_document.md')
  .then(response => response.text())
  .then((data) => {
    const output = micromark(data, {
      extensions: [math(), frontmatter()],
      htmlExtensions: [mathHtml(), frontmatterHtml()]
    });
    console.log(output);
  })

Expected behavior

I would like to get an object with both the HTML and the metadata.

Actual behavior

I only get HTML. It's as if the only thing this extension does is remove the frontmatter to leave only markdown? Any step in the right direction would be greatly appreciated.

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Feb 29, 2024
@wooorm
Copy link
Member

wooorm commented Feb 29, 2024

That’s not what this project does. micromark is a markdown parser. It parses markdown. This package is an extension for micromark to allow different fronmatter syntax extensions in markdown.

These things are not YAML parsers. If you want to parse YAML, use a YAML parser. And something that understands YAML frontmatter. Here’s a convenience wrapper to do both: https://github.com/vfile/vfile-matter.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@wooorm wooorm added the 🙋 no/question This does not need any changes label Feb 29, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Feb 29, 2024
@guillevg
Copy link
Author

All clear now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants