Skip to content

Commit

Permalink
fix(snippet.js): corner cases of Snippet Lines (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiphereth-A authored Dec 2, 2024
1 parent d6b8fe9 commit 4527343
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions oi-wiki-export-typst/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function resolvePath(snip, spacesAtStart) {
if ((str.startsWith('"') && str.endsWith('"')) ||
(str.startsWith("'") && str.endsWith("'"))) {
const strs = str.substring(1, str.length - 1).split(":")
res.path = strs[0]
if (strs.length == 3) {
res.beg_line = Number(strs[1]) - 1
res.end_line = Number(strs[2])
} else if (strs.length != 1) {
if (strs.length < 1 || strs.length > 3) {
console.error('cannot parse snippet:', snip)
} else {
res.path = strs[0]
res.beg_line = strs[1] ? Number(strs[1]) - 1 : undefined
res.end_line = strs[2] ? Number(strs[2]) : undefined
}
} else {
console.error('cannot parse snippet:', snip)
Expand Down
10 changes: 5 additions & 5 deletions oi-wiki-export/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ function resolvePath(snip, spacesAtStart) {
(str.startsWith("'") && str.endsWith("'"))
) {
const strs = str.substring(1, str.length - 1).split(":");
res.path = strs[0];
if (strs.length == 3) {
res.beg_line = Number(strs[1]) - 1;
res.end_line = Number(strs[2]);
} else if (strs.length != 1) {
if (strs.length < 1 || strs.length > 3) {
console.error("cannot parse snippet:", snip);
} else {
res.path = strs[0];
res.beg_line = strs[1] ? Number(strs[1]) - 1 : undefined;
res.end_line = strs[2] ? Number(strs[2]) : undefined;
}
} else {
console.error("cannot parse snippet:", snip);
Expand Down

0 comments on commit 4527343

Please sign in to comment.