X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=parser.c;h=3474cfdc94ec5490c6b018487a6a992066cf7f69;hb=3da34e1957b3484506b5f0f79f84f64a4cff2f1b;hp=3b56b5b347ca8a12c3fdc66db5e9be999934cbc8;hpb=ea429fb3f31aaee9f8b931b56b4488c70b2b7549;p=smdp.git diff --git a/parser.c b/parser.c index 3b56b5b..3474cfd 100644 --- a/parser.c +++ b/parser.c @@ -1,3 +1,26 @@ +/* + * Functions necessary to parse a file and transform its content into + * a deck of slides containing lines. All based on markdown formating + * rules. + * Copyright (C) 2014 Michael Goehler + * + * This file is part of mpd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include #include #include @@ -81,7 +104,7 @@ deck_t *markdown_load(FILE *input) { } else if(c == '\t') { // expand tab to spaces - for (i = 0; i <= EXPAND_TABS; i++) { + for (i = 0; i < EXPAND_TABS; i++) { (text->expand)(text, ' '); l++; } @@ -172,7 +195,8 @@ deck_t *markdown_load(FILE *input) { // remove line from linked list line->prev->next = line->next; - line->next->prev = line->prev; + if(line->next) + line->next->prev = line->prev; // set bits on revious line if(CHECK_BIT(line->bits, IS_H1)) { @@ -369,3 +393,7 @@ int next_blank(cstring_t *text, int i) { return i; } +int next_word(cstring_t *text, int i) { + return next_nonblank(text, next_blank(text, i)); +} +