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.
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);
} 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);
}
}
- if (FORMAT_MMD != format) {
- d_string_free(result, true);
- }
+ d_string_free(result, true);
}
d_string_free(buffer, true);
} 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) {
fclose(output_stream);
}
- if (FORMAT_MMD != format) {
- d_string_free(result, true);
- }
+ d_string_free(result, true);
}
d_string_free(buffer, true);