aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2022-03-27 21:46:07 +0200
committerJeremias Stotter <jeremias@stotter.eu>2022-03-27 21:49:03 +0200
commit8a3e714ebc0e2f1a7a2198464546c62efd89ab82 (patch)
tree883f182c1da98f97040959fce5d9094dc45d8c86
parent81b0eefc220907544691c27089093ad1e446d243 (diff)
downloadJBlog-8a3e714ebc0e2f1a7a2198464546c62efd89ab82.tar.gz
JBlog-8a3e714ebc0e2f1a7a2198464546c62efd89ab82.tar.bz2
JBlog-8a3e714ebc0e2f1a7a2198464546c62efd89ab82.zip
Fixed tabs and a bug with inline code
-rw-r--r--md.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/md.c b/md.c
index d69068b..af8968a 100644
--- a/md.c
+++ b/md.c
@@ -269,9 +269,9 @@ char* tree_to_html(struct tree_element* root) {
html = realloc_for_html(inline_code_html);
sprintf(html, inline_code_html, inner_html ? inner_html : "");
} else {
- html = realloc(html, strlen(inner_html) + 1);
+ html = realloc(html, inner_html ? strlen(inner_html) : 0 + 1);
memcpy(html, "`", 2);
- strcat(html, inner_html);
+ strcat(html, inner_html ? inner_html : "");
}
break;
case(t_bq):
@@ -545,9 +545,14 @@ int parse_markdown(char* input, char* buffer, size_t buffer_size) {
escaped = true;
break;
// Tabs
- /*case('\t'):
+ case('\t'):
+ if(active_element == root || newline) {
+ //@todo with this we should relatively easily be able to check for code blocks!
+ spaces_trimmed += 4;
+ break;
+ } else goto default2;
- break;*/
+ break;
// Newline
case('\r'):
// Ignoring \r goes against the commonmark spec, but who cares
@@ -844,23 +849,6 @@ int parse_markdown(char* input, char* buffer, size_t buffer_size) {
return 0;
}
-// This function outputs a pointer that points past leading spaces
-// it returns the number of spaces skippen where \t = 4 spaces
-int trim_space(char* input, char** output) {
- char* trimmed = input;
- int count = 0;
- while(*trimmed == ' ' || *trimmed == '\t') {
- if(*trimmed == '\t') {
- count += 4;
- } else {
- count ++;
- }
- trimmed++;
- }
- *output = trimmed;
- return count;
-}
-
// Returns location of the closing round bracket if found, otherwise it returns a NULL
// out_text and out_loc are allocated by this function
// Don't forget to free
Jeremias Stotters git repositories generated by CGIT