tangled
alpha
login
or
join now
ngp.computer
/
tsk
A file-based task manager
0
fork
atom
overview
issues
pulls
pipelines
ADD: inline block styling in green
ngp.computer
1 year ago
0ab078be
b1132c11
+34
-10
1 changed file
expand all
collapse all
unified
split
src
task.rs
+34
-10
src/task.rs
···
67
67
out.push(c);
68
68
let end = out.len() - 1;
69
69
match (last, c, state_last) {
70
70
-
('=', ' ' | '\n' | '\r' | '.' | '!' | '?', Some(Highlight(hl))) => {
71
71
-
state.pop();
72
72
-
out.replace_range(
73
73
-
hl..end,
74
74
-
&out.get(hl + 1..out.len() - 2)?.reversed().to_string(),
75
75
-
);
76
76
-
}
77
77
-
(' ' | '\r' | '\n', '=', _) => {
78
78
-
state.push(Highlight(end));
79
79
-
}
80
70
('[', '[', _) => {
81
71
state.push(InternalLink(end));
82
72
}
···
125
115
out.replace_range(linktextpos..end, &linktext);
126
116
}
127
117
}
118
118
+
('=', ' ' | '\n' | '\r' | '.' | '!' | '?', Some(Highlight(hl))) => {
119
119
+
state.pop();
120
120
+
out.replace_range(
121
121
+
hl..end,
122
122
+
&out.get(hl + 1..out.len() - 2)?.reversed().to_string(),
123
123
+
);
124
124
+
}
125
125
+
(' ' | '\r' | '\n', '=', _) => {
126
126
+
state.push(Highlight(end));
127
127
+
}
128
128
(' ' | '\r' | '\n', '*', _) => {
129
129
state.push(Italics(end));
130
130
}
···
161
161
il..end,
162
162
&out.get(il + 1..end - 1)?.strikethrough().to_string(),
163
163
);
164
164
+
}
165
165
+
('`', ' ' | '\n' | '\r' | '.' | '!' | '?', Some(InlineBlock(hl))) => {
166
166
+
state.pop();
167
167
+
out.replace_range(
168
168
+
hl..end,
169
169
+
&out.get(hl + 1..out.len() - 2)?.green().to_string(),
170
170
+
);
171
171
+
}
172
172
+
(' ' | '\r' | '\n', '`', _) => {
173
173
+
state.push(InlineBlock(end));
164
174
}
165
175
_ => (),
166
176
}
···
326
336
#[test]
327
337
fn test_strikethrough_bad() {
328
338
let input = "hello ~world\n";
339
339
+
let output = parse(input).expect("parse to work");
340
340
+
assert_eq!(input, output.content);
341
341
+
}
342
342
+
343
343
+
#[test]
344
344
+
fn test_inlineblock() {
345
345
+
let input = "hello `world`\n";
346
346
+
let output = parse(input).expect("parse to work");
347
347
+
assert_eq!("hello \u{1b}[32mworld\u{1b}[0m\n", output.content);
348
348
+
}
349
349
+
350
350
+
#[test]
351
351
+
fn test_inlineblock_bad() {
352
352
+
let input = "hello `world\n";
329
353
let output = parse(input).expect("parse to work");
330
354
assert_eq!(input, output.content);
331
355
}