File: docheader.c

package info (click to toggle)
lua-discount 2.1.8-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 224 kB
  • ctags: 418
  • sloc: ansic: 2,976; makefile: 38
file content (39 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (2)
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
/*
 * 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"

#define afterdle(t) (T((t)->text) + (t)->dle)

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

char *mkd_doc_author(Document *doc)
{
	if (doc && doc->headers && doc->headers->next)
		return afterdle(doc->headers->next);
	return 0;
}

char *mkd_doc_date(Document *doc)
{
	if (doc && doc->headers && doc->headers->next &&
	    doc->headers->next->next)
		return afterdle(doc->headers->next->next);
	return 0;
}