Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade/discount 3 #156

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Copy the new Discount sources to the appropriate directories for RDiscount:
Update rdiscount.gemspec to include all *.c, *.h, and *.rb files in
ext. This must be done manually. Here's a quick way to get the full list:

$ echo ext/*.c ext/*.h ext/*.rb ext/blocktags ext/VERSION | tr ' ' "\n" | sort
$ echo ext/*.c ext/*.h ext/*.rb ext/VERSION | tr ' ' "\n" | sort

(There is an old Rakefile target called "rdiscount.gemspec" that looks like it
is designed to perform an update of these files, however I haven't tested it.)
Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ task :gather => 'discount/markdown.h' do |t|
]

# Ensure configure.sh was run
if not File.exists? 'discount/mkdio.h'
if not File.exist? 'discount/mkdio.h'
abort "discount/mkdio.h not found. Did you run ./configure.sh in the discount directory?"
end

Expand Down Expand Up @@ -166,7 +166,6 @@ task :gather => 'discount/markdown.h' do |t|
end

# Copy special files from discount -> ext
cp 'discount/blocktags', 'ext/'
cp 'discount/VERSION', 'ext/'

# Copy man page
Expand Down
2 changes: 1 addition & 1 deletion discount
2 changes: 1 addition & 1 deletion ext/Csio.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Cswrite(Cstring *iot, char *bfr, int size)
/* reparse() into a cstring
*/
void
Csreparse(Cstring *iot, char *buf, int size, mkd_flag_t flags)
Csreparse(Cstring *iot, char *buf, int size, mkd_flag_t* flags)
{
MMIOT f;
___mkd_initmmiot(&f, 0);
Expand Down
2 changes: 1 addition & 1 deletion ext/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.7c
3.0.0a
8 changes: 3 additions & 5 deletions ext/dumptree.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)
if ( pp->ident )
d += fprintf(f, " %s", pp->ident);

#ifdef GITHUB_CHECKBOX
if ( pp->flags )
d += fprintf(f, " %x", pp->flags);
#endif
if ( pp->para_flags )
d += fprintf(f, " %x", pp->para_flags);

if ( pp->align > 1 )
d += fprintf(f, ", <%s>", Begin[pp->align]);
Expand All @@ -143,7 +141,7 @@ dumptree(Paragraph *pp, Stack *sp, FILE *f)


int
mkd_dump(Document *doc, FILE *out, mkd_flag_t flags, char *title)
mkd_dump(Document *doc, FILE *out, mkd_flag_t *flags, char *title)
{
Stack stack;

Expand Down
50 changes: 50 additions & 0 deletions ext/flagprocs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* markdown: a C implementation of John Gruber's Markdown markup language.
*
* Copyright (C) 2007-2011 David L Parsons.
* The redistribution terms are provided in the COPYRIGHT file that must
* be distributed with this source code.
*/

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>

#include "config.h"
#include "markdown.h"
#include "amalloc.h"

#if HAVE_LIBGEN_H
#include <libgen.h>
#endif

void
mkd_set_flag_num(mkd_flag_t *p, unsigned long bit)
{
if ( p && (bit < MKD_NR_FLAGS) )
set_mkd_flag(p, bit);
}


void
mkd_clr_flag_num(mkd_flag_t *p, unsigned long bit)
{
if ( p && (bit < MKD_NR_FLAGS) )
clear_mkd_flag(p, bit);
}


void
mkd_set_flag_bitmap(mkd_flag_t *p, long bits)
{
int i;

if ( p == 0 )
return;

for (i=0; i < 8*sizeof(long) && i < MKD_NR_FLAGS; i++)
if ( bits & (1<<i) )
set_mkd_flag(p, i);
}
57 changes: 49 additions & 8 deletions ext/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "markdown.h"

struct flagnames {
mkd_flag_t flag;
int flag;
char *name;
};

Expand All @@ -11,12 +11,11 @@ static struct flagnames flagnames[] = {
{ MKD_NOIMAGE, "!IMAGE" },
{ MKD_NOPANTS, "!PANTS" },
{ MKD_NOHTML, "!HTML" },
{ MKD_STRICT, "STRICT" },
{ MKD_TAGTEXT, "TAGTEXT" },
{ MKD_NO_EXT, "!EXT" },
{ MKD_CDATA, "CDATA" },
{ MKD_NOSUPERSCRIPT, "!SUPERSCRIPT" },
{ MKD_NORELAXED, "!RELAXED" },
{ MKD_STRICT, "STRICT" },
{ MKD_NOTABLES, "!TABLES" },
{ MKD_NOSTRIKETHROUGH,"!STRIKETHROUGH" },
{ MKD_TOC, "TOC" },
Expand All @@ -27,23 +26,30 @@ static struct flagnames flagnames[] = {
{ MKD_TABSTOP, "TABSTOP" },
{ MKD_NODIVQUOTE, "!DIVQUOTE" },
{ MKD_NOALPHALIST, "!ALPHALIST" },
{ MKD_NODLIST, "!DLIST" },
{ MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
{ MKD_NOSTYLE, "!STYLE" },
{ MKD_NODLDISCOUNT, "!DLDISCOUNT" },
{ MKD_DLDISCOUNT, "DLDISCOUNT" },
{ MKD_DLEXTRA, "DLEXTRA" },
{ MKD_FENCEDCODE, "FENCEDCODE" },
{ MKD_IDANCHOR, "IDANCHOR" },
{ MKD_GITHUBTAGS, "GITHUBTAGS" },
{ MKD_NORMAL_LISTITEM, "NORMAL_LISTITEM" },
{ MKD_URLENCODEDANCHOR, "URLENCODEDANCHOR" },
{ MKD_LATEX, "LATEX" },
{ MKD_EXPLICITLIST, "EXPLICITLIST" },
};
#define NR(x) (sizeof x/sizeof x[0])


int
mkd_flag_isset(mkd_flag_t *flags, int i)
{
return flags ? is_flag_set(flags, i) : 0;
}


void
mkd_flags_are(FILE *f, mkd_flag_t flags, int htmlplease)
mkd_flags_are(FILE *f, mkd_flag_t* flags, int htmlplease)
{
int i;
int not, set, even=1;
Expand All @@ -52,7 +58,7 @@ mkd_flags_are(FILE *f, mkd_flag_t flags, int htmlplease)
if ( htmlplease )
fprintf(f, "<table class=\"mkd_flags_are\">\n");
for (i=0; i < NR(flagnames); i++) {
set = flags & flagnames[i].flag;
set = mkd_flag_isset(flags, flagnames[i].flag);
name = flagnames[i].name;
if ( not = (*name == '!') ) {
++name;
Expand Down Expand Up @@ -89,5 +95,40 @@ void
mkd_mmiot_flags(FILE *f, MMIOT *m, int htmlplease)
{
if ( m )
mkd_flags_are(f, m->flags, htmlplease);
mkd_flags_are(f, &(m->flags), htmlplease);
}

void
mkd_init_flags(mkd_flag_t *p)
{
memset(p, 0, sizeof(*p));
}

mkd_flag_t *
mkd_flags(void)
{
mkd_flag_t *p = malloc( sizeof(mkd_flag_t) );

if ( p )
mkd_init_flags(p);

return p;
}


mkd_flag_t *
mkd_copy_flags(mkd_flag_t *original)
{
mkd_flag_t *copy = mkd_flags();

if ( original && copy )
*copy = *original;

return copy;
}

void
mkd_free_flags(mkd_flag_t *rip)
{
if (rip) free(rip);
}
Loading