|
|
@ -639,6 +639,7 @@ char_emphasis(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t of
|
|
|
|
static size_t
|
|
|
|
static size_t
|
|
|
|
char_linebreak(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size)
|
|
|
|
char_linebreak(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
(void)data, (void)offset, (void)size;
|
|
|
|
/* removing the last space from ob and rendering */
|
|
|
|
/* removing the last space from ob and rendering */
|
|
|
|
while (ob->size && ob->data[ob->size - 1] == ' ')
|
|
|
|
while (ob->size && ob->data[ob->size - 1] == ' ')
|
|
|
|
ob->size--;
|
|
|
|
ob->size--;
|
|
|
@ -652,6 +653,7 @@ static size_t
|
|
|
|
char_codespan(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size)
|
|
|
|
char_codespan(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset, size_t size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t end, nb = 0, i, f_begin, f_end;
|
|
|
|
size_t end, nb = 0, i, f_begin, f_end;
|
|
|
|
|
|
|
|
(void)offset;
|
|
|
|
|
|
|
|
|
|
|
|
/* counting the number of backticks in the delimiter */
|
|
|
|
/* counting the number of backticks in the delimiter */
|
|
|
|
while (nb < size && data[nb] == '`')
|
|
|
|
while (nb < size && data[nb] == '`')
|
|
|
@ -696,6 +698,7 @@ char_escape(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~";
|
|
|
|
static const char *escape_chars = "\\`*_{}[]()#+-.!:|&<>^~";
|
|
|
|
struct buf work = { 0, 0, 0, 0 };
|
|
|
|
struct buf work = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
(void)offset;
|
|
|
|
|
|
|
|
|
|
|
|
if (size > 1) {
|
|
|
|
if (size > 1) {
|
|
|
|
if (strchr(escape_chars, data[1]) == NULL)
|
|
|
|
if (strchr(escape_chars, data[1]) == NULL)
|
|
|
@ -721,6 +724,7 @@ char_entity(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offs
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t end = 1;
|
|
|
|
size_t end = 1;
|
|
|
|
struct buf work = { 0, 0, 0, 0 };
|
|
|
|
struct buf work = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
(void)offset;
|
|
|
|
|
|
|
|
|
|
|
|
if (end < size && data[end] == '#')
|
|
|
|
if (end < size && data[end] == '#')
|
|
|
|
end++;
|
|
|
|
end++;
|
|
|
@ -751,6 +755,7 @@ char_langle_tag(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
|
|
|
|
size_t end = tag_length(data, size, &altype);
|
|
|
|
size_t end = tag_length(data, size, &altype);
|
|
|
|
struct buf work = { data, end, 0, 0 };
|
|
|
|
struct buf work = { data, end, 0, 0 };
|
|
|
|
int ret = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
(void)offset;
|
|
|
|
|
|
|
|
|
|
|
|
if (end > 2) {
|
|
|
|
if (end > 2) {
|
|
|
|
if (rndr->cb.autolink && altype != MKDA_NOT_AUTOLINK) {
|
|
|
|
if (rndr->cb.autolink && altype != MKDA_NOT_AUTOLINK) {
|
|
|
@ -1133,6 +1138,7 @@ char_superscript(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t sup_start, sup_len;
|
|
|
|
size_t sup_start, sup_len;
|
|
|
|
struct buf *sup;
|
|
|
|
struct buf *sup;
|
|
|
|
|
|
|
|
(void)offset;
|
|
|
|
|
|
|
|
|
|
|
|
if (!rndr->cb.superscript)
|
|
|
|
if (!rndr->cb.superscript)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -1886,6 +1892,7 @@ htmlblock_end_tag(
|
|
|
|
size_t size)
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t i, w;
|
|
|
|
size_t i, w;
|
|
|
|
|
|
|
|
(void)rndr;
|
|
|
|
|
|
|
|
|
|
|
|
/* checking if tag is a match */
|
|
|
|
/* checking if tag is a match */
|
|
|
|
if (tag_len + 3 >= size ||
|
|
|
|
if (tag_len + 3 >= size ||
|
|
|
@ -2513,7 +2520,7 @@ void
|
|
|
|
sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, struct sd_markdown *md)
|
|
|
|
sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, struct sd_markdown *md)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#define MARKDOWN_GROW(x) ((x) + ((x) >> 1))
|
|
|
|
#define MARKDOWN_GROW(x) ((x) + ((x) >> 1))
|
|
|
|
static const char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
|
|
|
|
static const unsigned char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
|
|
|
|
|
|
|
|
|
|
|
|
struct buf *text;
|
|
|
|
struct buf *text;
|
|
|
|
size_t beg, end;
|
|
|
|
size_t beg, end;
|
|
|
|