-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle punctuation in single word cookware/ingredients (#15)
Add tests for singleword punctation
- Loading branch information
1 parent
d459df0
commit 3e2f98f
Showing
2 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
const metadata = /^>>\s*(?<key>.+?):\s*(?<value>.+)/; | ||
|
||
const multiwordIngredient = /@(?<mIngredientName>[^@#~[]+?){(?<mIngredientQuantity>[^]*?)(?:%(?<mIngredientUnits>[^}]+?))?}/; | ||
const singleWordIngredient = /@(?<sIngredientName>[^\s]+)/; | ||
const multiwordIngredient = /@(?<mIngredientName>[^@#~[]+?)\{(?<mIngredientQuantity>[^]*?)(?:%(?<mIngredientUnits>[^}]+?))?\}/; | ||
const singleWordIngredient = /@(?<sIngredientName>[^\s\t\p{Zs}\p{P}]+)/; | ||
|
||
const multiwordCookware = /#(?<mCookwareName>[^@#~[]+?){(?<mCookwareQuantity>.*?)}/; | ||
const singleWordCookware = /#(?<sCookwareName>[^\s]+)/; | ||
const multiwordCookware = /#(?<mCookwareName>[^@#~[]+?)\{(?<mCookwareQuantity>.*?)\}/; | ||
const singleWordCookware = /#(?<sCookwareName>[^\s\t\p{Zs}\p{P}]+)/; | ||
|
||
const timer = /~(?<timerName>.*?)(?:{(?<timerQuantity>.*?)(?:%(?<timerUnits>.+?))?})/; | ||
const timer = /~(?<timerName>.*?)(?:\{(?<timerQuantity>.*?)(?:%(?<timerUnits>.+?))?\})/; | ||
|
||
export const comment = /--.*/g; | ||
export const blockComment = /\s*\[\-.*?\-\]\s*/g; | ||
|
||
export const shoppingList = /\[(?<name>.+)\]\n(?<items>[^]*?)(?:\n\n|$)/g; | ||
export const tokens = new RegExp([metadata, multiwordIngredient, singleWordIngredient, multiwordCookware, singleWordCookware, timer].map(r => r.source).join('|'), 'g'); | ||
export const tokens = new RegExp([metadata, multiwordIngredient, singleWordIngredient, multiwordCookware, singleWordCookware, timer].map(r => r.source).join('|'), 'gu'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters