tangled
alpha
login
or
join now
ngp.computer
/
tsk
A file-based task manager
0
fork
atom
overview
issues
pulls
pipelines
FIX: small bugs with link parsing
ngp.computer
1 year ago
8cf743c9
4140500f
+12
-10
2 changed files
expand all
collapse all
unified
split
.tsk
archive
tsk-14.tsk
src
task.rs
+3
-1
.tsk/archive/tsk-14.tsk
···
5
5
6
6
and finally some *italics!*
7
7
8
8
-
here's [a link](https://ngp.computer).
8
8
+
here's [a link](https://ngp.computer).
9
9
+
10
10
+
and an internal link: [[tsk-11]]
+9
-9
src/task.rs
···
65
65
// there will always be an op code in the stack
66
66
Some((_, c)) => {
67
67
out.push(c);
68
68
-
let end = out.len()-1;
69
69
-
if c == '\n' || c == '\r' {
70
70
-
state.clear();
71
71
-
}
68
68
+
let end = out.len() - 1;
72
69
match (last, c, state_last) {
73
70
('=', ' ' | '\n' | '\r' | '.' | '!' | '?', Some(Highlight(hl))) => {
74
71
state.pop();
···
92
89
contents.purple(),
93
90
super_num(links.len() + 1).purple()
94
91
);
95
95
-
out.replace_range(il..out.len()-1, &linktext);
92
92
+
out.replace_range(il-1..out.len(), &linktext);
96
93
links.push(ParsedLink::Internal(id));
97
94
} else {
98
95
panic!("Internal link is not a valid id: {contents}");
···
119
116
};
120
117
let linktext = format!(
121
118
"{}{}",
122
122
-
out.get(linktextpos + 1..linkpos-1)?.blue(),
119
119
+
out.get(linktextpos + 1..linkpos - 1)?.blue(),
123
120
super_num(links.len() + 1).purple()
124
121
);
125
122
let link = out.get(linkpos + 1..out.len() - 2)?;
···
170
167
}
171
168
_ => (),
172
169
}
170
170
+
if c == '\n' || c == '\r' {
171
171
+
state.clear();
172
172
+
}
173
173
last = c;
174
174
}
175
175
None => break,
···
231
231
output.links.as_slice()
232
232
);
233
233
assert_eq!(
234
234
-
"hello \u{1b}[34mworld\u{1b}[0m\u{1b}[35m¹\u{1b}[0m)\n",
234
234
+
"hello \u{1b}[34mworld\u{1b}[0m\u{1b}[35m¹\u{1b}[0m\n",
235
235
output.content
236
236
);
237
237
}
···
264
264
let output = parse(input).expect("parse to work");
265
265
assert_eq!(&[ParsedLink::Internal(Id(123))], output.links.as_slice());
266
266
assert_eq!(
267
267
-
"hello [\u{1b}[35mtsk-123\u{1b}[0m\u{1b}[35m¹\u{1b}[0m]\n",
267
267
+
"hello \u{1b}[35mtsk-123\u{1b}[0m\u{1b}[35m¹\u{1b}[0m\n",
268
268
output.content
269
269
);
270
270
}
···
338
338
let input = "hello *italic* ~strikethrough~ !bold!\n";
339
339
let output = parse(input).expect("parse to work");
340
340
assert_eq!(
341
341
-
"hello \u{1b}[3mworld\u{1b}[0m \u{1b}[9mworld\u{1b}[0m \u{1b}[1mworld\u{1b}[0m\n",
341
341
+
"hello \u{1b}[3mitalic\u{1b}[0m \u{1b}[9mstrikethrough\u{1b}[0m \u{1b}[1mbold\u{1b}[0m\n",
342
342
output.content
343
343
);
344
344
}