Skip to content

Commit 5cb6480

Browse files
committed
Demo
1 parent ca32b96 commit 5cb6480

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

FoodSuggestionCore.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,21 @@ export class FoodSuggestionCore {
229229
* @returns true if it's a nutrition keyword or measure keyword, false otherwise
230230
*/
231231
isNutritionKeyword(suggestion: string): boolean {
232-
// Check if the suggestion ends with a nutrition or measure keyword
233-
return (
234-
this.nutritionKeywords.some(keyword => suggestion.endsWith(keyword)) ||
235-
this.measureKeywords.some(keyword => suggestion.endsWith(keyword))
236-
);
232+
// Check if the suggestion is exactly a nutrition or measure keyword
233+
// or ends with a number followed by a keyword (e.g., "100g", "50kcal")
234+
if (this.nutritionKeywords.includes(suggestion) || this.measureKeywords.includes(suggestion)) {
235+
return true;
236+
}
237+
238+
// Check if it matches the pattern: number + keyword (e.g., "100g", "50kcal")
239+
const numberKeywordRegex = /\d+([a-z]+)$/;
240+
const match = suggestion.match(numberKeywordRegex);
241+
if (match) {
242+
const keyword = match[1];
243+
return this.nutritionKeywords.includes(keyword) || this.measureKeywords.includes(keyword);
244+
}
245+
246+
return false;
237247
}
238248

239249
/**

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
Food Tracker <img src="logo.svg" alt="Logo" height="24" style="vertical-align: middle;"/>
33
</h1>
44

5-
65
[![Build status](https://github.com/forketyfork/obsidian-food-tracker/actions/workflows/build.yml/badge.svg)](https://github.com/forketyfork/obsidian-food-tracker/actions/workflows/build.yml)
76

87
An Obsidian plugin to track your food intake (calories, macronutrients) and nutritional information with real-time nutrition totals, intelligent food suggestions, and flexible entry methods including both database-driven and inline nutrition tracking.
98

9+
## Demo
10+
11+
![Demo of Food Tracker](assets/demo.gif)
12+
1013
## Features
1114

1215
### 🍎 Food Database Management

demo.gif

1.88 MB
Loading

0 commit comments

Comments
 (0)