mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-24 11:25:30 +00:00
Sync up with MMD upstream.
This commit is contained in:
parent
5771dbbaf3
commit
935df35140
@ -1,4 +1,4 @@
|
||||
.TH mxml 3 "Mini-XML API" "04/30/17" "Mini-XML API"
|
||||
.TH mxml 3 "Mini-XML API" "05/01/17" "Mini-XML API"
|
||||
.SH NAME
|
||||
mxml \- Mini-XML API
|
||||
.SH INCLUDE FILE
|
||||
|
37
mmd.c
37
mmd.c
@ -32,7 +32,6 @@
|
||||
*/
|
||||
|
||||
#include "mmd.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
@ -277,6 +276,31 @@ mmd_t * /* O - First node in markdown */
|
||||
mmdLoad(const char *filename) /* I - File to load */
|
||||
{
|
||||
FILE *fp; /* File */
|
||||
mmd_t *doc; /* Document */
|
||||
|
||||
|
||||
/*
|
||||
* Open the file and create an empty document...
|
||||
*/
|
||||
|
||||
if ((fp = fopen(filename, "r")) == NULL)
|
||||
return (NULL);
|
||||
|
||||
doc = mmdLoadFile(fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return (doc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'mmdLoadFile()' - Load a markdown file into nodes from a stdio file.
|
||||
*/
|
||||
|
||||
mmd_t * /* O - First node in markdown */
|
||||
mmdLoadFile(FILE *fp) /* I - File to load */
|
||||
{
|
||||
mmd_t *doc, /* Document */
|
||||
*current, /* Current parent block */
|
||||
*block = NULL; /* Current block */
|
||||
@ -288,12 +312,9 @@ mmdLoad(const char *filename) /* I - File to load */
|
||||
|
||||
|
||||
/*
|
||||
* Open the file and create an empty document...
|
||||
* Create an empty document...
|
||||
*/
|
||||
|
||||
if ((fp = fopen(filename, "r")) == NULL)
|
||||
return (NULL);
|
||||
|
||||
doc = current = mmd_add(NULL, MMD_TYPE_DOCUMENT, 0, NULL, NULL);
|
||||
|
||||
if (!doc)
|
||||
@ -580,8 +601,6 @@ mmdLoad(const char *filename) /* I - File to load */
|
||||
mmd_parse_inline(block, lineptr);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return (doc);
|
||||
}
|
||||
|
||||
@ -782,8 +801,6 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
|
||||
else
|
||||
type = MMD_TYPE_NORMAL_TEXT;
|
||||
}
|
||||
else
|
||||
type = MMD_TYPE_NORMAL_TEXT;
|
||||
|
||||
if (!*lineptr)
|
||||
break;
|
||||
@ -803,6 +820,7 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
|
||||
|
||||
text = NULL;
|
||||
whitespace = 0;
|
||||
type = MMD_TYPE_NORMAL_TEXT;
|
||||
}
|
||||
else if (*lineptr == '`' && type == MMD_TYPE_CODE_TEXT)
|
||||
{
|
||||
@ -811,6 +829,7 @@ mmd_parse_inline(mmd_t *parent, /* I - Parent node */
|
||||
|
||||
text = NULL;
|
||||
whitespace = 0;
|
||||
type = MMD_TYPE_NORMAL_TEXT;
|
||||
}
|
||||
else if (*lineptr == '\\' && lineptr[1])
|
||||
{
|
||||
|
10
mmd.h
10
mmd.h
@ -34,6 +34,7 @@
|
||||
* Include necessary headers...
|
||||
*/
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
|
||||
/*
|
||||
@ -82,6 +83,10 @@ typedef struct _mmd_s mmd_t;
|
||||
* Functions...
|
||||
*/
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif /* __cplusplus */
|
||||
|
||||
extern void mmdFree(mmd_t *node);
|
||||
extern mmd_t *mmdGetFirstChild(mmd_t *node);
|
||||
extern mmd_t *mmdGetLastChild(mmd_t *node);
|
||||
@ -95,5 +100,10 @@ extern const char *mmdGetURL(mmd_t *node);
|
||||
extern int mmdGetWhitespace(mmd_t *node);
|
||||
extern int mmdIsBlock(mmd_t *node);
|
||||
extern mmd_t *mmdLoad(const char *filename);
|
||||
extern mmd_t *mmdLoadFile(FILE *fp);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif /* __cplusplus */
|
||||
|
||||
#endif /* !MMD_H */
|
||||
|
Loading…
Reference in New Issue
Block a user