Permalink
Browse files

markdown: Use document's encoding for preview

  • Loading branch information...
1 parent 36400f5 commit 283d76a07b6f2ced8d67e7ef5ee3fd978df7a1ad @codebrainz committed Jul 15, 2012
Showing with 8 additions and 5 deletions.
  1. +2 −2 markdown/src/plugin.c
  2. +4 −2 markdown/src/viewer.c
  3. +2 −1 markdown/src/viewer.h
@@ -228,14 +228,14 @@ static gboolean on_idle_handler(MarkdownPlugin *plugin)
/* Only handle valid Markdown documents */
if (!DOC_VALID(doc) || g_strcmp0(doc->file_type->name, "Markdown") != 0) {
markdown_viewer_update_content(plugin->viewer,
- _("The current document does not have a Markdown filetype."));
+ _("The current document does not have a Markdown filetype."), "UTF-8");
plugin->handler_ids.update_view = 0;
return FALSE;
}
md_text = (gchar*) scintilla_send_message(doc->editor->sci,
SCI_GETCHARACTERPOINTER, 0, 0);
- markdown_viewer_update_content(plugin->viewer, md_text);
+ markdown_viewer_update_content(plugin->viewer, md_text, doc->encoding);
plugin->handler_ids.update_view = 0;
@@ -109,7 +109,8 @@ void on_viewer_load_status_notify(GObject *obj, GParamSpec *pspec, MarkdownViewe
}
}
-void markdown_viewer_update_content(MarkdownViewer *viewer, const gchar *text)
+void markdown_viewer_update_content(MarkdownViewer *viewer, const gchar *text,
+ const gchar *encoding)
{
g_return_if_fail(viewer);
gchar *html = markdown_to_html(text);
@@ -122,7 +123,8 @@ void markdown_viewer_update_content(MarkdownViewer *viewer, const gchar *text)
markdown_template_get_filename(viewer->template));
g_signal_connect(viewer->webview, "notify::load-status",
G_CALLBACK(on_viewer_load_status_notify), viewer);
- webkit_web_view_load_string(viewer->webview, new_text, "text/html", "UTF-8", base_uri);
+ webkit_web_view_load_string(viewer->webview, new_text, "text/html",
+ encoding, base_uri);
g_free(new_text);
g_free(base_uri);
}
@@ -41,7 +41,8 @@ void markdown_viewer_set_template(MarkdownViewer *viewer, MarkdownTemplate *tmpl
void markdown_viewer_show(MarkdownViewer *viewer);
void markdown_viewer_hide(MarkdownViewer *viewer);
-void markdown_viewer_update_content(MarkdownViewer *viewer, const gchar *text);
+void markdown_viewer_update_content(MarkdownViewer *viewer, const gchar *text,
+ const gchar *encoding);
G_END_DECLS

0 comments on commit 283d76a

Please sign in to comment.