Skip to content
Browse files

Working Markdown support

  • Loading branch information...
1 parent 6d7d6bd commit 8d5540c28b080bf075e32eb6462eb718a95a67f1 @hiddenmemory committed Apr 5, 2012
Showing with 18,283 additions and 7 deletions.
  1. +19 −0 Discount/discount-config/README.markdown
  2. +28 −0 Discount/discount-config/config.h
  3. +108 −0 Discount/discount-config/mkdio.h
  4. +33 −0 Discount/discount-config/update.sh
  5. +47 −0 Discount/discount/COPYRIGHT
  6. +33 −0 Discount/discount/CREDITS
  7. +61 −0 Discount/discount/Csio.c
  8. +41 −0 Discount/discount/INSTALL
  9. +130 −0 Discount/discount/Makefile.in
  10. +40 −0 Discount/discount/Plan9/README
  11. +169 −0 Discount/discount/Plan9/markdown.1
  12. +332 −0 Discount/discount/Plan9/markdown.2
  13. +543 −0 Discount/discount/Plan9/markdown.6
  14. +37 −0 Discount/discount/Plan9/mkfile
  15. +16 −0 Discount/discount/README
  16. +1 −0 Discount/discount/VERSION
  17. +111 −0 Discount/discount/amalloc.c
  18. +29 −0 Discount/discount/amalloc.h
  19. +43 −0 Discount/discount/basename.c
  20. +1,678 −0 Discount/discount/configure.inc
  21. +146 −0 Discount/discount/configure.sh
  22. +85 −0 Discount/discount/css.c
  23. +77 −0 Discount/discount/cstring.h
  24. +49 −0 Discount/discount/docheader.c
  25. +152 −0 Discount/discount/dumptree.c
  26. +188 −0 Discount/discount/emmatch.c
  27. +84 −0 Discount/discount/flags.c
  28. +1,747 −0 Discount/discount/generate.c
  29. +24 −0 Discount/discount/html5.c
  30. +198 −0 Discount/discount/main.c
  31. +45 −0 Discount/discount/makepage.1
  32. +87 −0 Discount/discount/makepage.c
  33. +171 −0 Discount/discount/markdown.1
  34. +137 −0 Discount/discount/markdown.3
  35. +1,020 −0 Discount/discount/markdown.7
  36. +1,237 −0 Discount/discount/markdown.c
  37. +183 −0 Discount/discount/markdown.h
  38. +71 −0 Discount/discount/mkd-callbacks.3
  39. +205 −0 Discount/discount/mkd-extensions.7
  40. +186 −0 Discount/discount/mkd-functions.3
  41. +41 −0 Discount/discount/mkd-line.3
  42. +52 −0 Discount/discount/mkd2html.1
  43. +185 −0 Discount/discount/mkd2html.c
  44. +357 −0 Discount/discount/mkdio.c
  45. +108 −0 Discount/discount/mkdio.h.in
  46. +157 −0 Discount/discount/resource.c
  47. +47 −0 Discount/discount/setup.c
  48. +123 −0 Discount/discount/tags.c
  49. +19 −0 Discount/discount/tags.h
  50. +27 −0 Discount/discount/tests/autolink.t
  51. +27 −0 Discount/discount/tests/automatic.t
  52. +16 −0 Discount/discount/tests/backslash.t
  53. +17 −0 Discount/discount/tests/callbacks.t
  54. +13 −0 Discount/discount/tests/chrome.text
  55. +35 −0 Discount/discount/tests/code.t
  56. +29 −0 Discount/discount/tests/compat.t
  57. +31 −0 Discount/discount/tests/crash.t
  58. +49 −0 Discount/discount/tests/div.t
  59. +96 −0 Discount/discount/tests/dl.t
  60. +9 −0 Discount/discount/tests/embedlinks.text
  61. +19 −0 Discount/discount/tests/emphasis.t
  62. +35 −0 Discount/discount/tests/extrafootnotes.t
  63. +33 −0 Discount/discount/tests/flow.t
  64. +16 −0 Discount/discount/tests/footnotes.t
  65. +80 −0 Discount/discount/tests/functions.sh
  66. +26 −0 Discount/discount/tests/header.t
  67. +141 −0 Discount/discount/tests/html.t
  68. +17 −0 Discount/discount/tests/html5.t
  69. +14 −0 Discount/discount/tests/links.text
  70. +130 −0 Discount/discount/tests/linkylinky.t
  71. +21 −0 Discount/discount/tests/linkypix.t
  72. +155 −0 Discount/discount/tests/list.t
  73. +38 −0 Discount/discount/tests/list3deep.t
  74. +12 −0 Discount/discount/tests/misc.t
  75. +44 −0 Discount/discount/tests/pandoc.t
  76. +19 −0 Discount/discount/tests/para.t
  77. +12 −0 Discount/discount/tests/paranoia.t
  78. +77 −0 Discount/discount/tests/peculiarities.t
  79. +20 −0 Discount/discount/tests/pseudo.t
  80. +27 −0 Discount/discount/tests/reddit.t
  81. +14 −0 Discount/discount/tests/reparse.t
  82. +91 −0 Discount/discount/tests/schiraldi.t
  83. +24 −0 Discount/discount/tests/smarty.t
  84. +29 −0 Discount/discount/tests/snakepit.t
  85. +15 −0 Discount/discount/tests/strikethrough.t
  86. +34 −0 Discount/discount/tests/style.t
  87. +17 −0 Discount/discount/tests/superscript.t
  88. +897 −0 Discount/discount/tests/syntax.text
  89. +211 −0 Discount/discount/tests/tables.t
  90. +48 −0 Discount/discount/tests/tabstop.t
  91. +76 −0 Discount/discount/tests/toc.t
  92. +18 −0 Discount/discount/tests/xml.t
  93. +142 −0 Discount/discount/theme.1
  94. +609 −0 Discount/discount/theme.c
  95. +103 −0 Discount/discount/toc.c
  96. +11 −0 Discount/discount/tools/checkbits.sh
  97. +38 −0 Discount/discount/tools/cols.c
  98. +24 −0 Discount/discount/tools/echo.c
  99. +27 −0 Discount/discount/version.c.in
  100. +82 −0 Discount/discount/xml.c
  101. +48 −0 Discount/discount/xmlpage.c
  102. +12 −0 Discount/discount_wrappers/Discount.h
  103. +10 −0 Discount/discount_wrappers/discountWrapper.h
  104. +36 −0 Discount/discount_wrappers/discountWrapper.m
  105. +20 −0 Discount/discount_wrappers/markdownWrapper.c
  106. +14 −0 Discount/discount_wrappers/markdownWrapper.h
  107. +19 −0 Discount/discount_wrappers/mkdioWrapper.c
  108. +14 −0 Discount/discount_wrappers/mkdioWrapper.h
  109. +22 −0 Tests/Test01.txt
  110. +207 −1 Tipi.xcodeproj/project.pbxproj
  111. +43 −0 Tipi/NSString+HiddenMemory.h
  112. +278 −0 Tipi/NSString+HiddenMemory.m
  113. +295 −0 Tipi/RegexKitLite.h
  114. +2,636 −0 Tipi/RegexKitLite.m
  115. +13 −0 Tipi/TPMarkdownDataParser.h
  116. +25 −0 Tipi/TPMarkdownDataParser.m
  117. +13 −0 Tipi/TPParser.h
  118. +17 −0 Tipi/TPParser.m
  119. +13 −0 Tipi/TPTextDataParser.h
  120. +67 −0 Tipi/TPTextDataParser.m
  121. +6 −6 Tipi/main.m
