Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown: Allow exporting Markdown as HTML #502

Merged
merged 2 commits into from
Nov 13, 2016

Conversation

codebrainz
Copy link
Member

Add a Tools menu item "Export Markdown as HTML" to allow saving of the rendered HTML to disk instead of just the live preview.

Closes #497

Add a Tools menu item "Export Markdown as HTML" to allow saving of the
rendered HTML to disk instead of just the live preview.

Closes geany#497
@codebrainz
Copy link
Member Author

codebrainz commented Nov 11, 2016

I optimistically added 1.29 milestone though none of the new strings are translated yet, feel free to ignore for next release in 2 days :)

GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think multi-selection is disabled by default, and probably irrelevant for save too :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just being explicit.

NULL);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), "index.html");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rather use basename(DOC_FILENAME(doc)) + ".html"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice, yeah.

filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, _("HTML Files"));
gtk_file_filter_add_pattern(filter, "*.html");
gtk_file_filter_add_pattern(filter, "*.htm");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rather use gtk_file_filter_add_mime_type(filter, "text/html");?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea if it does what it sounds like, is there similar for * (All files)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but I'm afraid not

dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Failed to export Markdown HTML to file '%s': %s"),
fn, error->message);
g_error_free(error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe re-show the save dialog in case of error? I guess the most likely reason of failure is permission issue/invalid path, so I imagine the general action would be trying again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

* Use the document's filename as the basis for the new HTML filename.
* Properly setup the initial directory and suggested filename in the
  file chooser.
* Re-run the file chooser after showing error message if saving fails.
@frlan frlan merged commit 6e3de19 into geany:master Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants