gerar444 commited on
Commit
373c5ab
·
verified ·
1 Parent(s): f5a69a8

parseYaml: strip inline comments

Browse files
Files changed (1) hide show
  1. index.html +6 -1
index.html CHANGED
@@ -113,7 +113,12 @@ function parseYaml(txt) {
113
  const o = {};
114
  for (const line of txt.split("\n")) {
115
  const m = line.match(/^([a-zA-Z_]+):\s*(.*)$/);
116
- if (m) { let v = m[2].trim().replace(/^["']|["']$/g, ""); if (v) o[m[1]] = v; }
 
 
 
 
 
117
  }
118
  return o;
119
  }
 
113
  const o = {};
114
  for (const line of txt.split("\n")) {
115
  const m = line.match(/^([a-zA-Z_]+):\s*(.*)$/);
116
+ if (!m) continue;
117
+ let v = m[2].trim();
118
+ // strip an inline comment that isn't inside quotes
119
+ if (!/^["']/.test(v)) v = v.replace(/\s+#.*$/, "").trim();
120
+ v = v.replace(/^["']|["']$/g, "");
121
+ if (v) o[m[1]] = v;
122
  }
123
  return o;
124
  }