mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Fix the munger for code blocks - ticks at start of line
This commit is contained in:
parent
715f2c488f
commit
8172551763
@ -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.
|
||||
|
@ -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})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user