From 8172551763d2a54bc5a04bb4bf4cf003bf8cf658 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Fri, 17 Jul 2015 20:51:38 -0700 Subject: [PATCH] Fix the munger for code blocks - ticks at start of line --- cmd/mungedocs/preformatted.go | 4 +--- cmd/mungedocs/util.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/cmd/mungedocs/preformatted.go b/cmd/mungedocs/preformatted.go index bd42f71a5b..515b6e3f2c 100644 --- a/cmd/mungedocs/preformatted.go +++ b/cmd/mungedocs/preformatted.go @@ -16,9 +16,7 @@ limitations under the License. package main -import ( - "bytes" -) +import "bytes" // Blocks of ``` need to have blank lines on both sides or they don't look // right in HTML. diff --git a/cmd/mungedocs/util.go b/cmd/mungedocs/util.go index 1a756dec0a..a5fd2847a4 100644 --- a/cmd/mungedocs/util.go +++ b/cmd/mungedocs/util.go @@ -23,13 +23,6 @@ import ( "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. func splitLines(document []byte) []string { lines := strings.Split(string(document), "\n") @@ -141,6 +134,12 @@ type fileBlock struct { type fileBlocks []fileBlock +var ( + // Finds all preformatted block start/stops. + preformatRE = regexp.MustCompile("^\\s*```") + notPreformatRE = regexp.MustCompile("^\\s*```.*```") +) + func splitByPreformatted(input []byte) fileBlocks { f := fileBlocks{} @@ -161,7 +160,7 @@ func splitByPreformatted(input []byte) fileBlocks { cur = append(cur, line...) } else { cur = append(cur, line...) - if preformatEndRE.Match(line) { + if preformatRE.Match(line) { if len(cur) > 0 { f = append(f, fileBlock{true, cur}) }