Skip to content

Commit

Permalink
Merge branch 'fix_1.10.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrochlore committed Feb 23, 2022
2 parents 42af0fe + c07e237 commit 22979f1
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 22 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Version 1.10.7
Version 1.10.8
- Fixed startDat/endDate misread as a relative date

Version 1.10.9
- Replace tab characters by spaces
- Accept more unicode characters in dvField
- Allow emojis in the folder path
- Fixed bugs

## !!! Breaking Changes !!!

From version 1.9.0, template variables, e.g. '{{sum}}', are deprecated. Instead, Tracker provide operators (+, -, *, /, %) and functions (dataset(), sum(), maxStreak(), ......etc) to help us do data processing. For users having code blocks from previous version, please replace '{{sum}}' by '{{sum()}}' or '{{sum(1)}}' by '{{sum(dataset(1))}}'. More information about the new expressions could be found [here](https://github.com/pyrochlore/obsidian-tracker/blob/master/docs/Expressions.md).
Expand Down
7 changes: 3 additions & 4 deletions docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ List of all examples
- [Bloodpressure Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/BloodPressureTracker.md)
- [Error Messages](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/ErrorMessages.md)
- [Finance Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/FinanceTracker.md)
- [Habit Trakcer](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/HabitTracker.md)
- [Mood Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/MoodTracker.md)
- [Habit Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/HabitTracker.md)
- [Star Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/StarTracker.md)
- [Bar Chart](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestBarChart.md)
- [Axis Interval and Format](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestAxisIntervalAndFormat.md)
Expand All @@ -59,11 +58,11 @@ List of all examples
- [Multiple Targets / Multiple Values](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestMultipleTargetsMultipleValues.md)
- [Pie Chart](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestPieChart.md)
- [Scaling and Positioning](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestScalingAndPositioning.md)
- [Specified Files](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestSpecifiedFiles.md))
- [Specified Files](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestSpecifiedFiles.md)
- [Summary](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestSummary.md)
- [Table](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestTable.md)
- [Task](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestTask.md)
- [Text-value Map](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestTextValueMap.md)
- [Text-value Map/Mood Tracker](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestTextValueMap.md)
- [Time Values](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestTimeValues.md)
- [Word Counting](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestWordCounting.md)
- [X Dataset](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestXDataset.md)
Expand Down
6 changes: 6 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## v1.10.9
- Replace tab characters by spaces
- Accept more unicode characters in dvField
- Allow emojis in the folder path
- Fixed bugs

## v1.10.8
- Fixed startDat/endDate misread as a relative date

Expand Down
4 changes: 2 additions & 2 deletions examples/TestCalendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ month:
selectedRingColor: steelblue
circleColorByValue: true
showSelectedValue: true
initMonth: 2021-09
initMonth: 2021-09
```

Specify the initial month by relative date
Expand All @@ -109,7 +109,7 @@ month:
selectedRingColor: steelblue
circleColorByValue: true
showSelectedValue: true
initMonth: -1M
initMonth: -1M
```

## Multiple targets
Expand Down
2 changes: 1 addition & 1 deletion examples/TestCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ folder: /
startDate:
endDate:
summary:
template: "Average value of tagName is {{average}}"
template: "Average value of tagName is {{average()}}"
style: "color:white;"
```
4 changes: 2 additions & 2 deletions examples/TestExpression.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ folder: /diary
startDate: 2021-01-01
endDate: 2021-01-03
summary:
template: 'Maximum value: {{max() / 2::i}} <-- should be 48 / 2'
template: 'Maximum value: {{max() - 2::i}} <-- should be 48 - 2'
```

