Ejemplo n.º 1
0
static void
process_bijiben_html_content (BijiLazyDeserializer *self,
                              xmlTextReaderPtr      reader)
{
  BijiLazyDeserializerPrivate *priv = self->priv;
  int ret;
  gchar *sane_html;

  sane_html = (gchar*) xmlTextReaderReadInnerXml (reader);

  priv->inner = xmlReaderForMemory (sane_html,
                                    strlen(sane_html),
                                    "", "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);
  }

  biji_note_obj_set_raw_text (priv->note, priv->raw_text->str);
  biji_note_obj_set_html (priv->note, sane_html);

  xmlFree (BAD_CAST sane_html);
}
Ejemplo n.º 2
0
/* 
 * TODO : move this to local provider.
 */
static BijiNoteObj *
biji_note_book_local_note_new           (BijiNoteBook *book, gchar *str)
{
  BijiNoteObj *ret = get_note_skeleton (book);

  if (str)
  {
    gchar *unique, *html;

    unique = biji_note_book_get_unique_title (book, str);
    html = html_from_plain_text (str);

    biji_note_obj_set_title (ret, unique);
    biji_note_obj_set_raw_text (ret, str);
    biji_note_obj_set_html (ret, html);

    g_free (unique);
    g_free (html);
  }

  biji_note_obj_save_note (ret);
  biji_note_book_add_item (book, BIJI_ITEM (ret), TRUE);

  return ret;
}
Ejemplo n.º 3
0
static void
process_tomboy_xml_content (BijiLazyDeserializer *self)
{
  BijiLazyDeserializerPrivate *priv = self->priv;
  int ret;
  gchar *revamped_html;

  g_string_append (priv->html, "<html xmlns=\"http://www.w3.org/1999/xhtml\"><body>");

  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_tomboy_node (self);
    ret = xmlTextReaderRead (priv->inner);
  }

  g_string_append (priv->html, "</body></html>");

  /* Now the inner content is known, we can
   * assign note values and let deserialization work on last elements*/
  biji_note_obj_set_raw_text (priv->note, priv->raw_text->str);

  revamped_html = biji_str_replace (priv->html->str, "\n", "<br/>");
  biji_note_obj_set_html (priv->note, revamped_html);
  g_free (revamped_html);
}