Skip to content

Commit

Permalink
fix(toml-narrator): fix quotes in TOML comments
Browse files Browse the repository at this point in the history
* add replacement for single or double quotes
  • Loading branch information
Yoda-Soda committed Oct 7, 2021
1 parent 8811d4c commit 50992f2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions javascript-modules/toml-narrator/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ module.exports = {
const isVariableComment = /^[a-z0-9\-_\.\s]+=.*?#.+?$/i;
// [some_section] #: Some comment
const isBlockComment = /^\s*?\[.*?#.+?$/i;

const extractComment = /#:([^#]+)$/i;
const extractVariable = /^\s*?([a-z0-9\-_\.]+)\s?=/i;

if (isVariableComment.test(line)) {
const [, comment] = extractComment.exec(line) || [];
const [, variable_name] = extractVariable.exec(line) || [];
const [, variable_name] = extractVariable.replaceAll('"', '/"').replaceAll("'","/'").exec(line) || [];
if (!comment || !variable_name) return line;

return `${variable_name}--bookshop_comment = "${comment.trim()}"\n${line}`
Expand Down

0 comments on commit 50992f2

Please sign in to comment.