Giter Site home page Giter Site logo

sundown-ffi's Introduction

sundown-ffi

A LuaJIT interface to the Sundown library (a Markdown implementation)

Installation

torch-rocks install https://raw.github.com/andresy/sundown-ffi/master/rocks/sundown-scm-1.rockspec

Usage

HTML

To render into HTML, the easiest is to use the provided renderHTML() function (aliased to render()), which interfaces Sundown renderer with Houdini HTML default renderer.

local sundown = require 'sundown'

local html = sundow.render[[
sundown-ffi
===========

A LuaJIT interface to the Sundown library (a Markdown implementation)

# Installation #

torch-rocks install https://raw.github.com/andresy/sundown-ffi/master/rocks/sundown-scm-1.rockspec
]]

You can equivalently call render() in sundown.html:

local html = require 'sundown.html'
html.render[[
...
]]

ASCII Markdown Pretty Print

We also provide an extra renderer renderASCII() which outputs pretty colored ASCII for Markdown pages.

local sundown = require 'sundown'
local text = sundown.renderASCII[[
sundown-ffi
===========

A LuaJIT interface to the Sundown library (a Markdown implementation)

# Installation #

torch-rocks install https://raw.github.com/andresy/sundown-ffi/master/rocks/sundown-scm-1.rockspec
]]

You can equivalently call render() in sundown.ascii:

local ascii = require 'sundown.ascii'
ascii.render[[
...
]]

Styles and Colors

renderASCII(text[, style]) takes an optional style argument, which defines the printing style of each Markdown element. The default style is the following:

local color_style = {
   maxlsz = 80,
   none = c.none,
   h1 = c.Magenta,
   h2 = c.Red,
   h3 = c.Blue,
   h4 = c.Cyan,
   h5 = c.Green,
   h6 = c.Yellow,
   blockquote = '',
   hrule = c.Black,
   link = c.green,
   linkcontent = c.Green,
   code = c.cyan,
   emph = c.Black,
   doubleemph = c.Red,
   tripleemph = c.Magenta,
   strikethrough = c._white,
   header = c.White,
   footer = c.White,
   image = c.yellow,
   ulist = c.magenta,
   olist = c.magenta,
   tableheader = c.magenta,
   superscript = '^'
}

Where colors are ASCII codes defined with:

local c = {
   none = '\27[0m',
   black = '\27[0;30m',
   red = '\27[0;31m',
   green = '\27[0;32m',
   yellow = '\27[0;33m',
   blue = '\27[0;34m',
   magenta = '\27[0;35m',
   cyan = '\27[0;36m',
   white = '\27[0;37m',
   Black = '\27[1;30m',
   Red = '\27[1;31m',
   Green = '\27[1;32m',
   Yellow = '\27[1;33m',
   Blue = '\27[1;34m',
   Magenta = '\27[1;35m',
   Cyan = '\27[1;36m',
   White = '\27[1;37m',
   _black = '\27[40m',
   _red = '\27[41m',
   _green = '\27[42m',
   _yellow = '\27[43m',
   _blue = '\27[44m',
   _magenta = '\27[45m',
   _cyan = '\27[46m',
   _white = '\27[47m'
}

You can redefine your own if interested. You can also turn color on/off with the following:

local ascii = require 'sundown.ascii'

ascii.bw() -- black and white output
ascii.render[[
...
]]

ascii.color() -- colored output
ascii.render[[
...
]]

Advanced usage

All functions from the library sundown and houdini are accessible through sundown.C.func where func is the function of interest.

See the Sundown library page for more details.

Note that Houdini C function and structure names are prefixed here with sd_html_ (e.g. sd_html_renderer). Sundown C function and structure names are prefixed with sd_ (e.g. sd_markdown_render).

See sdcdefs.lua and htmlcdefs.lua for what is actually available.

sundown-ffi's People

Contributors

andresy avatar soumith avatar samehkhamis avatar

Watchers

Linus Unnebäck avatar 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.