Method: BibTeX.parse

Defined in:
ext/btparse-ruby/btparse_ruby.c

.parse(rb_entry_text) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'ext/btparse-ruby/btparse_ruby.c', line 62

static VALUE bibtex_parse(VALUE klass, VALUE rb_entry_text)
{
  Check_Type(rb_entry_text, T_STRING);

  char *entry_text  = RSTRING_PTR(rb_entry_text);
  boolean status  = 0;

  bt_initialize();

  AST *entries = bt_parse_entry_s(entry_text, NULL, 1, 0, &status);

  /* Exit early if parsing failed */
  if (entries == NULL || status == 0)
  {
    return Qnil;
  }
  
  VALUE rb_entries = ast_to_class(entries);
  
  bt_parse_entry_s(NULL, NULL, 1, 0, NULL);
  
  bt_cleanup();
  
  return rb_entries;
}