Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
markdown formatting does nothing now
  • Loading branch information
bytbox committed Aug 22, 2010
1 parent 53da68a commit 0dbd307
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Makefile.deps
@@ -1,7 +1,8 @@
# external packages: time path opts log os template fmt io/ioutil strings http mime
# external packages: os exec time path opts log strings template fmt io/ioutil http mime
markdown.a: markdown.go
compile.a: compile.go data.a
data.a: data.go
input.a: input.go data.a
input.a: input.go markdown.a data.a
serve.a: serve.go data.a
main: main.${O}
main.${O}: main.go compile.a data.a input.a serve.a
3 changes: 2 additions & 1 deletion input.go
Expand Up @@ -10,6 +10,7 @@ import (
"template"

. "./data"
markdown "./markdown"
)

func readDir(dirname string) (ret []*os.FileInfo) {
Expand Down Expand Up @@ -72,7 +73,7 @@ func ReadPost(content string, path string) *Post {
groups := strings.Split(content, "\n\n", 2)
metalines := strings.Split(groups[0], "\n", -1)
post := &Post{}
post.Content = groups[1]
post.Content, _ = markdown.Format(groups[1])
post.Title = metalines[0]
post.Meta = make(map[string]string)
for _, line := range metalines[1:] {
Expand Down
25 changes: 24 additions & 1 deletion markdown.go
@@ -1,7 +1,30 @@
package markdown

import (
"exec"
"os"
)

// Format takes a markdown-formatted string and returns an equivalent
// HTML-formatted string.
func Format(md string) (html string) {
func Format(md string) (html string, err os.Error) {
cmdName, err := exec.LookPath("markdown")
if err != nil {
return
}
cmd, err := exec.Run(
cmdName,
[]string{},
os.Environ(),
".",
exec.Pipe,
exec.Pipe,
exec.PassThrough,
)
if err != nil {
return
}
cmd.Stdin.Close()
_, err = cmd.Wait(0)
return
}

0 comments on commit 0dbd307

Please sign in to comment.