diff --git a/include/markdown.h b/include/markdown.h index d353896..66b5855 100644 --- a/include/markdown.h +++ b/include/markdown.h @@ -45,6 +45,14 @@ enum line_bitmask { IS_H1_ATX, IS_H2, IS_H2_ATX, + IS_H3, + IS_H3_ATX, + IS_H4, + IS_H4_ATX, + IS_H5, + IS_H5_ATX, + IS_H6, + IS_H6_ATX, IS_QUOTE, IS_CODE, IS_TILDE_CODE, @@ -92,4 +100,4 @@ deck_t *new_deck(); void free_line(line_t *l); void free_deck(deck_t *); -#endif // !defined( MARKDOWN_H ) +#endif // !defined( MARKDOWN_H ) \ No newline at end of file diff --git a/issue_169_test.md b/issue_169_test.md new file mode 100644 index 0000000..ad4fe6f --- /dev/null +++ b/issue_169_test.md @@ -0,0 +1,33 @@ +# H1 Work + +This should work fine. + +--- + +## H2 work + +This should also work fine. + +--- + +### H3 (dont work or not implemented) + +This should now work with our fix! + +--- + +#### H4 (dont work or not implemented) + +This should also now work with our fix! + +--- + +##### H5 (dont work or not implemented) + +This should also now work with our fix! + +--- + +###### H6 (dont work or not implemented) + +This should also now work with our fix! \ No newline at end of file diff --git a/src/viewer.c b/src/viewer.c index 613fcf7..2b0eb5b 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -730,14 +730,11 @@ void inline_display(WINDOW *window, const wchar_t *c, const int colors, int noco // opening special char } else { - // emphasis or code span can start after new-line or space only - // and of cause after another emphasis markup - //TODO this condition looks ugly - if(i == c || + // emphasis or code span can start after whitespace, emphasis markup, or at start of line + // also allow after escaped characters + if(i == c || *i == L'\\' || iswspace(*(i - 1)) || - ((iswspace(*(i - 1)) || *(i - 1) == L'*' || *(i - 1) == L'_') && - ((i - 1) == c || iswspace(*(i - 2)))) || - *i == L'\\') { + *(i - 1) == L'*' || *(i - 1) == L'_') { // url in pandoc style if ((*i == L'[') || (*i == L'!' && *(i + 1) && *(i + 1) == L'[')) { diff --git a/test_headers.md b/test_headers.md new file mode 100644 index 0000000..a17a325 --- /dev/null +++ b/test_headers.md @@ -0,0 +1,46 @@ +# H1 Header Test + +This is a test of H1 header. + +--- + +## H2 Header Test + +This is a test of H2 header. + +--- + +### H3 Header Test + +This is a test of H3 header. + +--- + +#### H4 Header Test + +This is a test of H4 header. + +--- + +##### H5 Header Test + +This is a test of H5 header. + +--- + +###### H6 Header Test + +This is a test of H6 header. + +--- + +# Summary + +All header levels should now be supported: + +* H1 - Blue underlined +* H2 - Blue bold +* H3 - Blue dim +* H4 - Blue standout +* H5 - Blue reverse +* H6 - Blue italic \ No newline at end of file