File: docheader.c

package info (click to toggle)
ruby-rdiscount 2.2.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 480 kB
  • sloc: ansic: 4,798; ruby: 487; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * docheader -- get values from the document header
 *
 * Copyright (C) 2007 David L Parsons.
 * The redistribution terms are provided in the COPYRIGHT file that must
 * be distributed with this source code.
 */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#include "cstring.h"
#include "markdown.h"
#include "amalloc.h"

static char *
onlyifset(Line *l)
{
    char *ret;

    if ( l->dle < 0 || l->dle >= S(l->text) )
	return 0;

    ret = T(l->text) + l->dle;

    return ret[0] ? ret : 0;
}

char *
mkd_doc_title(Document *doc)
{
    if ( doc && doc->title )
	return onlyifset(doc->title);
    return 0;
}


char *
mkd_doc_author(Document *doc)
{
    if ( doc && doc->author )
	return onlyifset(doc->author);
    return 0;
}


char *
mkd_doc_date(Document *doc)
{
    if ( doc && doc->date )
	return onlyifset(doc->date);
    return 0;
}