Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:jgm/peg-markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Jan 19, 2009
2 parents c33826b + e7a83fe commit b6c7aac
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
61 changes: 61 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ It is released under the GPL; see LICENSE for details.
Installing
==========

On a linux or unix-based system
-------------------------------

This program is written in portable ANSI C. It requires
[glib2](http://www.gtk.org/download.html). Most *nix systems will have
this installed already. The build system requires GNU make.
Expand Down Expand Up @@ -63,6 +66,64 @@ following blank line. This is consistent with the official markdown
syntax description, and lets the author of the document choose whether
`<p>` tags are desired.

Cross-compiling for Windows with MinGW on a linux box
-----------------------------------------------------

Prerequisites:

* Linux system with MinGW cross compiler For Ubuntu:

sudo apt-get install mingw32

* [Windows glib-2.0 binary & development files](http://www.gtk.org/download-windows.html).
Unzip files into cross-compiler directory tree (e.g., `/usr/i586-mingw32msvc`).

Steps:

1. Create the markdown parser using Linux-compiled `leg` from peg-0.1.4:

./peg-0.1.4/leg markdown_parser.leg >markdown_parser.c

(Note: The same thing could be accomplished by cross-compiling leg,
executing it on Windows, and copying the resulting C file to the Linux
cross-compiler host.)

2 Run the cross compiler with include flag for the Windows glib-2.0 headers:
for example,

/usr/bin/i586-mingw32msvc-cc -c \
-I/usr/i586-mingw32msvc/include/glib-2.0 \
-I/usr/i586-mingw32msvc/lib/glib-2.0/include -Wall -O3 -ansi markdown*.c

3. Link against Windows glib-2.0 headers: for example,

/usr/bin/i586-mingw32msvc-cc markdown*.o \
-Wl,-L/usr/i586-mingw32msvc/lib/glib,--dy,--warn-unresolved-symbols,-lglib-2.0 \
-o markdown.exe

The resulting executable depends on the glib dll file, so be sure to
load the glib binary on the Windows host.

Compiling with MinGW on Windows
-------------------------------

These directions assume that MinGW is installed in `c:\MinGW` and glib-2.0
is installed in the MinGW directory hierarchy (with the mingw bin directory
in the system path).

Unzip peg-markdown in a temp directory. From the directory with the
peg-markdown source, execute:

cd peg-0.1.4
for %i in (*.c) do @gcc -g -Wall -O3 -DNDEBUG -c -o %~ni.o %i
gcc -o leg.exe leg.o tree.o compile.o
cd ..
peg-0.1.4\leg.exe markdown_parser.leg >markdown_parser.c
@for %i in (markdown*.c) do @gcc -mms-bitfields -Ic:/MinGW/include/glib-2.0 -Ic:/MinGW/lib/glib-2.0/include -c -o %~ni.o %i
gcc -O3 -Lc:/MinGW/lib/glib-2.0 -lglib-2.0 -lintl markdown.o markdown_lib.o markdown_output.o markdown_parser.o -o markdown.exe -Wl,--dy,--warn-unresolved-symbols,-lglib-2.0,-Lc:/MinGW/lib/glib-2.0,-lglib-2.0,-lintl

(Windows instructions courtesy of Matt Wolf.)

Extensions
==========

Expand Down
2 changes: 1 addition & 1 deletion markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int extensions;
***********************************************************************/

#define VERSION "0.4.2"
#define VERSION "0.4.3"
#define COPYRIGHT "Copyright (c) 2008 John MacFarlane.\n" \
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n" \
"This is free software: you are free to change and redistribute it.\n" \
Expand Down
8 changes: 7 additions & 1 deletion utility_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ static bool extension(int ext) {
/* match_inlines - returns true if inline lists match (case-insensitive...) */
static bool match_inlines(element *l1, element *l2) {
while (l1 != NULL && l2 != NULL) {
if (l1->key != l2->key)
if (l1->key != l2->key)
return false;
switch (l1->key) {
case SPACE:
case LINEBREAK:
case ELLIPSIS:
case EMDASH:
case ENDASH:
case APOSTROPHE:
break;
case CODE:
case STR:
Expand All @@ -142,6 +146,8 @@ static bool match_inlines(element *l1, element *l2) {
case EMPH:
case STRONG:
case LIST:
case SINGLEQUOTED:
case DOUBLEQUOTED:
if (match_inlines(l1->children, l2->children))
break;
else
Expand Down

0 comments on commit b6c7aac

Please sign in to comment.