npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-markdown-reloaded

v0.2.4

Published

Express middleware for rendering markdown files

Downloads

19

Readme

express-markdown-reloaded

NPM NPM

npm version npm license npm download npm download Package Quality Inline docs star this repo fork this repo david dependency david devDependency david optionalDependency david peerDependency npms score Known Vulnerabilities Build Status

Express middleware for rendering markdown files

It looks for URLs ending in ".md" or ".markdown", example: http://mysite.com/README.md

supports:

  • camel case path routing
  • highlighting (client and/or server side)
  • line numbers
  • marked options
  • templates

Render View with marked.js Editor View of EpicEditor Preview View of EpicEditor

Installation

npm install express-markdown-reloaded --save

or

git clone https://github.com/HansHammel/express-markdown-reloaded.git
cd express-markdown-reloaded
npm install

cd example
npm install
npm start

or

npm install "git+https://[email protected]/HansHammel/express-markdown-reloaded.git" --save

Usage

var expressmarkdown = require('express-markdown-reloaded');

//optional
var highlightjs = require('highlight.js');

// optional
// set view engine
app.set('views', path.join(__dirname, 'views'));
// set .ejs as the default extension
app.set('view engine', 'ejs');

// !!!IMPORTANT: place this before static or similar middleware
app.use('/docs',expressmarkdown({

    // directory where markdown files are stored
    // required
    directory: path.join(__dirname,'/docs'),

    // case sensitive/ camel case routing, defaults to lower case
    // optional
    // app.get('case sensitive routing') -> use express settings
    caseSensitive: app.get('case sensitive routing'),

    // view to use for rendering markdown files with a view engine
    // e.g with an ejs template -> full html page
    // optional
    // default is undefined, no view -> raw html content
    view: 'markdown',

    // include raw text in hidden div
    includerawtext: true,

    // load epic editor, for use with markdown_epiceditor.ejs
    loadepiceditor: true,

    //optional
    // options for marked (see [https://github.com/chjj/marked](https://github.com/chjj/marked))
    // tip: skip the server side highlighting function and use markdown_advanced.ejs with client
    // side code highlighting and line numbers !!!
    marked: {
        renderer: new marked.Renderer(),
        gfm: true,
        tables: true,
        breaks: false,
        pedantic: false,
        sanitize: true,
        smartLists: true,
        smartypants: false,
        highlight: function (code) {
            return highlightjs.highlightAuto(code).value;
        }
    },

    // variable passed in the context when rendering with a view engine
    // optional
    // e.g a title, js- and css- script may be passed in, and, raw css
    // and/or js can be executed, depending on your template (see markdown.ejs)
    context: {
        stylesheeturl: 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.0/styles/googlecode.min.css',
        styleraw: '',
        title: 'Markdown',
        //script: 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.0/highlight.min.js',
        jsraw: '',
        jsscripturl: ''
    }

}));

// now the static middleware
app.use('/docs',express.static(path.join(__dirname,'docs'), { maxAge: 0 }));

// optional
// and maybe we want to list the files
app.use('/docs',express.directory(path.join(__dirname,'docs'), { icons:true }));

sample ejs template for your view directory (markdown.ejs)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title><%= title %></title>
        <link rel="stylesheet" href='<%= stylesheeturl %>'>
        <style>
            <%- styleraw %>
        </style>
    </head>
    <body>
        <div class="container">
            <%- content %>
        </div>
    <script defer="defer" type="text/javascript" src='<%= jsscripturl %>'></script>
        <script defer="defer" ><%= jsraw %></script>
    </body>
</html>

Known issues

  • none

Contribution

if you would like to help improving this module, please:

  • write tests
  • help debugging/ solving the known issues
  • send bug fixes/ pull request
  • if you use this module, provide a link for reference

Changelog