Commit 81725517 authored by Tim Hockin's avatar Tim Hockin

Fix the munger for code blocks - ticks at start of line

parent 715f2c48
...@@ -16,9 +16,7 @@ limitations under the License. ...@@ -16,9 +16,7 @@ limitations under the License.
package main package main
import ( import "bytes"
"bytes"
)
// Blocks of ``` need to have blank lines on both sides or they don't look // Blocks of ``` need to have blank lines on both sides or they don't look
// right in HTML. // right in HTML.
......
...@@ -23,13 +23,6 @@ import ( ...@@ -23,13 +23,6 @@ import (
"strings" "strings"
) )
var (
// Finds all preformatted block start/stops.
preformatRE = regexp.MustCompile("^[\\s]*```.*")
notPreformatRE = regexp.MustCompile("^[\\s]*```.*```.*")
preformatEndRE = regexp.MustCompile(".*```.*")
)
// Splits a document up into a slice of lines. // Splits a document up into a slice of lines.
func splitLines(document []byte) []string { func splitLines(document []byte) []string {
lines := strings.Split(string(document), "\n") lines := strings.Split(string(document), "\n")
...@@ -141,6 +134,12 @@ type fileBlock struct { ...@@ -141,6 +134,12 @@ type fileBlock struct {
type fileBlocks []fileBlock type fileBlocks []fileBlock
var (
// Finds all preformatted block start/stops.
preformatRE = regexp.MustCompile("^\\s*```")
notPreformatRE = regexp.MustCompile("^\\s*```.*```")
)
func splitByPreformatted(input []byte) fileBlocks { func splitByPreformatted(input []byte) fileBlocks {
f := fileBlocks{} f := fileBlocks{}
...@@ -161,7 +160,7 @@ func splitByPreformatted(input []byte) fileBlocks { ...@@ -161,7 +160,7 @@ func splitByPreformatted(input []byte) fileBlocks {
cur = append(cur, line...) cur = append(cur, line...)
} else { } else {
cur = append(cur, line...) cur = append(cur, line...)
if preformatEndRE.Match(line) { if preformatRE.Match(line) {
if len(cur) > 0 { if len(cur) > 0 {
f = append(f, fileBlock{true, cur}) f = append(f, fileBlock{true, cur})
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment