summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés M <andmarti1424@users.noreply.github.com>2020-02-06 13:47:01 -0300
committerGitHub <noreply@github.com>2020-02-06 13:47:01 -0300
commit3b5a803cc3f8a0bfb2885b1582140e5cfbb9f5e5 (patch)
treefc4774f9dfcaecd08860292124665d4644875acc
parent3ce04c7bc690d732a25b976b3737c809e2146c39 (diff)
parent7f70295826df9fdf040d175bc78f77aca0f1c1c4 (diff)
Merge pull request #386 from mipmip/pr-export-argument-mkd
add --export_mkd option
-rwxr-xr-xsrc/doc3
-rw-r--r--src/file.c14
-rw-r--r--src/main.c5
3 files changed, 16 insertions, 6 deletions
diff --git a/src/doc b/src/doc
index 9a4867e..5cbf1ac 100755
--- a/src/doc
+++ b/src/doc
@@ -1452,9 +1452,10 @@ Commands for handling cell content:
You can set the --output parameter to save the results to a file.
- Export to csv, tab or plain text formats without interaction:
+ Export to csv, tab, markdown or plain text formats without interaction:
./sc-im --quit_afterload --nocurses --export_csv
./sc-im --quit_afterload --nocurses --export_tab
+ ./sc-im --quit_afterload --nocurses --export_mkd
./sc-im --quit_afterload --nocurses --export_txt # (or just --export)
If you set the --quit_afterload flag, SC-IM will quit after loading all
diff --git a/src/file.c b/src/file.c
index c042450..e05156d 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1160,12 +1160,16 @@ void export_markdown(char * fname, int r0, int c0, int rn, int cn) {
int pid;
wchar_t out[FBUFLEN] = L"";
- sc_info("Writing file \"%s\"...", fname);
-
- if ((f = openfile(fname, &pid, NULL)) == (FILE *)0) {
- sc_error ("Can't create file \"%s\"", fname);
- return;
+ if (fname == NULL)
+ f = stdout;
+ else {
+ sc_info("Writing file \"%s\"...", fname);
+ if ((f = openfile(fname, &pid, NULL)) == (FILE *)0) {
+ sc_error ("Can't create file \"%s\"", fname);
+ return;
+ }
}
+
struct ent * ent = go_end();
if (rn > ent->row) rn = ent->row;
diff --git a/src/main.c b/src/main.c
index abc0a53..99fbc84 100644
--- a/src/main.c
+++ b/src/main.c
@@ -333,10 +333,15 @@ int main (int argc, char ** argv) {
export_delim(NULL, '\t', 0, 0, maxrow, maxcol, 0);
}
+ if (get_conf_value("export_mkd")) {
+ export_markdown(NULL, 0, 0, maxrow, maxcol);
+ }
+
if (get_conf_value("export") || get_conf_value("export_txt")) {
export_plain(NULL, 0, 0, maxrow, maxcol);
}
+
while ( ! shall_quit && ! atoi((char *) get_conf_value("quit_afterload"))) {
// save current time for runtime timer
gettimeofday(&current_tv, NULL);