Skip to content

Commit 4da8b3d

Browse files
committed
fix commas getting inserted into certain values and add string escaping
1 parent c1b848c commit 4da8b3d

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

exampleVault/Test.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
---
2-
frequency: "[[high]]"
3-
toggle: false
4-
needs: Meta Bind JS
5-
date: Saturday, July 8th 2023
6-
text: asdasddas
72
Bible Reading: false
3+
test: 0
84
---
95

106
`INPUT[toggle:Bible Reading]`
11-
`INPUT[toggle:["Bible Reading"]]`
7+
`INPUT[toggle:["Bible Reading"]]`
8+
9+
10+
`INPUT[inlineSelect(option(0, 'don\'t do this'), option(1, 'do this \\')):test]`

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-meta-bind-plugin",
33
"name": "Meta Bind Plugin",
4-
"version": "0.6.3",
4+
"version": "0.6.4",
55
"minAppVersion": "0.14.0",
66
"description": "This plugin can create input fields inside your notes and bind them to metadata fields.",
77
"author": "Moritz Jung",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-meta-bind-plugin",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"description": "This plugin can create input fields inside your notes and bind them to metadata fields.",
55
"main": "main.js",
66
"scripts": {

src/parsers/nomParsers/Parsers.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,28 @@ const ident = P.regexp(/^[a-z][a-z0-9_-]*/i)
1919

2020
const spaceIdent = P.sequenceMap(
2121
(a, b) => {
22-
return a + b.map(x => x[0] + x[1]).join();
22+
return a + b.map(x => x[0] + x[1]).join('');
2323
},
2424
ident,
2525
P.sequence(P_UTILS.optionalWhitespace(), ident).many()
2626
).describe('identifier with spaces');
2727

28+
const escapeCharacter = P.string('\\')
29+
.then(P_UTILS.any())
30+
.map(escaped => {
31+
if (escaped === "'") {
32+
return "'";
33+
} else if (escaped === '\\') {
34+
return '\\';
35+
} else {
36+
return '\\' + escaped;
37+
}
38+
});
39+
2840
function createStr(quotes: string): Parser<string> {
2941
return P.string(quotes)
3042
.then(
31-
P.noneOf(quotes)
43+
P.or(escapeCharacter, P.noneOf(quotes + '\\'))
3244
.many()
3345
.map(x => x.join(''))
3446
)
@@ -41,11 +53,11 @@ const specialIdent = P.regexp(/^[^ \t\n\r()',]+/).describe('any character except
4153

4254
const specialSpaceIdent = P.sequenceMap(
4355
(a, b) => {
44-
return a + b.map(x => x[0] + x[1]).join();
56+
return a + b.map(x => x[0] + x[1]).join('');
4557
},
4658
specialIdent,
4759
P.sequence(P_UTILS.optionalWhitespace(), specialIdent).many()
48-
).describe('any character except parentheses');
60+
).describe('any character except parentheses, single quotation marks and commas');
4961

5062
const value = P.or(specialSpaceIdent, str);
5163

0 commit comments

Comments
 (0)