Skip to content

Commit 1a3e851

Browse files
committed
docbuilder: replace tabulation with space and keep only one space when there are multiple ones
1 parent 244ac12 commit 1a3e851

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/main.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define NO_SKIP -1
3333
#define SET_SKIP_N(_c,_n) do {toskip = _c; nskip = _n;} while(0)
3434
#define SET_SKIP(_c) SET_SKIP_N(_c, 1)
35+
#define SKIP_UNTIL(_c) do{i++;} while(PEEK == _c)
3536
#define RESET_SKIP() do {toskip = NO_SKIP; nskip = 1;} while(0)
3637

3738
#if GENERATE_SQLITE_DATABASE
@@ -245,7 +246,6 @@ static char *process_md (const char *input, size_t *len) {
245246

246247
case '[':
247248
case ']':
248-
case '\t':
249249
case '*': {
250250
// skip character
251251
continue;
@@ -262,6 +262,24 @@ static char *process_md (const char *input, size_t *len) {
262262
if (json_mode) buffer[j++] = '\\';
263263
break;
264264
}
265+
266+
case '\t': {
267+
// replace tabulations with spaces
268+
if (json_mode){
269+
if(PEEK == '\t'){
270+
continue;
271+
} else {
272+
c = ' ';
273+
}
274+
}
275+
break;
276+
}
277+
278+
case ' ': {
279+
// remove multiple spaces
280+
if (PEEK == ' ') SKIP_UNTIL(' ');
281+
break;
282+
}
265283

266284
case 'i': {
267285
if (strip_jsx == false) break;

0 commit comments

Comments
 (0)