Giter VIP home page Giter VIP logo

meta-marked's Introduction

meta-marked

The marked markdown processor for Node.js with a simple metadata system added on.

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 two properties: meta, which contains the metadata object, and html, which contains the parsed HTML.
  • metaMarked.noMeta is a reference to the marked function, so it can be used to avoid parsing metadata.

The metadata system used here is based on MultiMarkdown. It consists of key: value pairs at the top of the document, followed by a blank line. A line starting with whitespace is treated as a list item for the previous key. For example, running metaMarked(...) on this text:

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

##Header
Regular text and stuff goes here.

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"
}

Note that only string->string and non-nested string->array pairs are supported. Any whitespace before and after the colon and at end of the line is ignored.


Licensed under the MIT License. © 2013 j201

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.