github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/documize/section/markdown/markdown.go (about) 1 // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. 2 // 3 // This software (Documize Community Edition) is licensed under 4 // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html 5 // 6 // You can operate outside the AGPL restrictions by purchasing 7 // Documize Enterprise Edition and obtaining a commercial license 8 // by contacting <sales@documize.com>. 9 // 10 // https://documize.com 11 12 package markdown 13 14 import ( 15 "net/http" 16 17 "github.com/documize/blackfriday" 18 "github.com/documize/community/documize/section/provider" 19 ) 20 21 // Provider represents Markdown 22 type Provider struct { 23 } 24 25 // Meta describes us 26 func (*Provider) Meta() provider.TypeMeta { 27 section := provider.TypeMeta{} 28 29 section.ID = "1470bb4a-36c6-4a98-a443-096f5658378b" 30 section.Title = "Markdown" 31 section.Description = "CommonMark based markdown content with preview" 32 section.ContentType = "markdown" 33 section.Order = 9998 34 35 return section 36 } 37 38 // Command stub. 39 func (*Provider) Command(ctx *provider.Context, w http.ResponseWriter, r *http.Request) { 40 provider.WriteEmpty(w) 41 } 42 43 // Render converts markdown data into HTML suitable for browser rendering. 44 func (*Provider) Render(ctx *provider.Context, config, data string) string { 45 result := blackfriday.MarkdownCommon([]byte(data)) 46 47 return string(result) 48 } 49 50 // Refresh just sends back data as-is. 51 func (*Provider) Refresh(ctx *provider.Context, config, data string) string { 52 return data 53 }