Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/markdir
/markdir.exe

10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

BUILD_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/')
BUILD_TIMESTAMP := $(shell date -u '+%Y-%m-%d %H:%M:%SZ')
LDFLAGS := -X "main.BuildVersion=$(BUILD_VERSION)" -X "main.BuildTime=$(BUILD_TIMESTAMP)"

.SILENT:

.PHONY: install
install:
go install -ldflags '$(LDFLAGS)'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ to use read, write, and idle timeouts. As those appeared in net/http in Go
Release History
===============

* v1.0.3: update to blackfriday v2, add -v to display version
* v1.0.2: Internal changes as suggested by Reddit.
* v1.0.1: Internal rename to make this lint-clean by my gometalinter standards.
* v1.0: Initial release.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module markdir

go 1.15

require github.com/russross/blackfriday v1.6.0
require github.com/russross/blackfriday/v2 v2.1.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
18 changes: 16 additions & 2 deletions markdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@ package main
import (
"errors"
"flag"
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
"os"
"runtime"
"runtime/debug"
"strings"

"github.com/russross/blackfriday"
"github.com/russross/blackfriday/v2"
)

// build variables set via -ldflags in Makefile
var BuildVersion string = "<unknown>"
var BuildTime string = "<unknown>"

var bind = flag.String("bind", "127.0.0.1:19000", "port to run the server on")
var showVersion = flag.Bool("v",false, "display version information and exit")

func main() {
flag.Parse()

if *showVersion {
info, _ := debug.ReadBuildInfo()
fmt.Printf("%s %s (%s %s built %s)\n", info.Main.Path, BuildVersion, runtime.GOOS, runtime.GOARCH, BuildTime)
os.Exit(0)
}

httpdir := http.Dir(".")
handler := renderer{httpdir, http.FileServer(httpdir)}

Expand Down Expand Up @@ -64,7 +78,7 @@ func (r renderer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return
}

output := blackfriday.MarkdownCommon(input)
output := blackfriday.Run(input)

rw.Header().Set("Content-Type", "text/html; charset=utf-8")

Expand Down