Giter Site home page Giter Site logo

punch-markdown-highlight's Introduction

Punch Markdown + Highlight

This is a plugin for Punch, bringing syntax highlighting along Markdown parser.

Installation

npm install punch-markdown-highlight

Usage

Parser

In your config.json:

{
	"plugins": {
		"parsers": {
			".md": "punch-markdown-highlight/parser",
			".markdown": "punch-markdown-highlight/parser"
		}
	}
}

You can then use the three-backticks syntax (GitHub-like), and enjoy syntax highlighting, in all your Markdown contents.

Helper

Whenever you would need to use the same feature in your templates, there is a bundler helper. Add this in your config.json:

{
  "plugins": {
    "helpers": {
      "markdown_highlight": "punch-markdown-highlight/helpers"
    }
  }
}

You'll then be able to use the helper "highlight", this way:

<pre>
{{#highlight}}javascript
alert('hello');
{{/highlight}}
</pre>

As you can't pass arguments to helpers, you'll have to provide the language as first part of the text, followed by a newline.

CSS

Highlighter will only wrap tokens in specific classes, you have to add some CSS to your bundles.

pre {
  border: 1px solid #e0ded3;
  border-radius: 4px;
  margin: 10px 10px 40px 10px;
  padding: 10px;
  background-color: #f0efe8;
  overflow: auto;
  font-size: 14px;
  font-family: Consolas, "Liberation Mono", Courier, monospace;
}

code {
  white-space: pre;
  color: rgba(0,0,0, 1);
  .keyword         { font-weight: bold; color: #6089d4; }
  .string, .regexp { color: green }
  .class, .special { color: #6089d4 }
  .number          { color: red }
  .comment         { color: grey }
}

punch-markdown-highlight's People

Contributors

naholyr avatar

Stargazers

Santiago M. Mola avatar

Watchers

James Cloos avatar  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.