- // push special char to stack
- (stack->push)(stack, *c);
+ // emphasis or code span can start after new-line or space only
+ // and of cause after another emphasis markup
+ if(*(i - 1) == ' ' ||
+ ((*(i - 1) == '_' || *(i - 1) == '*') && (*(i - 2) == ' ' || (i - 1) == c)) ||
+ *i == '\\' ||
+ i == c) {
+
+ switch(*i) {
+ // enable highlight
+ case '*':
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_RED));
+ break;
+ // enable underline
+ case '_':
+ wattron(window, A_UNDERLINE);
+ break;
+ // enable inline code
+ case '`':
+ if(colors)
+ wattron(window, COLOR_PAIR(CP_BLACK));
+ break;
+ // do nothing for backslashes
+ }
+
+ // push special char to stack
+ (stack->push)(stack, *i);
+
+ } else {
+ wprintw(window, "%c", *i);
+ }