Coder Social home page Coder Social logo

the-alchemists-of-arland / gray-matter-rs Goto Github PK

View Code? Open in Web Editor NEW
32.0 2.0 1.0 150 KB

A tool for easily extracting front matter out of a string. It is a fast Rust implementation of gray-matter. Parses YAML, JSON, TOML and support for custom parsers. Use it and let me know by giving it a star!

Home Page: https://docs.rs/gray_matter

License: MIT License

Rust 100.00%
markdown matter yaml data parse rust frontmatter front-matter front-matter-parsers gray-matter

gray-matter-rs's People

Stargazers

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

Watchers

 avatar  avatar

Forkers

vjousse

gray-matter-rs's Issues

Optimize parser for performance

As mentioned in #14, there are likely a lot of things that can be done to improve the performance of our parser - as I was not very proficient in Rust when initially writing it. This issue can be used for tracking advances done in that regard.

Implement `Deserializer` for `Pod`

While investigating #3, I realised that we don't really have a need for the polyglot datatype Pod. Since we nonetheless coerce it into a serde_json::Value upon deserializing, Pod can easily be replaced by Value - essentially skipping a conversion step.

This would increase performance (probably not by much, but every nanosecond counts) and drastically reduce code complexity.

Changing this would introduce an API change, so I don't see the rush to do it, but I'm leaving this issue here for whenever we deem it fit to implement.

Handle misplaced `---`

Currently, it will panic at src/matter.rs:115:34 when you have something like

---
---
---

My suggested solution is to only parse the first two --- then include the succeeding to content

Content with leading and trailing whitespace trimmed

---
key: "Value"
---
    This is my content

gets parsed to

ParsedEntity {
    content: "This is my content"
}

Maybe introducing a configuration field for Matter to allow to set whether whitespace gets trimmed or not. Can be true by default for backwards compatibility.

A simple change to this line is not sufficient enough as the content then contains a leading newline:

parsed_entity.content = acc.trim().to_string();

\n    This is my content

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.