static void process_bijiben_html_content (BijiLazyDeserializer *self) { BijiLazyDeserializerPrivate *priv = self->priv; int ret; gchar *sane_text, *sane_html; priv->inner = xmlReaderForMemory (priv->content, strlen(priv->content), "", "UTF-8", 0); ret = xmlTextReaderRead (priv->inner); /* Make the GString grow as we read */ while (ret == 1) { process_bijiben_node (self); ret = xmlTextReaderRead (priv->inner); } /* Now the inner content is known, we can * assign note values and let deserialization work on last elements*/ sane_html = biji_str_mass_replace (priv->html->str, "
" , "<br/>", "&" , "&" , NULL); sane_text = biji_str_mass_replace (priv->raw_text->str, "
", " ", "&", "&" , NULL); biji_note_obj_set_raw_text (priv->note, sane_text); biji_note_obj_set_html_content (priv->note, sane_html); g_free (sane_text); g_free (sane_html); }
gchar * html_from_plain_text (gchar *content) { gchar *escaped, *retval; if (content == NULL) content = ""; escaped = biji_str_mass_replace (content, "&", "&", "<", "<", ">", ">", "\n", "<br/>", NULL); retval = g_strconcat ("<html xmlns=\"http://www.w3.org/1999/xhtml\">", "<body contenteditable='true' id='editable'>", "<script type='text/javascript'>", " window.onload = function () {", " document.getElementById('editable').focus();", " };", "</script>", escaped, "</body></html>", NULL); g_free (escaped); return retval; }
gchar * biji_note_obj_get_icon_file (BijiNoteObj *note) { g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL); const gchar *uuid; gchar *basename, *filename; uuid = BIJI_NOTE_OBJ_GET_CLASS (note)->get_basename (note); basename = biji_str_mass_replace (uuid, ".note", ".png", ".txt", ".png", NULL); filename = g_build_filename (g_get_user_cache_dir (), g_get_application_name (), basename, NULL); g_free (basename); return filename; }