type Page struct {
Status string
Images []string
+ RawContent []byte
Content template.HTML
Summary template.HTML
Truncated bool
if err = page.update(meta); err != nil {
return err
}
+
}
+ page.Content = template.HTML(p.Content())
+
+ return nil
+}
+func (page *Page) Convert() error {
switch page.guessMarkupType() {
case "md", "markdown", "mdown":
- page.convertMarkdown(bytes.NewReader(p.Content()))
+ page.convertMarkdown(bytes.NewReader([]byte(page.Content)))
case "rst":
- page.convertRestructuredText(bytes.NewReader(p.Content()))
+ page.convertRestructuredText(bytes.NewReader([]byte(page.Content)))
case "html":
fallthrough
default:
- page.Content = template.HTML(p.Content())
+ page.Content = template.HTML(page.Content)
}
return nil
}
func TestCreateNewPage(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE), "simple.md")
+ p.Convert()
+
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestPageWithDelimiter(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER), "simple.md")
+ p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestPageWithShortCodeInSummary(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SHORTCODE_IN_SUMMARY), "simple.md")
+ p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestPageWithMoreTag(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE), "simple.md")
+ p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestPageWithDate(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_RFC3339_DATE), "simple")
+ p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
func TestWordCount(t *testing.T) {
p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_LONG_CONTENT), "simple.md")
+ p.Convert()
if err != nil {
t.Fatalf("Unable to create a page with frontmatter and body content: %s", err)
}
return
}
s.timerStep("render and write aliases")
- s.ProcessShortcodes()
- s.timerStep("render shortcodes")
if err = s.RenderIndexes(); err != nil {
return
}
page.Tmpl = s.Tmpl
page.Section = file.Section
page.Dir = file.Dir
+
+ // Handling short codes prior to Conversion to HTML
+ page.Content = template.HTML(ShortcodesHandle(string(page.Content), page, s.Tmpl))
+ page.Summary = template.HTML(ShortcodesHandle(string(page.Summary), page, s.Tmpl))
+
+ err = page.Convert()
+ if err != nil {
+ return err
+ }
+
if s.Config.BuildDrafts || !page.Draft {
s.Pages = append(s.Pages, page)
}
TEMPLATE_CONTENT = "{{ .Content }}"
TEMPLATE_DATE = "{{ .Date }}"
INVALID_TEMPLATE_FORMAT_DATE = "{{ .Date.Format time.RFC3339 }}"
- TEMPLATE_WITH_URL_REL = "<a href=\"foobar.jpg\">Going</a>"
- TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>"
+ TEMPLATE_WITH_URL_REL = "<a href=\"foobar.jpg\">Going</a>"
+ TEMPLATE_WITH_URL_ABS = "<a href=\"/foobar.jpg\">Going</a>"
PAGE_URL_SPECIFIED = `---
title: simple template
url: "mycategory/my-whatever-content/"
func TestDegenerateRenderThingMissingTemplate(t *testing.T) {
p, _ := ReadFrom(strings.NewReader(PAGE_SIMPLE_TITLE), "content/a/file.md")
+ p.Convert()
s := new(Site)
s.prepTemplates()
err := s.renderThing(p, "foobar", nil)
for i, test := range tests {
p, err := ReadFrom(strings.NewReader(test.content), "content/a/file.md")
+ p.Convert()
if err != nil {
t.Fatalf("Error parsing buffer: %s", err)
}
Config: Config{Verbose: true, BaseUrl: "http://auth/bub"},
Source: &source.InMemorySource{sources},
}
+
s.initializeSiteInfo()
s.prepTemplates()