Welcome to mirror list, hosted at ThFree Co, Russian Federation.

README.md - github.com/torch/sundown-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d98afe2521bbb18e3eea6a53b7866895755a51b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
[![Build Status](https://travis-ci.org/torch/sundown-ffi.svg)](https://travis-ci.org/torch/sundown-ffi)

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.

```lua
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`:
```lua
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.

```lua
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`:
```lua
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:
```lua
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:
```lua
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:

```lua
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](https://github.com/vmg/sundown) 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.