]> granicus.if.org Git - multimarkdown/commitdiff
CHANGED: Standardize process for FORMAT_MMD
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sun, 30 Jul 2017 13:56:41 +0000 (09:56 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sun, 30 Jul 2017 13:56:41 +0000 (09:56 -0400)
Sources/libMultiMarkdown/mmd.c
Sources/multimarkdown/main.c

index 8a2bce77b9bee58660321a6cd65031aeecda4f6a..13859758e0b546c11772c7508a4442679bac2b16 100644 (file)
@@ -2649,7 +2649,7 @@ DString * mmd_d_string_convert_to_data(DString * source, unsigned long extension
 
        mmd_engine_set_language(e, language);
 
-       DString * result =  mmd_engine_convert_to_data(e, format, directory);
+       DString * result = mmd_engine_convert_to_data(e, format, directory);
 
        mmd_engine_free(e, false);                      // The engine doesn't own the DString, so don't free it.
 
@@ -2661,6 +2661,13 @@ DString * mmd_engine_convert_to_data(mmd_engine * e, short format, const char *
        DString * output = d_string_new("");
        DString * result = NULL;
 
+       if (format == FORMAT_MMD) {
+               // Simply return text (transclusion is handled externally)
+               d_string_append_c_array(output, e->dstr->str, e->dstr->currentStringLength);
+
+               return output;
+       }
+
        mmd_engine_parse_string(e);
 
        mmd_engine_export_token_tree(output, e, format);
index f8ce39059d31124b032854eeb15a59ea47a3c8c4..f66c914eb1bdd29d981f3e6ca362610844185f8f 100644 (file)
@@ -432,11 +432,7 @@ int main(int argc, char** argv) {
                        } else {
                                // Regular processing
 
-                               if (FORMAT_MMD == format) {
-                                       result = buffer;
-                               } else {
-                                       result = mmd_d_string_convert_to_data(buffer, extensions, format, language, folder);
-                               }
+                               result = mmd_d_string_convert_to_data(buffer, extensions, format, language, folder);
 
                                if (FORMAT_TEXTBUNDLE == format) {
                                        unzip_data_to_path(result->str, result->currentStringLength, output_filename);
@@ -450,9 +446,7 @@ int main(int argc, char** argv) {
                                        }
                                }
 
-                               if (FORMAT_MMD != format) {
-                                       d_string_free(result, true);
-                               }
+                               d_string_free(result, true);
                        }
 
                        d_string_free(buffer, true);
@@ -548,11 +542,7 @@ int main(int argc, char** argv) {
                } else {
                        // Regular processing
 
-                       if (FORMAT_MMD == format) {
-                               result = buffer;
-                       } else {
-                               result = mmd_d_string_convert_to_data(buffer, extensions, format, language, folder);
-                       }
+                       result = mmd_d_string_convert_to_data(buffer, extensions, format, language, folder);
 
                        // Where does output go?
                        if (strcmp(a_o->filename[0], "-") == 0) {
@@ -573,9 +563,7 @@ int main(int argc, char** argv) {
                                fclose(output_stream);
                        }
 
-                       if (FORMAT_MMD != format) {
-                               d_string_free(result, true);
-                       }
+                       d_string_free(result, true);
                }
 
                d_string_free(buffer, true);