summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPim Snel <post@pimsnel.com>2023-01-26 16:35:45 +0100
committerPim Snel <post@pimsnel.com>2023-01-26 16:35:45 +0100
commit3ca132ebb85619413ac60c4af0e67a8f3915d595 (patch)
tree02ea8e6e08151b591cd395586c9039f1b9902ca3
parentb4cfc3fef326f78b8c683707f0819886ddcd82bd (diff)
fix #775, wrong alignment of markdown export
-rw-r--r--src/file.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/file.c b/src/file.c
index ae07ada..20f96bb 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1532,24 +1532,6 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
(void) fprintf (f, " | ");
}
- //make header border of dashes with alignment characters
- if (row == 0) {
- if (col == c0) strcat (dashline, "|");
- if (align == 0) {
- strcat (dashline, ":");
- } else {
- strcat (dashline, "-");
- }
- for (dash_num = 0; dash_num < roman->cur_sh->fwidth[col]; dash_num++) {
- strcat (dashline, "-");
- }
- if(align >= 0) {
- strcat (dashline, ":");
- } else {
- strcat (dashline, "-");
- }
- strcat (dashline, "|");
- }
if (*pp) {
num [0] = '\0';
@@ -1584,7 +1566,6 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
}
}
-
pad_and_align (text, num, roman->cur_sh->fwidth[col], align, 0, out, roman->cur_sh->row_format[row]);
wchar_t new[wcslen(out)+1];
@@ -1610,6 +1591,27 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
} else {
fprintf (f, "%*s", roman->cur_sh->fwidth[col], " ");
}
+
+ // Make header border of dashes with alignment characters
+ // Column alignment is bases on cell alignments of first row
+ if (row == 0) {
+ if (col == c0) strcat (dashline, "|");
+ if (align == 0) {
+ strcat (dashline, ":");
+ } else {
+ strcat (dashline, "-");
+ }
+ for (dash_num = 0; dash_num < roman->cur_sh->fwidth[col]; dash_num++) {
+ strcat (dashline, "-");
+ }
+ if(align >= 0) {
+ strcat (dashline, ":");
+ } else {
+ strcat (dashline, "-");
+ }
+ strcat (dashline, "|");
+ }
+
}
fprintf(f," |\n");
}