-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathh1title.c
More file actions
38 lines (33 loc) · 781 Bytes
/
h1title.c
File metadata and controls
38 lines (33 loc) · 781 Bytes
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
#include <stdio.h>
#include "markdown.h"
static Paragraph *
mkd_h1(Paragraph *p)
{
Paragraph *found;
while ( p ) {
if ( p->typ == HDR && p->hnumber == 1 )
return p;
if ( p->down && (found = mkd_h1(p->down)) )
return found;
p = p->next;
}
return 0;
}
char *
mkd_h1_title(Document *doc)
{
Paragraph *title;
if (doc && (title = mkd_h1(doc->code)) ) {
char *generated;
int size;
/* assert that a H1 header is one line long, so that's
* the only thing needed
*/
set_mkd_flag(&(doc->ctx->flags), MKD_TAGTEXT);
size = mkd_line(T(title->text->text),
S(title->text->text), &generated, &(doc->ctx->flags));
clear_mkd_flag(&(doc->ctx->flags), MKD_TAGTEXT);
if ( size ) return generated;
}
return 0;
}