/* has_metadata - parse document and report whether metadata is present */ gboolean has_metadata(char *text, int extensions) { gboolean hasMeta; element *result; element *references; element *notes; element *labels; GString *formatted_text; formatted_text = preformat_text(text); references = parse_references(formatted_text->str, extensions); notes = parse_notes(formatted_text->str, extensions, references); labels = parse_labels(formatted_text->str, extensions, references, notes); result = parse_metadata_only(formatted_text->str, extensions); hasMeta = FALSE; if (result != NULL) { if (result->children != NULL) { hasMeta = TRUE; free_element_list(result); } else { free_element(result); } } free_element_list(references); free_element_list(labels); return hasMeta; }
/* extract_metadata_value - parse document and return value of specified metadata key (e.g. "LateX Mode")/ Returns a null-terminated string, which must be freed after use. */ char * extract_metadata_value(char *text, int extensions, char *key) { char *value; element *result; GString *formatted_text; formatted_text = preformat_text(text); result = parse_metadata_only(formatted_text->str, extensions); value = metavalue_for_key(key, result->children); free_element_list(result); return value; }
/* extract_metadata_value - parse document and return value of specified metadata key (e.g. "LateX Mode")/ Returns a null-terminated string, which must be freed after use. */ char * extract_metadata_value(char *text, int extensions, char *key) { char *value; element *result; element *references; element *notes; element *labels; GString *formatted_text; formatted_text = preformat_text(text); references = parse_references(formatted_text->str, extensions); notes = parse_notes(formatted_text->str, extensions, references); labels = parse_labels(formatted_text->str, extensions, references, notes); result = parse_metadata_only(formatted_text->str, extensions); value = metavalue_for_key(key, result); free_element_list(result); free_element_list(references); free_element_list(labels); return value; }