5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-26 06:15:40 +00:00
matterbridge/vendor/gitlab.com/golang-commonmark/markdown
Wim 04567c765e
Add support for markdown to HTML conversion (matrix). Closes #663 (#670)
This uses our own gomatrix lib with the SendHTML function which
adds HTML to formatted_body in matrix.
golang-commonmark is used to convert markdown into valid HTML.
2019-01-06 22:25:19 +01:00
..
.gitlab-ci.yml Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
align.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
AUTHORS Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
autolink.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
backticks.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
balance_pairs.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
blockquote.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
code.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
emphasis.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
entity.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
escape.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
fence.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
fuzz.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
heading.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
helpers.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
hr.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
html_block.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
html_inline.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
image.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
inline.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
lheading.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
LICENSE Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
link.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
linkify.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
list.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
markdown.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
newline.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
options.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
paragraph.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
parser_block.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
parser_inline.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
plugins.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
README.md Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
reference.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
render.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
replacements.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
smartquotes.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
state_block.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
state_core.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
state_inline.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
strikethrough.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
table_fsm.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
table.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
text_collapse.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
text.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
token.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
urlschema.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
util.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00
writer.go Add support for markdown to HTML conversion (matrix). Closes #663 (#670) 2019-01-06 22:25:19 +01:00

markdown GoDoc License Pipeline status Coverage report

Package golang-commonmark/markdown provides a CommonMark-compliant markdown parser and renderer, written in Go.

Installation

go get -u gitlab.com/golang-commonmark/markdown

You can also go get mdtool, an example command-line tool:

go get -u gitlab.com/golang-commonmark/mdtool

Standards support

Currently supported CommonMark spec: v0.28.

Extensions

Besides the features required by CommonMark, golang-commonmark/markdown supports:

  • Tables (GFM)
  • Strikethrough (GFM)
  • Autoconverting plain-text URLs to links
  • Typographic replacements (smart quotes and other)

Usage

md := markdown.New(markdown.XHTMLOutput(true))
fmt.Println(md.RenderToString([]byte("Header\n===\nText")))

Check out the source of mdtool for a more complete example.

The following options are currently supported:

Name Type Description Default
HTML bool whether to enable raw HTML false
Tables bool whether to enable GFM tables true
Linkify bool whether to autoconvert plain-text URLs to links true
Typographer bool whether to enable typographic replacements true
Quotes string / []string double + single quote replacement pairs for the typographer “”‘’
MaxNesting int maximum nesting level 20
LangPrefix string CSS language prefix for fenced blocks language-
Breaks bool whether to convert newlines inside paragraphs into <br> false
XHTMLOutput bool whether to output XHTML instead of HTML false

Benchmarks

Rendering spec/spec-0.28.txt on a Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz

BenchmarkRenderSpecNoHTML         100    10254720 ns/op    2998037 B/op    18225 allocs/op
BenchmarkRenderSpec               100    10180241 ns/op    2997307 B/op    18214 allocs/op
BenchmarkRenderSpecBlackFriday    200     7241749 ns/op    2834340 B/op    17101 allocs/op
BenchmarkRenderSpecBlackFriday2   200     7448256 ns/op    2991202 B/op    16705 allocs/op

See also

https://github.com/jgm/CommonMark — the reference CommonMark implementations in C and JavaScript, also contains the latest spec and an online demo.

http://talk.commonmark.org — the CommonMark forum, a good place to join together the efforts of the developers.