Skip to content

Commit

Permalink
Add support for multiline block comments (#25)
Browse files Browse the repository at this point in the history
Thanks!
  • Loading branch information
rveciana authored Sep 26, 2024
1 parent 73f803f commit 9ea85e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const singleWordCookware = /#(?<sCookwareName>[^\s\t\p{Zs}\p{P}]+)/;
const timer = /~(?<timerName>.*?)(?:\{(?<timerQuantity>.*?)(?:%(?<timerUnits>.+?))?\})/;

export const comment = /--.*/g;
export const blockComment = /\s*\[\-.*?\-\]\s*/g;
export const blockComment = /\s*\[\-[\s\S]*?\-\]\s*/g;

export const shoppingList = /\n\s*\[(?<name>.+)\]\n(?<items>[^]*?)(?:\n\n|$)/g;
export const tokens = new RegExp([metadata, multiwordIngredient, singleWordIngredient, multiwordCookware, singleWordCookware, timer].map(r => r.source).join('|'), 'gu');
20 changes: 20 additions & 0 deletions tests/custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ tests:
name: "pepper"
metadata: []

testMultilineBlockComments:
source: |
Add the @bacon [- make sure
not to burn -] and cook for ~{2%minutes}
result:
steps:
- - type: text
value: "Add the "
- type: ingredient
quantity: "some"
units: ""
name: "bacon"
- type: text
value: " and cook for "
- type: timer
quantity: 2
units: "minutes"
name: ""
metadata: []

testMultiWordFollowingSingleWordIngredient:
source: |
@ingredient and @ingredient with spaces{}
Expand Down

0 comments on commit 9ea85e9

Please sign in to comment.