mirror of https://github.com/istio/istio.io.git
Support escaped heredocs (#7386)
This commit is contained in:
parent
3554f87c4d
commit
6581b52325
|
@ -54,6 +54,7 @@ HEADER = """#!/bin/bash
|
|||
startsnip = re.compile(r"^(\s*){{< text (syntax=)?\"?(\w+)\"? .*>}}$")
|
||||
snippetid = re.compile(r"snip_id=(\w+)")
|
||||
githubfile = re.compile(r"^([^@]*)(?<![A-Za-z0-9])@([\w\.\-_/]+)@([^@]*)$")
|
||||
heredoc = re.compile(r"<<\s*\\?EOF")
|
||||
sectionhead = re.compile(r"^##+ (.*)$")
|
||||
invalidchar = re.compile(r"[^0-9a-zA-Z_]")
|
||||
|
||||
|
@ -141,7 +142,7 @@ with open(markdown, 'rt', encoding='utf-8') as mdfile:
|
|||
match = githubfile.match(line)
|
||||
if match:
|
||||
line = match.group(1) + match.group(2) + match.group(3)
|
||||
if "<<EOF" in line:
|
||||
if heredoc.search(line):
|
||||
multiline_cmd = True
|
||||
current_snip["script"].append(line)
|
||||
|
||||
|
|
|
@ -207,10 +207,12 @@ function handleCodeBlocks() {
|
|||
if (cl !== "") {
|
||||
let firstLineOfOutput = 0;
|
||||
const lines = code.innerText.split("\n");
|
||||
const heredoc = RegExp(/<<\s*\\?EOF/);
|
||||
let cmd = "";
|
||||
let escape = false;
|
||||
let escapeUntilEOF = false;
|
||||
let tmp = "";
|
||||
|
||||
for (let j = 0; j < lines.length; j++) {
|
||||
const line = lines[j];
|
||||
|
||||
|
@ -225,14 +227,14 @@ function handleCodeBlocks() {
|
|||
|
||||
tmp = line.slice(2);
|
||||
|
||||
if (line.includes("<<EOF")) {
|
||||
if (heredoc.test(line)) {
|
||||
escapeUntilEOF = true;
|
||||
}
|
||||
} else if (escape) {
|
||||
// continuation
|
||||
tmp += "\n" + line;
|
||||
|
||||
if (line.includes("<<EOF")) {
|
||||
if (heredoc.test(line)) {
|
||||
escapeUntilEOF = true;
|
||||
}
|
||||
} else if (escapeUntilEOF) {
|
||||
|
|
Loading…
Reference in New Issue