Commit 03d27c82 authored by Alessandro Ghedini's avatar Alessandro Ghedini

Imported Upstream version 2.1.7

parent 1e52b9de
......@@ -10,7 +10,7 @@ are met:
2. Redistributions in binary form must reproduce the original copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither my name (David L Parsons) nor the names of contributors to
3. Neither my name (David L Parsons) nor the names of contributors to
this code may be used to endorse or promote products derived
from this work without specific prior written permission.
......
......@@ -64,7 +64,7 @@ $(DESTDIR)$(LIBDIR):
@INSTALL_DIR@ $(DESTDIR)$(LIBDIR)
version.o: version.c VERSION
$(CC) -DVERSION=\"`cat VERSION`\" -c version.c
$(CC) $(CFLAGS) -DVERSION=\"`cat VERSION`\" -c version.c
VERSION:
@true
......@@ -76,23 +76,23 @@ blocktags: mktags
# example programs
@THEME@theme: theme.o $(MKDLIB) mkdio.h
@THEME@ $(CC) $(LFLAGS) -o theme theme.o pgm_options.o -lmarkdown @LIBS@
@THEME@ $(CC) $(CFLAGS) $(LFLAGS) -o theme theme.o pgm_options.o -lmarkdown @LIBS@
mkd2html: mkd2html.o $(MKDLIB) mkdio.h
$(CC) $(LFLAGS) -o mkd2html mkd2html.o -lmarkdown @LIBS@
$(CC) $(CFLAGS) $(LFLAGS) -o mkd2html mkd2html.o -lmarkdown @LIBS@
markdown: main.o pgm_options.o $(MKDLIB)
$(CC) $(LFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@
$(CC) $(CFLAGS) $(LFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@
makepage: makepage.c pgm_options.o $(MKDLIB) mkdio.h
$(CC) $(LFLAGS) -o makepage makepage.c pgm_options.o -lmarkdown @LIBS@
$(CC) $(CFLAGS) $(LFLAGS) -o makepage makepage.c pgm_options.o -lmarkdown @LIBS@
pgm_options.o: pgm_options.c mkdio.h config.h
$(CC) -I. -c pgm_options.c
$(CC) $(CFLAGS) -I. -c pgm_options.c
main.o: main.c mkdio.h config.h
$(CC) -I. -c main.c
$(CC) $(CFLAGS) -I. -c main.c
$(MKDLIB): $(OBJS)
./librarian.sh make $(MKDLIB) VERSION $(OBJS)
......
......@@ -868,6 +868,18 @@ AC_C_INLINE() {
# AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints.
#
AC_SCALAR_TYPES () {
rc=1
LOGN "defining WORD & DWORD scalar types"
if AC_QUIET AC_CHECK_HEADERS WinDef.h; then
# windows machine; BYTE, WORD, DWORD already
# defined
echo "#include <WinDef.h>" >> $__cwd/config.h
TLOG " (defined in WinDef.h)"
return 0
fi
cat > ngc$$.c << EOF
#include <stdio.h>
#include <string.h>
......@@ -908,8 +920,6 @@ char **argv;
exit(0);
}
EOF
rc=1
LOGN "defining WORD & DWORD scalar types"
if $AC_CC ngc$$.c -o ngc$$; then
while [ "$1" ]; do
case "$1" in
......@@ -933,6 +943,7 @@ EOF
0) TLOG "" ;;
*) AC_FAIL " ** FAILED **" ;;
esac
return $rc
}
......
......@@ -73,6 +73,10 @@ isthisspace(MMIOT *f, int i)
{
int c = peek(f, i);
if ( c == EOF )
return 1;
if ( c & 0x80 )
return 0;
return isspace(c) || (c < ' ');
}
......@@ -1582,11 +1586,17 @@ printblock(Paragraph *pp, MMIOT *f)
static void
printcode(Line *t, MMIOT *f)
printcode(Line *t, char *lang, MMIOT *f)
{
int blanks;
Qstring("<pre><code>", f);
Qstring("<pre><code", f);
if (lang) {
Qstring(" class=\"", f);
Qstring(lang, f);
Qstring("\"", f);
}
Qstring(">", f);
for ( blanks = 0; t ; t = t->next ) {
if ( S(t->text) > t->dle ) {
while ( blanks ) {
......@@ -1699,7 +1709,7 @@ display(Paragraph *p, MMIOT *f)
break;
case CODE:
printcode(p->text, f);
printcode(p->text, p->lang, f);
break;
case QUOTE:
......
......@@ -177,6 +177,9 @@ splitline(Line *t, int cutpoint)
}
#define UNCHECK(l) ((l)->flags &= ~CHECKED)
#define UNLESS_FENCED(t) if (fenced) { \
other = 1; l->count += (c == ' ' ? 0 : -1); \
} else { t; }
/*
* walk a line, seeing if it's any of half a dozen interesting regular
......@@ -188,8 +191,8 @@ checkline(Line *l)
int eol, i;
int dashes = 0, spaces = 0,
equals = 0, underscores = 0,
stars = 0, tildes = 0,
backticks = 0;
stars = 0, tildes = 0, other = 0,
backticks = 0, fenced = 0;
l->flags |= CHECKED;
l->kind = chk_text;
......@@ -206,16 +209,19 @@ checkline(Line *l)
if ( c != ' ' ) l->count++;
switch (c) {
case '-': dashes = 1; break;
case ' ': spaces = 1; break;
case '-': UNLESS_FENCED(dashes = 1); break;
case ' ': UNLESS_FENCED(spaces = 1); break;
case '=': equals = 1; break;
case '_': underscores = 1; break;
case '_': UNLESS_FENCED(underscores = 1); break;
case '*': stars = 1; break;
#if WITH_FENCED_CODE
case '~': tildes = 1; break;
case '`': backticks = 1; break;
case '~': if (other) return; fenced = 1; tildes = 1; break;
case '`': if (other) return; fenced = 1; backticks = 1; break;
#endif
default: return;
default:
other = 1;
l->count--;
if (!fenced) return;
}
}
......@@ -638,6 +644,14 @@ fencedcodeblock(ParagraphRoot *d, Line **ptr)
if ( iscodefence(r->next, first->count, first->kind) ) {
(*ptr) = r->next->next;
ret = Pp(d, first->next, CODE);
if (S(first->text) - first->count > 0) {
char *lang_attr = T(first->text) + first->count;
while ( *lang_attr != 0 && *lang_attr == ' ' ) lang_attr++;
ret->lang = strdup(lang_attr);
}
else {
ret->lang = 0;
}
___mkd_freeLine(first);
___mkd_freeLine(r->next);
r->next = 0;
......
......@@ -49,6 +49,7 @@ typedef struct paragraph {
struct paragraph *down; /* recompiled contents of this paragraph */
struct line *text; /* all the text in this paragraph */
char *ident; /* %id% tag for QUOTE */
char *lang; /* lang attribute for CODE */
enum { WHITESPACE=0, CODE, QUOTE, MARKUP,
HTML, STYLE, DL, UL, OL, AL, LISTITEM,
HDR, HR, TABLE, SOURCE } typ;
......
......@@ -81,7 +81,7 @@ char **argv;
CREATE(footers);
pgm = basename(argv[0]);
while ( argc ) {
while ( argc > 1 ) {
if ( strcmp(argv[1], "-css") == 0 ) {
EXPAND(css) = argv[2];
argc -= 2;
......
......@@ -51,6 +51,8 @@ ___mkd_freeParagraph(Paragraph *p)
___mkd_freeLines(p->text);
if (p->ident)
free(p->ident);
if (p->lang)
free(p->lang);
free(p);
}
......
......@@ -26,6 +26,9 @@ mkd_define_tag(char *id, int selfclose)
* either the standard or extra tag tables.
*/
if ( !(p = mkd_search_tags(id, strlen(id))) ) {
/* extratags could be deallocated */
if ( S(extratags) == 0 )
CREATE(extratags);
p = &EXPAND(extratags);
p->id = id;
p->size = strlen(id);
......
......@@ -100,6 +100,55 @@ code
code
~~~</p>'
try 'fenced code block with lang attribute' \
'```lang
code
```' \
'<pre><code class="lang">code
</code></pre>'
try 'fenced code block with lang-name attribute' \
'```lang-name
code
```' \
'<pre><code class="lang-name">code
</code></pre>'
try 'fenced code block with lang_name attribute' \
'```lang_name
code
```' \
'<pre><code class="lang_name">code
</code></pre>'
try 'fenced code block with lang attribute and space' \
'``` lang
code
```' \
'<pre><code class="lang">code
</code></pre>'
try 'fenced code block with lang attribute and multiple spaces' \
'``` lang
code
```' \
'<pre><code class="lang">code
</code></pre>'
try 'fenced code block with lang-name attribute and space' \
'``` lang-name
code
```' \
'<pre><code class="lang-name">code
</code></pre>'
try 'fenced code block with lang_name attribute and space' \
'``` lang_name
code
```' \
'<pre><code class="lang_name">code
</code></pre>'
fi
summary $0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment