mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Merge pull request #3 from tychoish/rst-fix
rst: fixing rst output processing
This commit is contained in:
commit
8403dba3ee
2 changed files with 9 additions and 17 deletions
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
Markup: 'rst'
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
==============
|
|
||||||
This is a Test
|
|
||||||
==============
|
|
||||||
|
|
||||||
|
|
||||||
Really
|
|
||||||
------
|
|
||||||
|
|
||||||
text *here* and **HERE**.
|
|
|
@ -409,9 +409,9 @@ func (page *Page) convertMarkdown(lines []string) {
|
||||||
|
|
||||||
func (page *Page) convertRestructuredText(lines []string) {
|
func (page *Page) convertRestructuredText(lines []string) {
|
||||||
|
|
||||||
page.RawMarkdown = strings.Join(lines, " ")
|
page.RawMarkdown = strings.Join(lines, "\n")
|
||||||
|
|
||||||
cmd := exec.Command("rst2html.py", "--template=/tmp/template.txt")
|
cmd := exec.Command("rst2html.py")
|
||||||
cmd.Stdin = strings.NewReader(page.RawMarkdown)
|
cmd.Stdin = strings.NewReader(page.RawMarkdown)
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
|
@ -419,7 +419,13 @@ func (page *Page) convertRestructuredText(lines []string) {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
content := out.String()
|
rstLines := strings.Split(out.String(), "\n")
|
||||||
|
for i, line := range rstLines {
|
||||||
|
if strings.HasPrefix(line, "<body>") {
|
||||||
|
rstLines = (rstLines[i+1:len(rstLines)-3])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
content := strings.Join(rstLines, "\n")
|
||||||
page.Content = template.HTML(content)
|
page.Content = template.HTML(content)
|
||||||
page.Summary = template.HTML(TruncateWordsToWholeSentence(StripHTML(StripShortcodes(content)), summaryLength))
|
page.Summary = template.HTML(TruncateWordsToWholeSentence(StripHTML(StripShortcodes(content)), summaryLength))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue