Code Monkey home page Code Monkey logo

remark-parse-yaml's Introduction

remark-parse-yaml

npm version Build Status

This remark plugin takes markdown with yaml frontmatter and parses the yaml into an object.

Usage

const unified = require('unified')
const markdown = require('remark-parse')
const frontmatter = require('remark-frontmatter')
const parseFrontmatter = require('remark-parse-yaml');

let processor = unified()
    .use(markdown)
    .use(frontmatter)
    .use(parseFrontmatter)

When the processor is run, yaml nodes will now have an additional key, parsedValue, attached to its data key.

Say that we have this markdown string:

---
metadata: this is metadata
tags:
    - one
    - two
---

# Heading 

When parsed, this will produce a yaml node with a data object that looks like this:

data: {
    parsedValue: {
        metadata: "this is metadata",
        tags: ["one", "two"]
    }
}

remark-parse-yaml's People

Contributors

danburzo avatar kachkaev avatar landakram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

blizzardzheng

remark-parse-yaml's Issues

Is `babel-polyfill` necesary for production?

It's included in dependencies inside package.json and also included int the npm release. Is it really necesary?

With it, the library should become a third of the current size when published.

remark@next (13)

Hi!

remark is switching to a new parser (and compiler) internally (micromark, remarkjs/remark#536), which will break this plugin.
The handling of frontmatter is done by remark-frontmatter. It seems an approach here to use part of that for parsing, but use a custom compiler extension, is a good approach? Feel free to ask me questions!

[DEP0148] DeprecationWarning

Although everything works, I'm getting this warning in my console:

[DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at ../node_modules/yaml/package.json.
Update this package.json to use a subpath pattern like "./*".

Pass options to load

Hi, I want to use the FAILSAFE_SCHEMA and it should be able to pass it at an option to the load function. But options are not passed to it. I think that should be the case, or is there any other way to use a different schema?

js-yaml dependency update

Hi,

js-yaml has fixed some security vulnerabilities and it's recommended to use version 3.13.1 at this point. Could you please update your dependencies?

cheers,
M.

Adding messages?

Hey @landakram! WDYT of adding messages to the virtual file in case if the yaml fails to parse? These could go to a linter, for instance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.