MCPcopy
hub / github.com/writefreely/writefreely / formatContent

Method formatContent

postrender.go:76–91  ·  view source on GitHub ↗
(cfg *config.Config, c *Collection, isOwner bool, isPostPage bool)

Source from the content-addressed store, hash-verified

74}
75
76func (p *Post) formatContent(cfg *config.Config, c *Collection, isOwner bool, isPostPage bool) {
77 baseURL := c.CanonicalURL()
78 // TODO: redundant
79 if !isSingleUser {
80 baseURL = "/" + c.Alias + "/"
81 }
82
83 p.handlePremiumContent(c, isOwner, isPostPage, cfg)
84 p.Content = strings.Replace(p.Content, "&lt;!--paid-->", "<!--paid-->", 1)
85
86 p.HTMLTitle = template.HTML(applyBasicMarkdown([]byte(p.Title.String)))
87 p.HTMLContent = template.HTML(applyMarkdown([]byte(p.Content), baseURL, cfg))
88 if exc := strings.Index(string(p.Content), "<!--more-->"); exc > -1 {
89 p.HTMLExcerpt = template.HTML(applyMarkdown([]byte(p.Content[:exc]), baseURL, cfg))
90 }
91}
92
93func (p *PublicPost) formatContent(cfg *config.Config, isOwner bool, isPostPage bool) {
94 p.Post.formatContent(cfg, &p.Collection.Collection, isOwner, isPostPage)

Callers 6

GetPostsMethod · 0.95
GetPostsTaggedMethod · 0.95
GetLangPostsMethod · 0.95
viewCollectionPostFunction · 0.45
formatContentMethod · 0.45
emailPostFunction · 0.45

Calls 4

handlePremiumContentMethod · 0.95
applyBasicMarkdownFunction · 0.85
applyMarkdownFunction · 0.85
CanonicalURLMethod · 0.45

Tested by

no test coverage detected