From 41e8c714d09586e1ddcd38f211e7e12f716b1594 Mon Sep 17 00:00:00 2001 From: laharah Date: Thu, 9 Nov 2023 12:36:52 -0800 Subject: [PATCH 1/2] Add support for in-sentence dvfields --- examples/TestInSentenceFields.md | 15 +++++++++++++++ examples/data/In-Sentence-Fields.md | 9 +++++++++ src/collecting.ts | 22 ++++++++++++++-------- 3 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 examples/TestInSentenceFields.md create mode 100644 examples/data/In-Sentence-Fields.md diff --git a/examples/TestInSentenceFields.md b/examples/TestInSentenceFields.md new file mode 100644 index 0000000..92d460b --- /dev/null +++ b/examples/TestInSentenceFields.md @@ -0,0 +1,15 @@ + +```tracker +searchType: frontmatter, dvField +searchTarget: date, count +xDataset: 0 +folder: "data" +bullet: + title: Total Counts + value: "{{sum()}}" + range: 1,5,10,20 + rangeColor: darkRed, lightBlue, lightGreen, blue + showMarker: true + markerValue: 2 + markerColor: red +``` diff --git a/examples/data/In-Sentence-Fields.md b/examples/data/In-Sentence-Fields.md new file mode 100644 index 0000000..ca1556e --- /dev/null +++ b/examples/data/In-Sentence-Fields.md @@ -0,0 +1,9 @@ +--- +date: 2021-01-05 +--- + +I am [count:: 1] inline +So am (count::2) I +count:: 3 +| count:: 4 | +|count:: 5| \ No newline at end of file diff --git a/src/collecting.ts b/src/collecting.ts index 1f0325a..ab352b6 100644 --- a/src/collecting.ts +++ b/src/collecting.ts @@ -13,11 +13,17 @@ import * as helper from "./helper"; import { Moment } from "moment"; // ref: https://www.rapidtables.com/code/text/unicode-characters.html -const CurrencyCodes = "\u0024\u20AC\u00A3\u00A5\u00A2\u20B9\u20A8\u20B1\u20A9\u0E3F\u20AB\u20AA"; +const CurrencyCodes = + "\u0024\u20AC\u00A3\u00A5\u00A2\u20B9\u20A8\u20B1\u20A9\u0E3F\u20AB\u20AA"; const AlphabetCodes = "\u03B1-\u03C9\u0391-\u03A9"; const IntellectualPropertyCodes = "\u00A9\u00AE\u2117\u2122\u2120"; const CJKCodes = "\u4E00-\u9FFF\u3400-\u4DBF\u3000\u3001-\u303F"; -const WordCharacters = "\\w" + CurrencyCodes + AlphabetCodes + IntellectualPropertyCodes + CJKCodes; +const WordCharacters = + "\\w" + + CurrencyCodes + + AlphabetCodes + + IntellectualPropertyCodes + + CJKCodes; // fileBaseName is a string contains dateFormat only export function getDateFromFilename( @@ -512,9 +518,9 @@ export function collectDataFromFrontmatterKey( // console.log(retParse); if (retParse.value === null) { // Try parsing as a boolean: true means 1, false means 0. - if (deepValue === 'true' || deepValue === 'false') { + if (deepValue === "true" || deepValue === "false") { retParse.type = ValueType.Number; - retParse.value = deepValue === 'true' ? 1 : 0; + retParse.value = deepValue === "true" ? 1 : 0; } } if (retParse.value !== null) { @@ -798,13 +804,13 @@ export function collectDataFromDvField( // Test this in Regex101 // remember '\s' includes new line - // (^| |\t)\*{0,2}dvTarget\*{0,2}(::[ |\t]*(?[\d\.\/\-\w,@; \t:]*))(\r?\n|\r|$) + // (^| |\t|\|)(\[|\()?\*{0,2}dvTarget\*{0,2}(::[ |\t]*(?[\d\.\/\-\w,@; \t:]*)(\]|\))?) let strRegex = - "(^| |\\t)\\*{0,2}" + + String.raw`(^| |\t|\|)(\[|\()?\*{0,2}` + dvTarget + - "\\*{0,2}(::[ |\\t]*(?[\\d\\.\\/\\-,@; \\t:" + + String.raw`\*{0,2}(::[ |\t]*(?[\d\.\/\-\w,@; \t:` + WordCharacters + - "]*))(\\r\\?\\n|\\r|$)"; + String.raw`]*)(\]|\))?)`; // console.log(strRegex); return extractDataUsingRegexWithMultipleValues( From 92a901839586cc4b19f04e183e7be640e54a16e8 Mon Sep 17 00:00:00 2001 From: Joe Constant Date: Thu, 16 Nov 2023 19:01:12 -0700 Subject: [PATCH 2/2] Add support for emoji values --- examples/TestEmoji.md | 20 ++++++++++++++++++++ examples/diary/2023-06-05.md | 1 + examples/diary/2023-06-06.md | 1 + examples/diary/2023-06-07.md | 1 + examples/diary/2023-06-08.md | 1 + src/collecting.ts | 4 ++-- 6 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 examples/TestEmoji.md create mode 100644 examples/diary/2023-06-05.md create mode 100644 examples/diary/2023-06-06.md create mode 100644 examples/diary/2023-06-07.md create mode 100644 examples/diary/2023-06-08.md diff --git a/examples/TestEmoji.md b/examples/TestEmoji.md new file mode 100644 index 0000000..a5c84b6 --- /dev/null +++ b/examples/TestEmoji.md @@ -0,0 +1,20 @@ + +```tracker +searchType: dvfield +searchTarget: Physical +folder: diary +startDate: 2023-06-04 +endDate: 2023-06-11 +textValueMap: + 😀: 5 + 🙂: 4 + 😐: 3 + 🙁: 2 + 😞: 1 +datasetName: 🚹 Physical +line: + lineColor: orange + lineWidth: 3 + showLegend: true + legendPosition: right +``` \ No newline at end of file diff --git a/examples/diary/2023-06-05.md b/examples/diary/2023-06-05.md new file mode 100644 index 0000000..80f84e7 --- /dev/null +++ b/examples/diary/2023-06-05.md @@ -0,0 +1 @@ +Physical:: 😐 \ No newline at end of file diff --git a/examples/diary/2023-06-06.md b/examples/diary/2023-06-06.md new file mode 100644 index 0000000..80f84e7 --- /dev/null +++ b/examples/diary/2023-06-06.md @@ -0,0 +1 @@ +Physical:: 😐 \ No newline at end of file diff --git a/examples/diary/2023-06-07.md b/examples/diary/2023-06-07.md new file mode 100644 index 0000000..6378774 --- /dev/null +++ b/examples/diary/2023-06-07.md @@ -0,0 +1 @@ +Physical:: 😀 \ No newline at end of file diff --git a/examples/diary/2023-06-08.md b/examples/diary/2023-06-08.md new file mode 100644 index 0000000..7074a69 --- /dev/null +++ b/examples/diary/2023-06-08.md @@ -0,0 +1 @@ +Physical:: 😞 \ No newline at end of file diff --git a/src/collecting.ts b/src/collecting.ts index ab352b6..2e7e47a 100644 --- a/src/collecting.ts +++ b/src/collecting.ts @@ -339,7 +339,7 @@ function extractDataUsingRegexWithMultipleValues( ): boolean { // console.log("extractDataUsingRegexWithMultipleValues"); - let regex = new RegExp(strRegex, "gm"); + let regex = new RegExp(strRegex, "gmu"); let match; let measure = 0.0; let extracted = false; @@ -808,7 +808,7 @@ export function collectDataFromDvField( let strRegex = String.raw`(^| |\t|\|)(\[|\()?\*{0,2}` + dvTarget + - String.raw`\*{0,2}(::[ |\t]*(?[\d\.\/\-\w,@; \t:` + + String.raw`\*{0,2}(::[ |\t]*(?[\p{ExtPict}\d\.\/\-\w,@; \t:` + WordCharacters + String.raw`]*)(\]|\))?)`; // console.log(strRegex);