Dataset \* number --> Dataset
Expand All @@ -61,7 +61,7 @@ folder: /diary
startDate: 2021-01-01
endDate: 2021-01-03
summary:
template: 'Maximum value: {{max() /2::i}} <-- should be 48 / 2'
template: 'Maximum value: {{max() / 2::i}} <-- should be 48 / 2'
```

Dataset % number --> Dataset
Expand Down
33 changes: 33 additions & 0 deletions examples/TestTabCharacters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Test Tab Characters

Tab characters will be replaced by numbers of spaces according to the tabSize defined in your editor settings

## Single Tab
``` tracker
searchType: tag
searchTarget: exercise-pushup
folder: diary
endDate: 2021-01-31
line:
title: PushUp
yAxisLabel: Count
lineColor: "#d65d0e"
```

## Multiple Tabs

``` tracker
searchType: tag
searchTarget: exercise-pushup
folder: diary
endDate: 2021-01-31
line:
title: PushUp
yAxisLabel: Count
lineColor: "#d65d0e"
```





2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-tracker",
"name": "Tracker",
"version": "1.10.8",
"version": "1.10.9",
"minAppVersion": "0.9.12",
"description": "A plugin tracks occurrences and numbers in your notes",
"author": "pyrochlore",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-tracker",
"version": "1.10.8",
"version": "1.10.9",
"description": "A plugin tracks occurrences and numbers in your notes",
"main": "main.js",
"scripts": {
Expand Down
11 changes: 10 additions & 1 deletion src/collecting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import {
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 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;

// fileBaseName is a string contains dateFormat only
export function getDateFromFilename(
file: TFile,
Expand Down Expand Up @@ -788,7 +795,9 @@ export function collectDataFromDvField(
let strRegex =
"(^| |\\t)\\*{0,2}" +
dvTarget +
"\\*{0,2}(::[ |\\t]*(?<value>[\\d\\.\\/\\-\\w,@; \\t:]*))(\\r\\?\\n|\\r|$)";
"\\*{0,2}(::[ |\\t]*(?<value>[\\d\\.\\/\\-,@; \\t:" +
WordCharacters +
"]*))(\\r\\?\\n|\\r|$)";
// console.log(strRegex);

return extractDataUsingRegexWithMultipleValues(
Expand Down
13 changes: 13 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ declare global {
}
}

declare module 'obsidian' {
interface Vault {
getConfig(prop: string): any;
}
}

export default class Tracker extends Plugin {
settings: TrackerSettings;

Expand Down Expand Up @@ -259,6 +265,13 @@ export default class Tracker extends Plugin {
const canvas = document.createElement("div");

let yamlText = source.trim();

// Replace all tabs by spaces
let tabSize = this.app.vault.getConfig("tabSize");
let spaces = Array(tabSize).fill(" ").join("");
yamlText = yamlText.replace(/\t/gm, spaces);

// Get render info
let retRenderInfo = getRenderInfoFromYaml(yamlText, this);
if (typeof retRenderInfo === "string") {
return this.renderErrorMessage(retRenderInfo, canvas, el);
Expand Down
15 changes: 7 additions & 8 deletions src/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ export function getRenderInfoFromYaml(
): RenderInfo | string {
let yaml;
try {
// console.log(yamlText);
yaml = parseYaml(yamlText);
} catch (err) {
let errorMessage = "Error parsing YAML";
Expand Down Expand Up @@ -1191,13 +1192,11 @@ export function getRenderInfoFromYaml(
}

// Root folder to search
if (typeof yaml.folder === "string") {
if (yaml.folder === "") {
renderInfo.folder = plugin.settings.folder;
} else {
renderInfo.folder = yaml.folder;
}
} else {
renderInfo.folder = getStringFromInput(
yaml?.folder,
plugin.settings.folder
);
if (renderInfo.folder.trim() === "") {
renderInfo.folder = plugin.settings.folder;
}
// console.log("renderInfo folder: " + renderInfo.folder);
Expand Down Expand Up @@ -2175,7 +2174,7 @@ export function getRenderInfoFromYaml(

// todayRingColor
month.todayRingColor = getStringFromInput(
yamlMonth.todayRingColor,
yamlMonth?.todayRingColor,
month.todayRingColor
);
// console.log(month.todayRingColor);
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class TrackerSettingTab extends PluginSettingTab {
new Setting(containerEl)
.setName("Default date format")
.setDesc(
"This format is used to parse the date in your diary title.\nYou can also override it using 'date-format' argument in the tracker codeblock."
"This format is used to parse the date in your diary title.\nYou can also override it using 'dateFormat' argument in the tracker codeblock."
)
.addText((text) =>
text
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"1.10.5": "0.9.12",
"1.10.6": "0.9.12",
"1.10.7": "0.9.12",
"1.10.8": "0.9.12"
"1.10.8": "0.9.12",
"1.10.9": "0.9.12"
}

0 comments on commit 22979f1

Please sign in to comment.