File indexing completed on 2024-04-28 11:21:06

0001 /*
0002  * docheader -- get values from the document header
0003  *
0004  * Copyright (C) 2007 David L Parsons.
0005  * The redistribution terms are provided in the COPYRIGHT file that must
0006  * be distributed with this source code.
0007  */
0008 #include "config.h"
0009 #include <stdio.h>
0010 #include <stdlib.h>
0011 #include <ctype.h>
0012 
0013 #include "cstring.h"
0014 #include "markdown.h"
0015 #include "amalloc.h"
0016 
0017 static char *
0018 onlyifset(Line *l)
0019 {
0020     char *ret;
0021 
0022     if ( l->dle < 0 || l->dle >= S(l->text) )
0023     return 0;
0024 
0025     ret = T(l->text) + l->dle;
0026 
0027     return ret[0] ? ret : 0;
0028 }
0029 
0030 char *
0031 mkd_doc_title(Document *doc)
0032 {
0033     if ( doc && doc->title )
0034     return onlyifset(doc->title);
0035     return 0;
0036 }
0037 
0038 
0039 char *
0040 mkd_doc_author(Document *doc)
0041 {
0042     if ( doc && doc->author )
0043     return onlyifset(doc->author);
0044     return 0;
0045 }
0046 
0047 
0048 char *
0049 mkd_doc_date(Document *doc)
0050 {
0051     if ( doc && doc->date )
0052     return onlyifset(doc->date);
0053     return 0;
0054 }