aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2022-03-20 20:24:31 +0100
committerJeremias Stotter <jeremias@stotter.eu>2022-03-20 20:24:31 +0100
commit29aac63479b3ad0b93a317cf0f4899734c8ccfcf (patch)
tree0360c8d8972c4398994cc760bba2b2c52c4784a4
parent1485eeeae32c9bf7c2bae956e9068c905b9a73d9 (diff)
downloadJBlog-29aac63479b3ad0b93a317cf0f4899734c8ccfcf.tar.gz
JBlog-29aac63479b3ad0b93a317cf0f4899734c8ccfcf.tar.bz2
JBlog-29aac63479b3ad0b93a317cf0f4899734c8ccfcf.zip
Spaces before links now get inserted
-rw-r--r--md.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/md.c b/md.c
index 33b6b4e..31cfa1e 100644
--- a/md.c
+++ b/md.c
@@ -176,7 +176,6 @@ int depth = 0;
char* tree_to_html(struct tree_element* root) {
char* html=NULL;
char* inner_html = NULL;
- printf("%d: %d\n", depth, root->type);
for(int i = 0; i < root->children_n; i++) {
struct tree_element* child = root->children[i];
switch(child->type) {
@@ -494,10 +493,11 @@ int parse_markdown(char* input, char* buffer, size_t buffer_size) {
}\
}
+ #define APPEND_SPACES for(int i = 0; i < soft_newline_count; i++) append_char_to_active(root, &active_element, ' ');
+
// Checks that should be done if a non special character is hit, might also be necessary to check sometimes not in default
#define DEFAULT_CHECKS {\
- for(int i = 0; i < soft_newline_count; i++) \
- append_char_to_active(root, &active_element, ' '); \
+ APPEND_SPACES \
soft_newline_count = 0; \
if(spaces_trimmed >= 4 && (newline || active_element == root)) { \
/* if code_element is set the new active element is just returned to the code element*/ \
@@ -678,6 +678,7 @@ int parse_markdown(char* input, char* buffer, size_t buffer_size) {
size_t link_len = 0;
char* new_position = get_link_components(cur_char, &link_text, &link_loc, &link_len);
if(new_position) {
+ APPEND_SPACES
if(active_element == root) {
NEW_ACTIVE_CHILD(active_element, active_element, -1, t_p, true);
}
Jeremias Stotters git repositories generated by CGIT