From d71f977a55aab9a770d43e40773bce88bf128415 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Sat, 20 Feb 2021 18:06:20 -0500 Subject: [PATCH] Revert "Remove hack in Timestamp parser now that 'remark-breaks' has addressed the original problem." This reverts commit 02792b8f0c24eea2dad71a55f40c29f5613ae3c2. --- ui/util/remark-timestamp.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/util/remark-timestamp.js b/ui/util/remark-timestamp.js index 030940e50..9eabc7812 100644 --- a/ui/util/remark-timestamp.js +++ b/ui/util/remark-timestamp.js @@ -30,6 +30,13 @@ function findNextTimestamp(value, fromIndex, strictlyFromIndex) { } } + if (fromIndex > 0 && fromIndex >= match.index && fromIndex < match.index + match[0].length) { + // Skip previously-rejected word, preventing "62:01" from being tokenized as "2:01", for example. + // This assumes that a non-zero 'fromIndex' means that a previous lookup has failed. + begin = match.index + match[0].length; + continue; + } + // Exclude trailing colons to allow "0:12: Start of section", for example. const str = match[0].replace(/:+$/, ''); @@ -77,7 +84,7 @@ function locateTimestamp(value, fromIndex) { } // Generate 'timestamp' markdown node -const createTimestampNode = (text) => ({ +const createTimestampNode = text => ({ type: TIMESTAMP_NODE_TYPE, value: text, children: [{ type: 'text', value: text }], @@ -138,7 +145,7 @@ const transformer = (node, index, parent) => { } }; -const transform = (tree) => { +const transform = tree => { visit(tree, [TIMESTAMP_NODE_TYPE], transformer); };