GithubHelp home page GithubHelp logo

matths / meta-marked Goto Github PK

View Code? Open in Web Editor NEW

This project forked from j201/meta-marked

1.0 1.0 0.0 37 KB

[Fork with up to date dependencies of] the 'marked' markdown processor for Node.js with a simple metadata system added on.

JavaScript 100.00%

meta-marked's Introduction

meta-marked

The marked markdown processor for Node.js with support for YAML metadata

Dependency Status

Just a quick extension I needed for processing markdown in Node. Props to Christopher Jeffrey for his excellent markdown processor 'marked'.

The meta-marked function behaves exactly the same as marked, except for the following:

  • Instead of returning a parsed string, meta-marked returns an object with the following properties:
    • meta contains the metadata object or null if metadata isn't found
    • html contains the parsed HTML
    • markdown contains the text of the markdown section of the string
  • metaMarked.noMeta is a reference to the marked function, so it can be used to avoid parsing metadata.

In order to include metadata in a document, insert YAML at the top of the document surrounded by --- and .... Note that if the given string doesn't start with ---, it will not be interpreted as having metadata.

Example

---
Title:   My awesome markdown file
Author:  Me
Scripts:
    - js/doStuff.js
    - js/doMoreStuff.js
...

##Header
Regular text and stuff goes here.

You can also use the approach below, which will result in a very nice data table at the top of your markdown when viewing the file GitHub:

---
Title:   My awesome markdown file
Author:  Me
Scripts:
    - js/doStuff.js
    - js/doMoreStuff.js
---

##Header
Regular text and stuff goes here.

Both of the above will result in the following output:

{
	"meta": {
		"Title": "My awesome markdown file",
		"Author": "Me",
		"Scripts": [
			"js/doStuff.js",
			"js/doMoreStuff.js"
		]
	},
	"html": "<h2>Header</h2>\n<p>Regular text and stuff goes here.</p>\n",
	"markdown": "\n\n##Header\nRegular text and stuff goes here."
}

###Testing

npm test

Licensed under the MIT License. © 2013-2014 j201

meta-marked's People

Contributors

j201 avatar matths avatar sockdrawermoney avatar brettlangdon avatar inolen avatar bripkens avatar tvooo avatar dependabot[bot] avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

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.