View
19 Discount/discount-config/README.markdown
@@ -0,0 +1,19 @@
+# [Discount][] instructions #
+
+This folder holds the files generated by discount's `configure.sh` script that are used by MarkdownLive.
+
+## Upgrading discount ##
+
+Discount is included as a [fake submodule][]. To upgrade or test other versions of discount, delete the files in the `discount` directory and clone a new local repository into it:
+
+ rm -rf discount/
+ git clone git://github.com/Orc/discount.git discount
+
+## Config files ##
+
+When discount is changed, regenerate the config files. The included `update.sh` script should do this automatically.
+
+If you want to update the files by hand, remove the "configuration for markdown, generated" comments at the head of `config.h` to avoid adding needless patches to the git history.
+
+[discount]:https://github.com/Orc/discount
+[fake submodule]:http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb
View
28 Discount/discount-config/config.h
@@ -0,0 +1,28 @@
+/*
+ * configuration for markdown, generated Mon 11 Jul 2011 22:16:51 BST
+ * by Jonathan@macbook-pro.local
+ */
+#ifndef __AC_MARKDOWN_D
+#define __AC_MARKDOWN_D 1
+
+
+#define OS_DARWIN 1
+#define USE_DISCOUNT_DL 1
+#define DWORD unsigned int
+#define WORD unsigned short
+#define BYTE unsigned char
+#define HAVE_PWD_H 1
+#define HAVE_GETPWUID 1
+#define HAVE_SRANDOM 1
+#define INITRNG(x) srandom((unsigned int)x)
+#define HAVE_BZERO 1
+#define HAVE_RANDOM 1
+#define COINTOSS() (random()&1)
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_FCHDIR 1
+#define TABSTOP 4
+#define PATH_FIND "/usr/bin/find"
+#define PATH_SED "/usr/bin/sed"
+
+#endif/* __AC_MARKDOWN_D */
View
108 Discount/discount-config/mkdio.h
@@ -0,0 +1,108 @@
+#ifndef _MKDIO_D
+#define _MKDIO_D
+
+#include <stdio.h>
+
+typedef void MMIOT;
+
+typedef unsigned int mkd_flag_t;
+
+/* line builder for markdown()
+ */
+MMIOT *mkd_in(FILE*,mkd_flag_t); /* assemble input from a file */
+MMIOT *mkd_string(const char*,int,mkd_flag_t); /* assemble input from a buffer */
+
+void mkd_basename(MMIOT*,char*);
+
+void mkd_initialize();
+void mkd_with_html5_tags();
+void mkd_shlib_destructor();
+
+/* compilation, debugging, cleanup
+ */
+int mkd_compile(MMIOT*, mkd_flag_t);
+int mkd_cleanup(MMIOT*);
+
+/* markup functions
+ */
+int mkd_dump(MMIOT*, FILE*, int, char*);
+int markdown(MMIOT*, FILE*, mkd_flag_t);
+int mkd_line(char *, int, char **, mkd_flag_t);
+typedef int (*mkd_sta_function_t)(const int,const void*);
+void mkd_string_to_anchor(char *, int, mkd_sta_function_t, void*, int);
+int mkd_xhtmlpage(MMIOT*,int,FILE*);
+
+/* header block access
+ */
+char* mkd_doc_title(MMIOT*);
+char* mkd_doc_author(MMIOT*);
+char* mkd_doc_date(MMIOT*);
+
+/* compiled data access
+ */
+int mkd_document(MMIOT*, char**);
+int mkd_toc(MMIOT*, char**);
+int mkd_css(MMIOT*, char **);
+int mkd_xml(char *, int, char **);
+
+/* write-to-file functions
+ */
+int mkd_generatehtml(MMIOT*,FILE*);
+int mkd_generatetoc(MMIOT*,FILE*);
+int mkd_generatexml(char *, int,FILE*);
+int mkd_generatecss(MMIOT*,FILE*);
+#define mkd_style mkd_generatecss
+int mkd_generateline(char *, int, FILE*, mkd_flag_t);
+#define mkd_text mkd_generateline
+
+/* url generator callbacks
+ */
+typedef char * (*mkd_callback_t)(const char*, const int, void*);
+typedef void (*mkd_free_t)(char*, void*);
+
+void mkd_e_url(void *, mkd_callback_t);
+void mkd_e_flags(void *, mkd_callback_t);
+void mkd_e_free(void *, mkd_free_t );
+void mkd_e_data(void *, void *);
+
+/* version#.
+ */
+extern char markdown_version[];
+void mkd_mmiot_flags(FILE *, MMIOT *, int);
+void mkd_flags_are(FILE*, mkd_flag_t, int);
+
+void mkd_ref_prefix(MMIOT*, char*);
+
+
+/* special flags for markdown() and mkd_text()
+ */
+#define MKD_NOLINKS 0x00000001 /* don't do link processing, block <a> tags */
+#define MKD_NOIMAGE 0x00000002 /* don't do image processing, block <img> */
+#define MKD_NOPANTS 0x00000004 /* don't run smartypants() */
+#define MKD_NOHTML 0x00000008 /* don't allow raw html through AT ALL */
+#define MKD_STRICT 0x00000010 /* disable SUPERSCRIPT, RELAXED_EMPHASIS */
+#define MKD_TAGTEXT 0x00000020 /* process text inside an html tag; no
+ * <em>, no <bold>, no html or [] expansion */
+#define MKD_NO_EXT 0x00000040 /* don't allow pseudo-protocols */
+#define MKD_CDATA 0x00000080 /* generate code for xml ![CDATA[...]] */
+#define MKD_NOSUPERSCRIPT 0x00000100 /* no A^B */
+#define MKD_NORELAXED 0x00000200 /* emphasis happens /everywhere/ */
+#define MKD_NOTABLES 0x00000400 /* disallow tables */
+#define MKD_NOSTRIKETHROUGH 0x00000800 /* forbid ~~strikethrough~~ */
+#define MKD_TOC 0x00001000 /* do table-of-contents processing */
+#define MKD_1_COMPAT 0x00002000 /* compatibility with MarkdownTest_1.0 */
+#define MKD_AUTOLINK 0x00004000 /* make http://foo.com link even without <>s */
+#define MKD_SAFELINK 0x00008000 /* paranoid check for link protocol */
+#define MKD_NOHEADER 0x00010000 /* don't process header blocks */
+#define MKD_TABSTOP 0x00020000 /* expand tabs to 4 spaces */
+#define MKD_NODIVQUOTE 0x00040000 /* forbid >%class% blocks */
+#define MKD_NOALPHALIST 0x00080000 /* forbid alphabetic lists */
+#define MKD_NODLIST 0x00100000 /* forbid definition lists */
+#define MKD_EXTRA_FOOTNOTE 0x00200000 /* enable markdown extra-style footnotes */
+#define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
+
+/* special flags for mkd_in() and mkd_string()
+ */
+
+
+#endif/*_MKDIO_D*/
View
33 Discount/discount-config/update.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+status_msg () {
+ echo -e "\033[1m$1\033[0m"
+}
+
+error_msg () {
+ echo -e "\033[31m$1\033[0m" >&2
+ tput sgr0
+}
+
+status_msg "Running configure.sh..."
+
+cd `dirname $0`/../discount/
+./configure.sh
+
+status_msg "Copying important files..."
+
+if head -n 1 config.h | grep -q "^/\*$"; then
+ # remove generated comments in config.h
+ sed '1,/^ *\*\/ *$/ { d; }' <config.h >../discount-config/config.h && echo 'config.h'
+else
+ cp config.h ../discount-config/config.h && echo 'config.h'
+ error_msg "Can't locate config.h comments!"
+ error_msg "Check the diff before committing (and fix this script if you can)"
+fi
+cp mkdio.h ../discount-config/mkdio.h && echo 'mkdio.h'
+
+status_msg "Clean files from working directory..."
+
+git clean -f
+
+status_msg "Done!"
View
47 Discount/discount/COPYRIGHT
@@ -0,0 +1,47 @@
+->Copyright (C) 2007 David Loren Parsons.
+All rights reserved.<-
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation files
+(the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicence, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution, and in the same place and form as other
+ copyright, license and disclaimer information.
+
+ 3. The end-user documentation included with the redistribution, if
+ any, must include the following acknowledgment:
+
+ This product includes software developed by
+ David Loren Parsons <http://www.pell.portland.or.us/~orc>
+
+ in the same place and form as other third-party acknowledgments.
+ Alternately, this acknowledgment may appear in the software
+ itself, in the same form and location as other such third-party
+ acknowledgments.
+
+ 4. Except as contained in this notice, the name of David Loren
+ Parsons shall not be used in advertising or otherwise to promote
+ the sale, use or other dealings in this Software without prior
+ written authorization from David Loren Parsons.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL DAVID LOREN PARSONS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
View
33 Discount/discount/CREDITS
@@ -0,0 +1,33 @@
+Discount is primarily my work, but it has only reached the point
+where it is via contributions, critiques, and bug reports from a
+host of other people, some of which are listed before. If your
+name isn't on this list, please remind me
+ -david parsons (orc@pell.chi.il.us)
+
+
+Josh Wood -- Plan9 support.
+Mike Schiraldi -- Reddit style automatic links, MANY MANY MANY
+ bug reports about boundary conditions and
+ places where I didn't get it right.
+Jjgod Jiang -- Table of contents support.
+Petite Abeille -- Many bug reports about places where I didn't
+ get it right.
+Tim Channon -- inspiration for the `mkd_xhtmlpage()` function
+Christian Herenz-- Many bug reports regarding my implementation of
+ `[]()` and `![]()`
+A.S.Bradbury -- Portability bug reports for 64 bit systems.
+Joyent -- Loan of a solaris box so I could get discount
+ working under solaris.
+Ryan Tomayko -- Portability requests (and the rdiscount ruby
+ binding.)
+yidabu -- feedback on the documentation, bug reports
+ against utf-8 support.
+Pierre Joye -- bug reports, php discount binding.
+Masayoshi Sekimura- perl discount binding.
+Jeremy Hinegardner- bug reports about list handling.
+Andrew White -- bug reports about the format of generated urls.
+Steve Huff -- bug reports about Makefile portability (for Fink)
+Ignacio Burgue?o-- bug reports about `>%class%`
+Henrik Nyh -- bug reports about embedded html handling.
+
+
View
61 Discount/discount/Csio.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "cstring.h"
+#include "markdown.h"
+#include "amalloc.h"
+
+
+/* putc() into a cstring
+ */
+void
+Csputc(int c, Cstring *iot)
+{
+ EXPAND(*iot) = c;
+}
+
+
+/* printf() into a cstring
+ */
+int
+Csprintf(Cstring *iot, char *fmt, ...)
+{
+ va_list ptr;
+ int siz=100;
+
+ do {
+ RESERVE(*iot, siz);
+ va_start(ptr, fmt);
+ siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
+ va_end(ptr);
+ } while ( siz > (ALLOCATED(*iot)-S(*iot)) );
+
+ S(*iot) += siz;
+ return siz;
+}
+
+
+/* write() into a cstring
+ */
+int
+Cswrite(Cstring *iot, char *bfr, int size)
+{
+ RESERVE(*iot, size);
+ memcpy(T(*iot)+S(*iot), bfr, size);
+ S(*iot) += size;
+ return size;
+}
+
+
+/* reparse() into a cstring
+ */
+void
+Csreparse(Cstring *iot, char *buf, int size, int flags)
+{
+ MMIOT f;
+ ___mkd_initmmiot(&f, 0);
+ ___mkd_reparse(buf, size, 0, &f);
+ ___mkd_emblock(&f);
+ SUFFIX(*iot, T(f.out), S(f.out));
+ ___mkd_freemmiot(&f, 0);
+}
View
41 Discount/discount/INSTALL
@@ -0,0 +1,41 @@
+
+ HOW TO BUILD AND INSTALL DISCOUNT
+
+1) Unpacking the distribution
+
+The DISCOUNT sources are distributed in tarballs. After extracting from
+the tarball, you should end up with all the source and build files in the
+directory
+ discount-(version)
+
+2) Installing the distribution
+
+DISCOUNT uses configure.sh to set itself up for compilation. To run
+configure, just do ``./configure.sh'' and it will check your system for
+build dependencies and build makefiles for you. If configure.sh finishes
+without complaint, you can then do a ``make'' to compile everything and a
+``make install'' to install the binaries.
+
+Configure.sh has a few options that can be set:
+
+--src=DIR where the source lives (.)
+--prefix=DIR where to install the final product (/usr/local)
+--execdir=DIR where to put executables (prefix/bin)
+--sbindir=DIR where to put static executables (prefix/sbin)
+--confdir=DIR where to put configuration information (/etc)
+--libdir=DIR where to put libraries (prefix/lib)
+--libexecdir=DIR where to put private executables
+--mandir=DIR where to put manpages
+--enable-dl-tag Use the DL tag extension
+--enable-pandoc-header Use pandoc-style header blocks
+--enable-superscript A^B expands to A<sup>B</sup>
+--enable-amalloc Use a debugging memory allocator (to detect leaks)
+--relaxed-emphasis Don't treat _ in the middle of a word as emphasis
+--with-tabstops=N Set tabstops to N characters (default is 4)
+
+3) Installing sample programs and manpages
+
+The standard ``make install'' rule just installs the binaries. If you
+want to install the sample programs, they are installed with
+``make install.samples''; to install manpages, ``make install.man''.
+A shortcut to install everything is ``make install.everything''
View
130 Discount/discount/Makefile.in
@@ -0,0 +1,130 @@
+CC=@CC@ -I. -L.
+CFLAGS=@CFLAGS@
+AR=@AR@
+RANLIB=@RANLIB@
+
+BINDIR=@exedir@
+MANDIR=@mandir@
+LIBDIR=@libdir@
+INCDIR=@prefix@/include
+
+PGMS=markdown
+SAMPLE_PGMS=mkd2html makepage
+@THEME@SAMPLE_PGMS+= theme
+MKDLIB=libmarkdown
+OBJS=mkdio.o markdown.o dumptree.o generate.o \
+ resource.o docheader.o version.o toc.o css.o \
+ xml.o Csio.o xmlpage.o basename.o emmatch.o \
+ setup.o tags.o html5.o flags.o @AMALLOC@
+TESTFRAMEWORK=echo cols
+
+MAN3PAGES=mkd-callbacks.3 mkd-functions.3 markdown.3 mkd-line.3
+
+all: $(PGMS) $(SAMPLE_PGMS) $(TESTFRAMEWORK)
+
+install: $(PGMS) $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(LIBDIR) $(DESTDIR)/$(INCDIR)
+ @INSTALL_PROGRAM@ $(PGMS) $(DESTDIR)/$(BINDIR)
+ ./librarian.sh install libmarkdown VERSION $(DESTDIR)/$(LIBDIR)
+ @INSTALL_DATA@ mkdio.h $(DESTDIR)/$(INCDIR)
+
+install.everything: install install.samples install.man
+
+install.samples: $(SAMPLE_PGMS) install $(DESTDIR)/$(BINDIR)
+ @INSTALL_PROGRAM@ $(SAMPLE_PGMS) $(DESTDIR)/$(BINDIR)
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1
+ @INSTALL_DATA@ theme.1 makepage.1 mkd2html.1 $(DESTDIR)/$(MANDIR)/man1
+
+install.man:
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man3
+ @INSTALL_DATA@ $(MAN3PAGES) $(DESTDIR)/$(MANDIR)/man3
+ for x in mkd_line mkd_generateline; do \
+ ( echo '.\"' ; echo ".so man3/mkd-line.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\
+ done
+ for x in mkd_in mkd_string; do \
+ ( echo '.\"' ; echo ".so man3/markdown.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3;\
+ done
+ for x in mkd_compile mkd_css mkd_generatecss mkd_generatehtml mkd_cleanup mkd_doc_title mkd_doc_author mkd_doc_date; do \
+ ( echo '.\"' ; echo ".so man3/mkd-functions.3" ) > $(DESTDIR)/$(MANDIR)/man3/$$x.3; \
+ done
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man7
+ @INSTALL_DATA@ markdown.7 mkd-extensions.7 $(DESTDIR)/$(MANDIR)/man7
+ @INSTALL_DIR@ $(DESTDIR)/$(MANDIR)/man1
+ @INSTALL_DATA@ markdown.1 $(DESTDIR)/$(MANDIR)/man1
+
+install.everything: install install.man
+
+$(DESTDIR)/$(BINDIR):
+ @INSTALL_DIR@ $(DESTDIR)/$(BINDIR)
+
+$(DESTDIR)/$(INCDIR):
+ @INSTALL_DIR@ $(DESTDIR)/$(INCDIR)
+
+$(DESTDIR)/$(LIBDIR):
+ @INSTALL_DIR@ $(DESTDIR)/$(LIBDIR)
+
+version.o: version.c VERSION
+ $(CC) -DVERSION=\"`cat VERSION`\" -c version.c
+
+# example programs
+@THEME@theme: theme.o $(MKDLIB) mkdio.h
+@THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@
+
+
+mkd2html: mkd2html.o $(MKDLIB) mkdio.h
+ $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@
+
+markdown: main.o pgm_options.o $(MKDLIB)
+ $(CC) $(CFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@
+
+makepage: makepage.c pgm_options.o $(MKDLIB) mkdio.h
+ $(CC) $(CFLAGS) -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
+
+main.o: main.c mkdio.h config.h
+ $(CC) -I. -c main.c
+
+$(MKDLIB): $(OBJS)
+ ./librarian.sh make $(MKDLIB) VERSION $(OBJS)
+
+verify: echo tools/checkbits.sh
+ @./echo -n "headers ... "; tools/checkbits.sh && echo "GOOD"
+
+test: $(PGMS) $(TESTFRAMEWORK) verify
+ @for x in tests/*.t; do \
+ @LD_LIBRARY_PATH@=`pwd` sh $$x || exit 1; \
+ done
+
+cols: tools/cols.c config.h
+ $(CC) -o cols tools/cols.c
+echo: tools/echo.c config.h
+ $(CC) -o echo tools/echo.c
+
+clean:
+ rm -f $(PGMS) $(TESTFRAMEWORK) $(SAMPLE_PGMS) *.o
+ rm -f $(MKDLIB) `./librarian.sh files $(MKDLIB) VERSION`
+
+distclean spotless: clean
+ rm -f @GENERATED_FILES@ @CONFIGURE_FILES@
+
+Csio.o: Csio.c cstring.h amalloc.h config.h markdown.h
+amalloc.o: amalloc.c
+basename.o: basename.c config.h cstring.h amalloc.h markdown.h
+css.o: css.c config.h cstring.h amalloc.h markdown.h
+docheader.o: docheader.c config.h cstring.h amalloc.h markdown.h
+dumptree.o: dumptree.c markdown.h cstring.h amalloc.h config.h
+emmatch.o: emmatch.c config.h cstring.h amalloc.h markdown.h
+generate.o: generate.c config.h cstring.h amalloc.h markdown.h
+main.o: main.c config.h amalloc.h
+pgm_options.o: pgm_options.c pgm_options.h config.h amalloc.h
+makepage.o: makepage.c
+markdown.o: markdown.c config.h cstring.h amalloc.h markdown.h
+mkd2html.o: mkd2html.c config.h mkdio.h cstring.h amalloc.h
+mkdio.o: mkdio.c config.h cstring.h amalloc.h markdown.h
+resource.o: resource.c config.h cstring.h amalloc.h markdown.h
+theme.o: theme.c config.h mkdio.h cstring.h amalloc.h
+toc.o: toc.c config.h cstring.h amalloc.h markdown.h
+version.o: version.c config.h
+xml.o: xml.c config.h cstring.h amalloc.h markdown.h
+xmlpage.o: xmlpage.c config.h cstring.h amalloc.h markdown.h
View
40 Discount/discount/Plan9/README
@@ -0,0 +1,40 @@
+% Discount on Plan 9
+% Josh Wood
+% 2009-06-12
+
+# *Discount* Markdown compiler on Plan 9
+
+## Build
+
+ % CONFIG='--enable-all-features' mk config
+ % mk install
+ % markdown -V
+ markdown: discount X.Y.Z DL_TAG HEADER DEBUG SUPERSCRIPT RELAXED DIV
+
+`--enable-all-features` may be replaced by zero or more of:
+
+ --enable-dl-tag Use the DL tag extension
+ --enable-pandoc-header Use pandoc-style header blocks
+ --enable-superscript A^B becomes A<sup>B</sup>
+ --enable-amalloc Enable memory allocation debugging
+ --relaxed-emphasis underscores aren't special in the middle of words
+ --with-tabstops=N Set tabstops to N characters (default is 4)
+ --enable-div Enable >%id% divisions
+ --enable-alpha-list Enable (a)/(b)/(c) lists
+ --enable-all-features Turn on all stable optional features
+
+## Notes
+
+The supplied mkfile merely drives Discount's own configure script and
+then APE's *psh* environment to build the Discount source, then copies
+the result(s) to locations appropriate for system-wide use on Plan 9.
+There are a few other *mk*(1) targets:
+
+`install.libs`: Discount includes a C library and header.
+Installation is optional. Plan 9 binaries are statically linked.
+
+`install.man`: Add manual pages for markdown(1) and (6).
+
+`install.progs`: Extra programs. *makepage* writes complete XHTML
+documents, rather than fragments. *mkd2html* is similar, but produces
+HTML.
View
169 Discount/discount/Plan9/markdown.1
@@ -0,0 +1,169 @@
+.TH MARKDOWN 1
+.SH NAME
+markdown \- convert Markdown text to HTML
+.SH SYNOPSIS
+.B markdown
+[
+.B -dTV
+]
+[
+.BI -b " url-base
+]
+[
+.BI -F " bitmap
+]
+[
+.BI -f " flags
+]
+[
+.BI -o " ofile
+]
+[
+.BI -s " text
+]
+[
+.BI -t " text
+]
+[
+.I file
+]
+.SH DESCRIPTION
+The
+.I markdown
+utility reads the
+.IR Markdown (6)-formatted
+.I file
+(or standard input) and writes its
+.SM HTML
+fragment representation on standard output.
+.PP
+The options are:
+.TF dfdoptions
+.TP
+.BI -b " url-base
+Links in source begining with
+.B /
+will be prefixed with
+.I url-base
+in the output.
+.TP
+.B -d
+Instead of printing an
+.SM HTML
+fragment, print a parse tree.
+.TP
+.BI -F " bitmap
+Set translation flags.
+.I Bitmap
+is a bit map of the various configuration options described in
+.IR markdown (2).
+.TP
+.BI -f " flags
+Set or clear various translation
+.IR flags ,
+described below.
+.I Flags
+are in a comma-delimited list, with an optional
+.B +
+(set) prefix on each flag.
+.TP
+.BI -o " ofile
+Write the generated
+.SM HTML
+to
+.IR ofile .
+.TP
+.BI -s " text
+Use the
+.IR markdown (2)
+function to format the
+.I text
+on standard input.
+.TP
+.B -T
+Under
+.B -f
+.BR toc ,
+print the table of contents as an unordered list before the usual
+.SM HTML
+output.
+.TP
+.BI -t " text
+Use
+.IR mkd_text
+(in
+.IR markdown (2))
+to format
+.I text
+instead of processing standard input with
+.IR markdown .
+.TP
+.B -V
+Show version number and configuration. If the version includes the string
+.BR DL_TAG ,
+.I markdown
+was configured with definition list support. If the version includes the string
+.BR HEADER ,
+.I markdown
+was configured to support pandoc header blocks.
+.PD
+.SS TRANSLATION FLAGS
+The translation flags understood by
+.B -f
+are:
+.TF \ noheader
+.TP
+.B noimage
+Don't allow image tags.
+.TP
+.B nolinks
+Don't allow links.
+.TP
+.B nohtml
+Don't allow any embedded HTML.
+.TP
+.B cdata
+Generate valid XML output.
+.TP
+.B noheader
+Do not process pandoc headers.
+.TP
+.B notables
+Do not process the syntax extension for tables.
+.TP
+.B tabstops
+Use Markdown-standard 4-space tabstops.
+.TP
+.B strict
+Disable superscript and relaxed emphasis.
+.TP
+.B relax
+Enable superscript and relaxed emphasis (the default).
+.TP
+.B toc
+Enable table of contents support, generated from headings (in
+.IR markdown (6))
+in the source.
+.TP
+.B 1.0
+Revert to Markdown 1.0 compatibility.
+.PD
+.PP
+For example,
+.B -f nolinks,quot
+tells
+.I markdown
+not to allow
+.B <a>
+tags, and to expand double quotes.
+.SH SOURCE
+.B /sys/src/cmd/discount
+.SH SEE ALSO
+.IR markdown (2),
+.IR markdown (6)
+.PP
+http://daringfireball.net/projects/markdown/,
+``Markdown''.
+.SH DIAGNOSTICS
+.I Markdown
+exits 0 on success and >0 if an error occurs.
View
332 Discount/discount/Plan9/markdown.2
@@ -0,0 +1,332 @@
+.TH MARKDOWN 2
+.SH NAME
+mkd_in, mkd_string, markdown, mkd_compile, mkd_css, mkd_generatecss,
+mkd_document, mkd_generatehtml, mkd_xhtmlpage, mkd_toc, mkd_generatetoc,
+mkd_cleanup, mkd_doc_title, mkd_doc_author, mkd_doc_date, mkd_line,
+mkd_generateline \- convert Markdown text to HTML
+.SH SYNOPSIS
+.ta \w'MMIOT* 'u
+.B #include <mkdio.h>
+.PP
+.B
+MMIOT* mkd_in(FILE *input, int flags)
+.PP
+.B
+MMIOT* mkd_string(char *buf, int size, int flags)
+.PP
+.B
+int markdown(MMIOT *doc, FILE *output, int flags)
+.PP
+.B
+int mkd_compile(MMIOT *document, int flags)
+.PP
+.B
+int mkd_css(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatecss(MMIOT *document, FILE *output)
+.PP
+.B
+int mkd_document(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatehtml(MMIOT *document, FILE *output)
+.PP
+.B
+int mkd_xhtmlpage(MMIOT *document, int flags, FILE *output)
+.PP
+.B
+int mkd_toc(MMIOT *document, char **doc)
+.PP
+.B
+int mkd_generatetoc(MMIOT *document, FILE *output)
+.PP
+.B
+void mkd_cleanup(MMIOT*);
+.PP
+.B
+char* mkd_doc_title(MMIOT*)
+.PP
+.B
+char* mkd_doc_author(MMIOT*)
+.PP
+.B
+char* mkd_doc_date(MMIOT*)
+.PP
+.B
+int mkd_line(char *string, int size, char **doc, int flags)
+.PP
+.B
+int mkd_generateline(char *string, int size, FILE *output, int flags)
+.PD
+.PP
+.SH DESCRIPTION
+These functions convert
+.IR Markdown (6)
+text into
+.SM HTML
+markup.
+.PP
+.I Mkd_in
+reads the text referenced by pointer to
+.B FILE
+.I input
+and returns a pointer to an
+.B MMIOT
+structure of the form expected by
+.I markdown
+and the other converters.
+.I Mkd_string
+accepts one
+.I string
+and returns a pointer to
+.BR MMIOT .
+.PP
+After such preparation,
+.I markdown
+converts
+.I doc
+and writes the result to
+.IR output ,
+while
+.I mkd_compile
+transforms
+.I document
+in-place.
+.PP
+One or more of the following
+.I flags
+(combined with
+.BR OR )
+control
+.IR markdown 's
+processing of
+.IR doc :
+.TF MKD_NOIMAGE
+.TP
+.B MKD_NOIMAGE
+Do not process
+.B ![]
+and remove
+.B <img>
+tags from the output.
+.TP
+.B MKD_NOLINKS
+Do not process
+.B []
+and remove
+.B <a>
+tags from the output.
+.TP
+.B MKD_NOPANTS
+Suppress Smartypants-style replacement of quotes, dashes, or ellipses.
+.TP
+.B MKD_STRICT
+Disable superscript and relaxed emphasis processing if configured; otherwise a no-op.
+.TP
+.B MKD_TAGTEXT
+Process as inside an
+.SM HTML
+tag: no
+.BR <em> ,
+no
+.BR <bold> ,
+no
+.SM HTML
+or
+.B []
+expansion.
+.TP
+.B MKD_NO_EXT
+Don't process pseudo-protocols (in
+.IR markdown (6)).
+.TP
+.B MKD_CDATA
+Generate code for
+.SM XML
+.B ![CDATA[...]]
+element.
+.TP
+.B MKD_NOHEADER
+Don't process Pandoc-style headers.
+.TP
+.B MKD_TABSTOP
+When reading documents, expand tabs to 4 spaces, overriding any compile-time configuration.
+.TP
+.B MKD_TOC
+Label headings for use with the
+.I mkd_generatetoc
+and
+.I mkd_toc
+functions.
+.TP
+.B MKD_1_COMPAT
+MarkdownTest_1.0 compatibility. Trim trailing spaces from first line of code blocks and disable implicit reference links (in
+.IR markdown (6)).
+.TP
+.B MKD_AUTOLINK
+Greedy
+.SM URL
+generation. When set, any
+.SM URL
+is converted to a hyperlink, even those not encased in
+.BR <> .
+.TP
+.B MKD_SAFELINK
+Don't make hyperlinks from
+.B [][]
+links that have unknown
+.SM URL
+protocol types.
+.TP
+.B MKD_NOTABLES
+Do not process the syntax extension for tables (in
+.IR markdown (6)).
+.TP
+.B MKD_EMBED
+All of
+.BR MKD_NOLINKS ,
+.BR MKD_NOIMAGE ,
+and
+.BR MKD_TAGTEXT .
+.PD
+.PP
+This implementation supports
+Pandoc-style
+headers and inline
+.SM CSS
+.B <style>
+blocks, but
+.I markdown
+does not access the data provided by these extensions.
+The following functions do, and allow other manipulations.
+.PP
+Given a pointer to
+.B MMIOT
+prepared by
+.I mkd_in
+or
+.IR mkd_string ,
+.I mkd_compile
+compiles the
+.I document
+into
+.BR <style> ,
+Pandoc, and
+.SM HTML
+sections. It accepts the
+.I flags
+described for
+.IR markdown ,
+above.
+.PP
+Once compiled, the document particulars can be read and written:
+.PP
+.I Mkd_css
+allocates a string and populates it with any
+.B <style>
+sections from the document.
+.I Mkd_generatecss
+writes any
+.B <style>
+sections to
+.IR output .
+.PP
+.I Mkd_document
+points
+.I doc
+to the
+.B MMIOT
+.IR document ,
+returning
+.IR document 's
+size.
+.PP
+.I Mkd_generatehtml
+writes the rest of the
+.I document
+to the
+.IR output .
+.PP
+.IR Mkd_doc_title ,
+.IR mkd_doc_author ,
+and
+.I mkd_doc_date
+read the contents of any Pandoc header.
+.PP
+.I Mkd_xhtmlpage
+writes an
+.SM XHTML
+page representation of the document.
+It accepts the
+.I flags
+described for
+.IR markdown ,
+above.
+.PP
+.I Mkd_toc
+.IR malloc s
+a buffer into which it writes an outline, in the form of a
+.B <ul>
+element populated with
+.BR <li> s
+each containing a link to successive headings in the
+.IR document .
+It returns the size of that string.
+.I Mkd_generatetoc
+is similar,
+but writes the outline to the
+.I output
+referenced by a pointer to
+.BR FILE .
+.PP
+.I Mkd_cleanup
+deletes a processed
+.BR MMIOT .
+.PP
+The last two functions convert a single line of markdown source, for example a page title or a signature.
+.I Mkd_line
+allocates a buffer into which it writes an
+.SM HTML
+fragment representation of the
+.IR string .
+.I Mkd_generateline
+writes the result to
+.IR output .
+.SH SOURCE
+.B /sys/src/cmd/discount
+.SH SEE ALSO
+.IR markdown (1),
+.IR markdown (6)
+.SH DIAGNOSTICS
+The
+.I mkd_in
+and
+.I mkd_string
+functions return a pointer to
+.B MMIOT
+on success, null on failure.
+.IR Markdown ,
+.IR mkd_compile ,
+.IR mkd_style ,
+and
+.I mkd_generatehtml
+return
+.B 0
+on success,
+.B -1
+otherwise.
+.SH BUGS
+Error handling is minimal at best.
+.PP
+The
+.B MMIOT
+created by
+.I mkd_string
+is deleted by the
+.I markdown
+function.
+.PP
+This is an
+.SM APE
+library.
View
543 Discount/discount/Plan9/markdown.6
@@ -0,0 +1,543 @@
+.TH MARKDOWN 6
+.SH NAME
+Markdown \- text formatting syntax
+.SH DESCRIPTION
+Markdown
+is a text markup syntax for machine conversion to
+the more complex
+.SM HTML
+or
+.SM XHTML
+markup languages.
+It is intended to be easy to read and to write, with
+emphasis on readability.
+A Markdown-formatted document should be publishable as-is,
+in plain text, without the formatting distracting the reader.
+.PP
+The biggest source of inspiration for Markdown's
+syntax is the format of plain text email. The markup is comprised entirely
+of punctuation characters, chosen so as to look like what they mean.
+Asterisks around a word look like
+.IR *emphasis* .
+Markdown lists look like lists. Even
+blockquotes look like quoted passages of text, assuming the reader has
+used email.
+.PP
+.SS Block Elements
+.TF W
+.PD
+.TP
+Paragraphs and Line Breaks
+A paragraph is one or more consecutive lines of text, separated
+by one or more blank lines. (A blank line is any line that looks like a
+blank line -- a line containing nothing but spaces or tabs is considered
+blank.) Normal paragraphs should not be indented with spaces or tabs.
+.IP
+Lines may be freely broken for readability; Markdown
+does not translate source line breaks to
+.B <br />
+tags. To request generation of
+.B <br />
+in the output, end a line with two or more spaces, then a newline.
+.TP
+Headings
+Headings can be marked in two ways, called
+.I setext
+and
+.IR atx .
+.IP
+Setext-style headings are
+``underlined'' using equal signs (for first-level
+headings) and dashes (for second-level headings).
+.IP
+Atx-style headings use 1-6 hash characters at the start of the line,
+corresponding to
+.SM HTML
+.BR <h^(1-6)^> .
+Optional closing hashes may follow
+the heading text.
+.TP
+Blockquotes
+Lines beginning with
+.B >
+are output in blockquotes.
+Blockquotes can be nested
+by multiple levels of
+.BR >> .
+Blockquotes can contain other Markdown elements, including
+headings, lists, and code blocks.
+.TP
+Lists
+Markdown supports ordered (numbered) and unordered (bulleted) lists.
+List markers typically start at the left margin, but may be indented by
+up to three spaces.
+List markers must be followed by one or more spaces
+or a tab, then the list item text.
+A newline terminates each list item.
+.IP
+Unordered lists use asterisks, pluses, and hyphens interchangeably as
+list markers.
+.IP
+Ordered lists use integers followed by periods as list markers.
+The order of the integers is not interpreted,
+but the list should begin with
+.BR 1 .
+.IP
+If list items are separated by blank lines, Markdown will wrap each list
+item in
+.B <p>
+tags in the
+.SM HTML
+output.
+.IP
+List items may consist of multiple paragraphs.
+Each subsequent
+paragraph within a list item must be indented by either 4 spaces
+or one tab.
+To put a blockquote within a list item, the blockquote's
+.B >
+marker needs to be indented.
+To put a code block within a list item, the code block needs
+to be indented
+.I twice
+-- 8 spaces or two tabs.
+.TP
+Code Blocks
+To produce a code block, indent every line of the
+block by at least 4 spaces or 1 tab.
+A code block continues until it reaches a line that is not indented.
+.IP
+Rather than forming normal paragraphs, the lines
+of a code block are interpreted literally.
+Regular Markdown syntax is not processed within code blocks.
+Markdown wraps a code block in both
+.B <pre>
+and
+.B <code>
+tags.
+One level of indentation -- 4
+spaces or 1 tab -- is removed from each line of the code block in
+the output.
+.TP
+Horizontal Rules
+Produce a horizontal rule tag
+.RB ( <hr\ /> )
+by placing three or
+more hyphens, asterisks, or underscores on a line by themselves.
+.SS Span Elements
+.TF W
+.PD
+.TP
+Links
+Markdown supports two styles of links:
+.I inline
+and
+.IR reference .
+In both styles, the link text is delimited by square brackets
+.RB ( [] ).
+To create an inline link, use a set of regular parentheses immediately
+after the link text's closing square bracket.
+Inside the parentheses,
+put the link URL, along with an optional
+title for the link surrounded in double quotes.
+For example:
+.IP
+.EX
+ An [example](http://example.com/ "Title") inline link.
+.EE
+.IP
+Reference-style links use a second set of square brackets, inside
+which you place a label of your choosing to identify the link:
+.IP
+.EX
+ An [example][id] reference-style link.
+.EE
+.IP
+The label is then assigned a value on its own line, anywhere in the document:
+.IP
+.EX
+ [id]: http://example.com/ "Optional Title"
+.EE
+.IP
+Link label names may consist of letters, numbers, spaces, and
+punctuation.
+Labels are not case sensitive.
+An empty label bracket
+set after a reference-style link implies the link label is equivalent to
+the link text.
+A URL value can then be assigned to the link by referencing
+the link text as the label name.
+.TP
+Emphasis
+Markdown treats asterisks
+.RB ( * )
+and underscores
+.RB ( _ )
+as indicators of emphasis.
+Text surrounded with single asterisks or underscores
+will be wrapped with an
+.SM HTML
+.B <em>
+tag.
+Double asterisks or underscores generate an
+.SM HTML
+.B <strong>
+tag.
+.TP
+Code
+To indicate a span of code, wrap it with backtick quotes
+.RB ( ` ).
+Unlike a code block, a code span indicates code within a
+normal paragraph.
+To include a literal backtick character within a code span, you can use
+multiple backticks as the opening and closing delimiters:
+.IP
+.EX
+ ``There is a literal backtick (`) here.``
+.EE
+.TP
+Images
+Markdown image syntax is intended to resemble that
+for links, allowing for two styles, once again
+.I inline
+and
+.IR reference .
+The syntax is as for each respective style of link, described above, but
+prefixed with an exclamation mark character
+.RB ( ! ).
+Inline image syntax looks like this:
+.IP
+.EX
+ ![Alt text](/path/to/img.jpg "Optional title")
+.EE
+.IP
+That is:
+An exclamation mark;
+followed by a set of square brackets containing the `alt'
+attribute text for the image;
+followed by a set of parentheses containing the URL or path to
+the image, and an optional `title' attribute enclosed in double
+or single quotes.
+.IP
+Reference-style image syntax looks like this:
+.IP
+.EX
+ ![Alt text][id]
+.EE
+.IP
+Where
+.I id
+is a label used as for reference-style URL links, described above.
+.SS Convenience
+.TF W
+.PD
+.TP
+Automatic Links
+There is a shortcut style for creating ``automatic''
+links for URLs and email addresses.
+Surround the URL
+or address with angle brackets.
+.TP
+Backslash Escapes
+Use backslash escapes to generate literal
+characters which would otherwise have special meaning in Markdown's
+formatting syntax.
+.TP
+Inline HTML
+For markup that is not covered by Markdown's
+syntax, simply use the
+.SM HTML
+directly.
+The only restrictions are that block-level
+.SM HTML
+elements --
+.BR <div> ,
+.BR <table> ,
+.BR <pre> ,
+.BR <p> ,
+etc. -- must be separated from surrounding
+content by blank lines, and the start and end tags of the block should
+not be indented with tabs or spaces. Markdown formatting syntax is
+not processed within block-level
+.SM HTML
+tags.
+.IP
+Span-level
+.SM HTML
+tags -- e.g.
+.BR <span> ,
+.BR <cite> ,
+or
+.B <del>
+-- can be
+used anywhere in a Markdown
+paragraph, list item, or heading.
+It is permitted to use
+.SM HTML
+tags instead of Markdown formatting; e.g.
+.SM HTML
+.B <a>
+or
+.B <img>
+tags instead of Markdown's
+link or image syntax.
+Unlike block-level
+.SM HTML
+tags, Markdown
+syntax
+.I is
+processed within the elements of span-level tags.
+.TP
+Automatic Special Character Escapes
+To be displayed literally in a user agent, the characters
+.B <
+and
+.B &
+must appear as escaped entities in
+.SM HTML
+source, e.g.
+.B &lt;
+and
+.BR &amp; .
+Markdown
+allows natural use of these characters, taking care of
+the necessary escaping.
+The ampersand part of a directly-used
+.SM HTML
+entity remains unchanged; otherwise it will be translated
+into
+.BR &amp; .
+Inside code spans and blocks, angle brackets and
+ampersands are always encoded automatically.
+This makes it easy to use Markdown to write about
+.SM HTML
+code.
+.PP
+.SS Smarty Pants
+The
+.IR markdown (1)
+utility transforms a few plain text symbols into their typographically-fancier
+.SM HTML
+entity equivalents.
+These are extensions to the standard Markdown syntax.
+.TF W
+.PD
+.TP
+Punctuation
+Input single- and double-quotes are transformed
+into ``curly'' quote entities in the output (e.g.,
+.B 'text'
+becomes
+.BR &lsquo;text&rsquo; ).
+Input double-dashes
+.RB ( -- )
+and triple-dashes become en- and em-dashes, respectively,
+while a series of three dots
+.RB ( ... )
+in the input becomes an ellipsis entity
+.RB ( &hellip; )
+in the
+.SM HTML
+output.
+.TP
+Symbols
+Three other transformations replace the common plain-text shorthands
+.BR (c) ,
+.BR (r) ,
+and
+.BR (tm)
+from the input with their respective
+.SM HTML
+entities. (As in
+.B (c)
+becoming
+.BR &copy; ,
+the Copyright symbol entity.)
+.TP
+Fractions
+A small set of plain-text shorthands for fractions is recognized.
+.B 1/4
+becomes
+.BR &frac14; ,
+for example. These fraction notations are replaced with their
+.SM HTML
+entity equivalents:
+.BR 1/4 ,
+.BR 1/2 ,
+.BR 3/4 .
+.B 1/4th
+and
+.B 3/4ths
+are replaced with their entity and the indicated ordinal suffix letters.
+.PP
+Like the basic Markdown syntax, none of the ``Smarty Pants'' extensions are processed
+inside code blocks or spans.
+.PP
+.SS Discount Extensions
+.IR Markdown (1)
+recognizes some extensions to the Markdown format,
+many of them adopted or adapted from other Markdown
+interpreters or document formatting systems.
+.TF W
+.PD
+.TP
+Pandoc Headers
+If
+.I markdown
+was configured with
+.BR --enable-pandoc-header ,
+the markdown source can have a 3-line Pandoc header in the format of
+.IP
+.EX
+% Title
+% Author
+% Date
+.EE
+.IP
+whose data is available to the
+.IR mkd_doc_title ,
+.IR mkd_doc_author ,
+and
+.I mkd_doc_date
+(in
+.IR markdown (2))
+functions.
+.TP
+Embedded Stylesheets
+Stylesheets may be defined and modified in a
+.B <style>
+block. A style block is parsed like any other block-level
+.SM HTML;
+.B <style>
+starting on column 1, raw
+.SM HTML
+(or, in this case,
+.SM CSS \)
+following it, and either ending with a
+.B </style>
+at the end of the line or at the beginning of a subsequent line.
+.IP
+Style blocks apply to the entire document regardless of where they are defined.
+.TP
+Image Dimensions
+Image specification has been extended with an argument describing image dimensions:
+.BI = height x width.
+For an image 400 pixels high and 300 wide, the new syntax is:
+.IP
+.EX
+ ![Alt text](/path/to/image.jpg =400x300 "Title")
+.EE
+.TP
+Pseudo-Protocols
+Pseudo-protocols that may replace the common
+.B http:
+or
+.B mailto:
+have been added to the link syntax described above.
+.IP
+.BR abbr :
+Text following is used as the
+.B title
+attribute of an
+.B abbr
+tag wrapping the link text. So
+.B [LT](abbr:Link Text)
+gives
+.B <abbr title="Link Text">LT</abbr>.
+.IP
+.BR id :
+The link text is marked up and written to the output, wrapped with
+.B <a id=text following>
+and
+.BR </a> .
+.IP
+.BR class :
+ The link text is marked up and written to the output, wrapped with
+.B <span class=text following>
+and
+.BR </span> .
+.IP
+.BR raw :
+Text following is written to the output with no further processing.
+The link text is discarded.
+.TP
+Alphabetic Lists
+If
+.I markdown
+was configured with
+.BR --enable-alpha-list ,
+.IP
+.EX
+a. this
+b. is
+c. an alphabetic
+d. list
+.EE
+.IP
+yields an
+.SM HTML
+.B ol
+ordered list.
+.TP
+Definition Lists
+If configured with
+.BR --enable-dl-tag ,
+markup for definition lists is enabled. A definition list item is defined as
+.IP
+.EX
+=term=
+ definition
+.EE
+.TP
+Tables
+Tables are specified with a pipe
+.RB ( | )
+and dash
+.RB ( - )
+marking. The markdown text
+.IP
+.EX
+header0|header1
+-------|-------
+ textA|textB
+ textC|textD
+.EE
+.IP
+will produce an
+.SM HTML
+.B table
+of two columns and three rows.
+A header row is designated by ``underlining'' with dashes.
+Declare a column's alignment by affixing a colon
+.RB ( : )
+to the left or right end of the dashes underlining its header.
+In the output, this
+yields the corresponding value for the
+.B align
+attribute on each
+.B td
+cell in the column.
+A colon at both ends of a column's header dashes indicates center alignment.
+.TP
+Relaxed Emphasis
+If configured with
+.BR --relaxed-emphasis ,
+the rules for emphasis are changed so that a single
+.B _
+will not count as an emphasis character in the middle of a word.
+This is useful for documenting some code where
+.B _
+appears frequently, and would normally require a backslash escape.
+.PD
+.SH SEE ALSO
+.IR markdown (1),
+.IR markdown (2)
+.PP
+http://daringfireball.net/projects/markdown/syntax/,
+``Markdown: Syntax''.
+.PP
+http://daringfireball.net/projects/smartypants/,
+``Smarty Pants''.
+.PP
+http://michelf.com/projects/php-markdown/extra/#table,
+``PHP Markdown Extra: Tables''.
View
37 Discount/discount/Plan9/mkfile
@@ -0,0 +1,37 @@
+BIN=/$objtype/bin
+CC='cc -D_BSD_EXTENSION -D_C99_SNPRINTF_EXTENSION'
+
+markdown:
+ ape/psh -c 'cd .. && make'
+
+none:V: markdown
+
+test: markdown
+ ape/psh -c 'cd ..&& make test'
+
+install: markdown
+ cp ../markdown $BIN/markdown
+
+install.progs: install
+ cp ../makepage $BIN/makepage
+ cp ../mkd2html $BIN/mkd2html
+
+install.libs: install
+ cp ../mkdio.h /sys/include/ape/mkdio.h
+ cp ../libmarkdown.a /$objtype/lib/ape/libmarkdown.a
+
+install.man: install
+ cp markdown.1 /sys/man/1/markdown
+ cp markdown.2 /sys/man/2/markdown
+ cp markdown.6 /sys/man/6/markdown
+
+installall:V: install.libs install.man install.progs
+
+config:
+ ape/psh -c 'cd .. && ./configure.sh $CONFIG'
+
+clean:
+ ape/psh -c 'cd .. && make clean'
+
+nuke:
+ ape/psh -c 'cd .. && make distclean'
View
16 Discount/discount/README
@@ -0,0 +1,16 @@
+DISCOUNT is a implementation of John Gruber's Markdown markup
+language. It implements, as far as I can tell, all of the
+language as described in
+<http://daringfireball.net/projects/markdown/syntax>
+and passes the Markdown test suite at
+<http://daringfireball.net/projects/downloads/MarkdownTest_1.0.zip>
+
+DISCOUNT is free software written by David Parsons <orc@pell.chi.il.us>;
+it is released under a BSD-style license that allows you to do
+as you wish with it as long as you don't attempt to claim it as
+your own work.
+
+Most of the programs included in the DISCOUNT distribution have
+manual pages describing how they work.
+
+The file INSTALL describes how to build and install discount
View
1 Discount/discount/VERSION
@@ -0,0 +1 @@
+2.1.0
View
111 Discount/discount/amalloc.c
@@ -0,0 +1,111 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAGIC 0x1f2e3d4c
+
+struct alist { int magic, size; struct alist *next, *last; };
+
+static struct alist list = { 0, 0, 0, 0 };
+
+static int mallocs=0;
+static int reallocs=0;
+static int frees=0;
+
+void *
+acalloc(int size, int count)
+{
+ struct alist *ret = calloc(size + sizeof(struct alist), count);
+
+ if ( ret ) {
+ ret->magic = MAGIC;
+ ret->size = size * count;
+ if ( list.next ) {
+ ret->next = list.next;
+ ret->last = &list;
+ ret->next->last = ret;
+ list.next = ret;
+ }
+ else {
+ ret->last = ret->next = &list;
+ list.next = list.last = ret;
+ }
+ ++mallocs;
+ return ret+1;
+ }
+ return 0;
+}
+
+
+void*
+amalloc(int size)
+{
+ return acalloc(size,1);
+}
+
+
+void
+afree(void *ptr)
+{
+ struct alist *p2 = ((struct alist*)ptr)-1;
+
+ if ( p2->magic == MAGIC ) {
+ p2->last->next = p2->next;
+ p2->next->last = p2->last;
+ ++frees;
+ free(p2);
+ }
+ else
+ free(ptr);
+}
+
+
+void *
+arealloc(void *ptr, int size)
+{
+ struct alist *p2 = ((struct alist*)ptr)-1;
+ struct alist save;
+
+ if ( p2->magic == MAGIC ) {
+ save.next = p2->next;
+ save.last = p2->last;
+ p2 = realloc(p2, sizeof(*p2) + size);
+
+ if ( p2 ) {
+ p2->size = size;
+ p2->next->last = p2;
+ p2->last->next = p2;
+ ++reallocs;
+ return p2+1;
+ }
+ else {
+ save.next->last = save.last;
+ save.last->next = save.next;
+ return 0;
+ }
+ }
+ return realloc(ptr, size);
+}
+
+
+void
+adump()
+{
+ struct alist *p;
+
+
+ for ( p = list.next; p && (p != &list); p = p->next ) {
+ fprintf(stderr, "allocated: %d byte%s\n", p->size, (p->size==1) ? "" : "s");
+ fprintf(stderr, " [%.*s]\n", p->size, (char*)(p+1));
+ }
+
+ if ( getenv("AMALLOC_STATISTICS") ) {
+ fprintf(stderr, "%d malloc%s\n", mallocs, (mallocs==1)?"":"s");
+ fprintf(stderr, "%d realloc%s\n", reallocs, (reallocs==1)?"":"s");
+ fprintf(stderr, "%d free%s\n", frees, (frees==1)?"":"s");
+ }
+}
View
29 Discount/discount/amalloc.h
@@ -0,0 +1,29 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+#ifndef AMALLOC_D
+#define AMALLOC_D
+
+#include "config.h"
+
+#ifdef USE_AMALLOC
+
+extern void *amalloc(int);
+extern void *acalloc(int,int);
+extern void *arealloc(void*,int);
+extern void afree(void*);
+extern void adump();
+
+#define malloc amalloc
+#define calloc acalloc
+#define realloc arealloc
+#define free afree
+
+#else
+
+#define adump() (void)1
+
+#endif
+
+#endif/*AMALLOC_D*/
View
43 Discount/discount/basename.c
@@ -0,0 +1,43 @@
+/*
+ * mkdio -- markdown front end input functions
+ *
+ * Copyright (C) 2007 David L Parsons.
+ * The redistribution terms are provided in the COPYRIGHT file that must
+ * be distributed with this source code.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "mkdio.h"
+#include "cstring.h"
+#include "amalloc.h"
+
+static char *
+e_basename(const char *string, const int size, void *context)
+{
+ char *ret;
+ char *base = (char*)context;
+
+ if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
+ strcpy(ret, base);
+ strncat(ret, string, size);
+ return ret;
+ }
+ return 0;
+}
+
+static void
+e_free(char *string, void *context)
+{
+ if ( string ) free(string);
+}
+
+void
+mkd_basename(MMIOT *document, char *base)
+{
+ mkd_e_url(document, e_basename);
+ mkd_e_data(document, base);
+ mkd_e_free(document, e_free);
+}
View
1,678 Discount/discount/configure.inc
@@ -0,0 +1,1678 @@
+# @(#) configure.inc 1.42@(#)
+# Copyright (c) 1999-2007 David Parsons. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. My name may not be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
+# PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+#
+# this preamble code is executed when this file is sourced and it picks
+# interesting things off the command line.
+#
+ac_default_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
+
+ac_standard="--src=DIR where the source lives (.)
+--prefix=DIR where to install the final product (/usr/local)
+--execdir=DIR where to put executables (prefix/bin)
+--sbindir=DIR where to put static executables (prefix/sbin)
+--confdir=DIR where to put configuration information (/etc)
+--libdir=DIR where to put libraries (prefix/lib)
+--libexecdir=DIR where to put private executables
+--mandir=DIR where to put manpages"
+
+__fail=exit
+
+if dirname B/A 2>/dev/null >/dev/null; then
+__ac_dirname() {
+ dirname "$1"
+}
+else
+__ac_dirname() {
+ echo "$1" | sed -e 's:/[^/]*$::'
+}
+fi
+
+__remove() {
+ if [ \( -x "$1" \) -a "$__MACOS_DSYM" ]; then
+ rm -rf "$1".dSYM
+ fi
+ rm -f "$@"
+}
+
+ac_progname=$0
+ac_configure_command=
+Q=\'
+for x in "$@"; do
+ ac_configure_command="$ac_configure_command $Q$x$Q"
+done
+# ac_configure_command="$*"
+
+__d=`__ac_dirname "$ac_progname"`
+if [ "$__d" = "$ac_progname" ]; then
+ AC_SRCDIR=`pwd`
+else
+ AC_SRCDIR=`cd $__d;pwd`
+fi
+
+__ac_dir() {
+ if test -d "$1"; then
+ (cd "$1";pwd)
+ else
+ echo "$1";
+ fi
+}
+
+#
+# echo w/o newline
+#
+echononl()
+{
+ ${ac_echo:-echo} "${@}$ac_echo_nonl"
+}
+
+#
+# log something to the terminal and to a logfile.
+#
+LOG () {
+ echo "$@"
+ echo "$@" 1>&5
+}
+
+#
+# log something to the terminal without a newline, and to a logfile with
+# a newline
+#
+LOGN () {
+ echononl "$@" 1>&5
+ echo "$@"
+}
+
+#
+# log something to the terminal
+#
+TLOG () {
+ echo "$@" 1>&5
+}
+
+#
+# log something to the terminal, no newline
+#
+TLOGN () {
+ echononl "$@" 1>&5
+}
+
+
+#
+# AC_CONTINUE tells configure not to bomb if something fails, but to
+# continue blithely along
+#
+AC_CONTINUE () {
+ __fail="return"
+}
+
+
+#
+# generate a .o file from sources
+#
+__MAKEDOTO() {
+ AC_PROG_CC
+
+ if $AC_CC -c -o ngc$$.o "$@" $AC_LIBS 2>ngc$$.err; then
+ __remove ngc$$.o ngc$$.err
+ TLOG " (found)"
+ return 0
+ fi
+ __remove ngc$$.o
+ TLOG " (not found)"
+ echo "test failed: command was $AC_CC -c -o ngc$$.o" "$@" $AC_LIBS
+ echo "output:"
+ cat ngc$$.err
+ __remove ngc$$.err
+ echo "offending sources:"
+ for x in "$@"; do
+ echo "$x:"
+ cat $x
+ done
+ return 1
+}
+
+
+#
+# Emulate gnu autoconf's AC_CHECK_HEADERS() function
+#
+AC_CHECK_HEADERS () {
+
+ echo "/* AC_CHECK_HEADERS */" > ngc$$.c
+ for hdr in $*; do
+ echo "#include <$hdr>" >> ngc$$.c
+ done
+ echo "main() { }" >> ngc$$.c
+
+ LOGN "looking for header $hdr"
+
+ if __MAKEDOTO ngc$$.c; then
+ AC_DEFINE 'HAVE_'`echo $hdr | $AC_UPPERCASE | tr './' '_'` 1
+ rc=0
+ else
+ rc=1
+ fi
+ __remove ngc$$.c
+ return $rc
+}
+
+
+#
+# emulate GNU autoconf's AC_CHECK_FUNCS function
+#
+AC_CHECK_FUNCS () {
+ AC_PROG_CC
+
+ B=`echo "$1" | sed -e 's/(.*)//'`
+
+ case "$B" in
+ "$1") F="$1()" ;;
+ *) F="$1" ;;
+ esac
+
+ shift
+ __remove ngc$$.c
+
+ while [ "$1" ]; do
+ echo "#include <$1>" >> ngc$$.c
+ shift
+ done
+
+ cat >> ngc$$.c << EOF
+main()
+{
+
+ $F;
+}
+EOF
+
+ LOGN "looking for the $B function"
+
+ if $AC_CC -o ngc$$ ngc$$.c $LIBS; then
+ AC_DEFINE `echo ${2:-HAVE_$B} | $AC_UPPERCASE` 1
+ TLOG " (found)"
+ rc=0
+ else
+ echo "offending command was:"
+ cat ngc$$.c
+ echo "$AC_CC -o ngc$$ ngc$$.c $LIBS"
+ TLOG " (not found)"
+ rc=1
+ fi
+ __remove ngc$$ ngc$$.c
+ return $rc
+}
+
+
+#
+# check to see if some structure exists
+#
+# usage: AC_CHECK_STRUCT structure {include ...}
+#
+AC_CHECK_STRUCT () {
+ struct=$1
+ shift
+
+ __remove ngc$$.c
+
+ for include in $*; do
+ echo "#include <$include>" >> ngc$$.c
+ done
+
+ cat >> ngc$$.c << EOF
+main()
+{
+ struct $struct foo;
+}
+EOF
+
+ LOGN "looking for struct $struct"
+
+ if __MAKEDOTO ngc$$.c; then
+ AC_DEFINE HAVE_STRUCT_`echo ${struct} | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ __remove ngc$$.c
+ return $rc
+}
+
+
+#
+# check to see if some type exists
+#
+# usage: AC_CHECK_TYPE type {include ...}
+#
+AC_CHECK_TYPE () {
+ type=$1
+ shift
+
+ __remove ngc$$.c
+
+ for include in $*; do
+ echo "#include <$include>" >> ngc$$.c
+ done
+
+ cat >> ngc$$.c << EOF
+main()
+{
+ $type foo;
+}
+EOF
+
+ LOGN "looking for $type type"
+
+ if __MAKEDOTO ngc$$.c; then
+ AC_DEFINE HAVE_TYPE_`echo ${type} | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ __remove ngc$$.c
+ return $rc
+}
+
+
+#
+# check to see if some structure contains a field
+#
+# usage: AC_CHECK_FIELD structure field {include ...}
+#
+AC_CHECK_FIELD () {
+
+ struct=$1
+ field=$2
+ shift 2
+
+ __remove ngc$$.c
+
+ for include in $*;do
+ echo "#include <$include>" >> ngc$$.c
+ done
+
+ cat >> ngc$$.c << EOF
+main()
+{
+ struct $struct foo;
+
+ foo.$field;
+}
+EOF
+
+ LOGN "checking that struct $struct has a $field field"
+
+ if __MAKEDOTO ngc$$.c; then
+ AC_DEFINE HAVE_`echo ${struct}_$field | $AC_UPPERCASE`
+ rc=0
+ else
+ rc=1
+ fi
+ __remove ngc$$.c
+ return $rc
+}
+
+
+#
+# check that the C compiler works
+#
+AC_PROG_CC () {
+ test "$AC_CC" && return 0
+
+ cat > ngc$$.c << \EOF
+#include <stdio.h>
+main()
+{
+ puts("hello, sailor");
+}
+EOF
+
+ TLOGN "checking the C compiler"
+
+ unset AC_CFLAGS AC_LDFLAGS
+
+ if [ "$CC" ] ; then
+ AC_CC="$CC"
+ elif [ "$WITH_PATH" ]; then
+ AC_CC=`acLookFor cc`
+ elif [ "`acLookFor cc`" ]; then
+ # don't specify the full path if the user is looking in their $PATH
+ # for a C compiler.
+ AC_CC=cc
+ fi
+
+ # finally check for POSIX c89
+ test "$AC_CC" || AC_CC=`acLookFor c89`
+
+ if [ ! "$AC_CC" ]; then
+ TLOG " (no C compiler found)"
+ $__fail 1
+ fi
+ echo "checking out the C compiler"
+
+ unset __MACOS_DSYM
+ $AC_CC -o ngc$$ ngc$$.c
+ status=$?
+ test -d ngc$$.dSYM && __MACOS_DSYM=1
+
+ TLOGN " ($AC_CC)"
+
+ if [ $status -eq 0 ]; then
+ if $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then
+ TLOG " oh ick, it looks like gcc"
+ IS_BROKEN_CC=T
+ else
+ TLOG " ok"
+ fi
+
+ # check that the CFLAGS and LDFLAGS aren't bogus
+
+ unset AC_CFLAGS AC_LDFLAGS
+
+ if [ "$CFLAGS" ]; then
+ test "$CFLAGS" && echo "validating CFLAGS=${CFLAGS}"
+ if $AC_CC $CFLAGS -o ngc$$.o ngc$$.c ; then
+ AC_CFLAGS=${CFLAGS:-"-g"}
+ test "$CFLAGS" && echo "CFLAGS=\"${CFLAGS}\" are okay"
+ elif [ "$CFLAGS" ]; then
+ echo "ignoring bogus CFLAGS=\"${CFLAGS}\""
+ fi
+ else
+ AC_CFLAGS=-g
+ fi
+ if [ "$LDFLAGS" ]; then
+ test "$LDFLAGS" && echo "validating LDFLAGS=${LDFLAGS}"
+ if $AC_CC $LDFLAGS -o ngc$$ ngc$$.o; then
+ AC_LDFLAGS=${LDFLAGS:-"-g"}
+ test "$LDFLAGS" && TLOG "LDFLAGS=\"${LDFLAGS}\" are okay"
+ elif [ "$LDFLAGS" ]; then
+ TLOG "ignoring bogus LDFLAGS=\"${LDFLAGS}\""
+ fi
+ else
+ AC_LDFLAGS=${CFLAGS:-"-g"}
+ fi
+ else
+ AC_FAIL " does not compile code properly"
+ fi
+
+ AC_SUB 'CC' "$AC_CC"
+
+ __remove ngc$$ ngc$$.c ngc$$.o
+
+ return $status
+}
+
+
+#
+# acLookFor actually looks for a program, without setting anything.
+#
+acLookFor () {
+ path=${AC_PATH:-$ac_default_path}
+ case "X$1" in
+ X-[rx]) __mode=$1
+ shift
+ ;;
+ *) __mode=-x
+ ;;
+ esac
+ oldifs="$IFS"
+ for program in $*; do
+ IFS=":"
+ for x in $path; do
+ if [ $__mode $x/$program -a -f $x/$program ]; then
+ echo $x/$program
+ break 2
+ fi
+ done
+ done
+ IFS="$oldifs"
+ unset __mode
+}
+
+
+#
+# check that a program exists and set its path
+#
+MF_PATH_INCLUDE () {
+ SYM=$1; shift
+
+ case X$1 in
+ X-[rx]) __mode=$1
+ shift
+ ;;
+ *) unset __mode
+ ;;
+ esac
+
+ TLOGN "looking for $1"
+
+ DEST=`acLookFor $__mode $*`
+
+ __sym=`echo "$SYM" | $AC_UPPERCASE`
+ if [ "$DEST" ]; then