From 597346e99e29502e4a83330bc5f1559116f69c3d Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Sat, 21 Jan 2012 10:43:10 +0000 Subject: [PATCH 01/22] Modernised project to XCode 4.2 --- MarkdownLive.xcodeproj/project.pbxproj | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 186147d..ecbfb92 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -343,8 +343,12 @@ /* Begin PBXProject section */ 2A37F4A9FDCFA73011CA2CEA /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "MarkdownLive" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, @@ -476,7 +480,6 @@ DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = NO; @@ -489,7 +492,6 @@ "-framework", AppKit, ); - PREBINDING = NO; PRODUCT_NAME = ORCDiscount; RUN_CLANG_STATIC_ANALYZER = YES; }; @@ -504,7 +506,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_PREFIX_HEADER = ""; @@ -516,7 +517,6 @@ "-framework", AppKit, ); - PREBINDING = NO; PRODUCT_NAME = ORCDiscount; RUN_CLANG_STATIC_ANALYZER = YES; ZERO_LINK = NO; @@ -530,7 +530,6 @@ COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)\"/**"; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -577,8 +576,7 @@ GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/discount-1.5.4\""; }; name = Debug; @@ -604,8 +602,7 @@ GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; SEPARATE_STRIP = YES; STRIP_INSTALLED_PRODUCT = YES; USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/discount-1.5.4\""; From 2e4f117b3a29956a29fbfb9c0e21791378084e00 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Sat, 21 Jan 2012 10:44:28 +0000 Subject: [PATCH 02/22] Added parenthesis to silence compiler warning --- MyDocument.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MyDocument.m b/MyDocument.m index 0333243..5f5c83c 100644 --- a/MyDocument.m +++ b/MyDocument.m @@ -211,7 +211,7 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary NSURL *stdUrl = [url URLByStandardizingPath]; NSURL *docUrl = [[self fileURL] URLByStandardizingPath]; if ([[url scheme] isEqualToString:@"applewebdata"] || - [stdUrl isFileURL] && [stdUrl isEqualTo:docUrl]) { + ([stdUrl isFileURL] && [stdUrl isEqualTo:docUrl])) { [listener use]; } else { [[NSWorkspace sharedWorkspace] openURL:url]; From 1624d37b5f2008b994e23bca727e9c72f1073257 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Mon, 23 Jan 2012 21:57:59 +0000 Subject: [PATCH 03/22] Updated discount to 2.1.3 --- discount/CREDITS | 2 + discount/Csio.c | 2 +- discount/Makefile.in | 65 +++--- discount/VERSION | 2 +- discount/configure.inc | 29 ++- discount/configure.sh | 3 + discount/emmatch.c | 2 +- discount/flags.c | 2 +- discount/generate.c | 131 ++++++++---- discount/html5.c | 2 - discount/main.c | 6 +- discount/makepage.c | 2 +- discount/markdown.c | 357 +++++++++++++++++++-------------- discount/markdown.h | 15 +- discount/mkd2html.c | 3 +- discount/mkdio.c | 4 +- discount/mkdio.h.in | 1 + discount/mktags.c | 89 ++++++++ discount/pgm_options.c | 137 +++++++++++++ discount/pgm_options.h | 9 + discount/setup.c | 10 +- discount/tags.c | 100 ++++----- discount/tests/code.t | 56 ++++++ discount/tests/defects.t | 17 ++ discount/tests/dl.t | 13 +- discount/tests/functions.sh | 9 +- discount/tests/html.t | 9 - discount/tests/para.t | 6 +- discount/tests/peculiarities.t | 2 +- discount/tests/reddit.t | 2 +- discount/tests/smarty.t | 5 +- discount/tests/strikethrough.t | 1 + discount/tests/tables.t | 87 +++++++- discount/tests/toc.t | 12 +- discount/theme.1 | 18 +- discount/theme.c | 11 +- discount/toc.c | 31 ++- discount/tools/cols.c | 3 +- discount/tools/echo.c | 2 +- discount/version.c.in | 3 + discount/xml.c | 4 +- discount/xmlpage.c | 2 +- 42 files changed, 889 insertions(+), 377 deletions(-) create mode 100644 discount/mktags.c create mode 100644 discount/pgm_options.c create mode 100644 discount/pgm_options.h create mode 100644 discount/tests/defects.t diff --git a/discount/CREDITS b/discount/CREDITS index 3ec9d8c..2014bc5 100644 --- a/discount/CREDITS +++ b/discount/CREDITS @@ -29,5 +29,7 @@ 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. +John J. Foerch -- bug reports about incorrect `–` and `—` + translations. diff --git a/discount/Csio.c b/discount/Csio.c index 4358b33..5706657 100644 --- a/discount/Csio.c +++ b/discount/Csio.c @@ -54,7 +54,7 @@ Csreparse(Cstring *iot, char *buf, int size, int flags) { MMIOT f; ___mkd_initmmiot(&f, 0); - ___mkd_reparse(buf, size, 0, &f); + ___mkd_reparse(buf, size, 0, &f, 0); ___mkd_emblock(&f); SUFFIX(*iot, T(f.out), S(f.out)); ___mkd_freemmiot(&f, 0); diff --git a/discount/Makefile.in b/discount/Makefile.in index 53ec5e2..78d2079 100644 --- a/discount/Makefile.in +++ b/discount/Makefile.in @@ -1,4 +1,5 @@ -CC=@CC@ -I. -L. +CC=@CC@ -Wall -I. +LFLAGS=-L. CFLAGS=@CFLAGS@ AR=@AR@ RANLIB=@RANLIB@ @@ -22,62 +23,70 @@ 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: $(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.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 + @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;\ + ( 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;\ + ( 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; \ + ( 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_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)$(BINDIR): + @INSTALL_DIR@ $(DESTDIR)$(BINDIR) -$(DESTDIR)/$(INCDIR): - @INSTALL_DIR@ $(DESTDIR)/$(INCDIR) +$(DESTDIR)$(INCDIR): + @INSTALL_DIR@ $(DESTDIR)$(INCDIR) -$(DESTDIR)/$(LIBDIR): - @INSTALL_DIR@ $(DESTDIR)/$(LIBDIR) +$(DESTDIR)$(LIBDIR): + @INSTALL_DIR@ $(DESTDIR)$(LIBDIR) version.o: version.c VERSION $(CC) -DVERSION=\"`cat VERSION`\" -c version.c +VERSION: + @true + +tags.o: tags.c blocktags + +blocktags: mktags + ./mktags > blocktags + # example programs @THEME@theme: theme.o $(MKDLIB) mkdio.h -@THEME@ $(CC) -o theme theme.o -lmarkdown @LIBS@ +@THEME@ $(CC) $(LFLAGS) -o theme theme.o -lmarkdown @LIBS@ mkd2html: mkd2html.o $(MKDLIB) mkdio.h - $(CC) -o mkd2html mkd2html.o -lmarkdown @LIBS@ + $(CC) $(LFLAGS) -o mkd2html mkd2html.o -lmarkdown @LIBS@ markdown: main.o pgm_options.o $(MKDLIB) - $(CC) $(CFLAGS) -o markdown main.o pgm_options.o -lmarkdown @LIBS@ + $(CC) $(LFLAGS) -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@ + $(CC) $(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 diff --git a/discount/VERSION b/discount/VERSION index 7ec1d6d..ac2cdeb 100644 --- a/discount/VERSION +++ b/discount/VERSION @@ -1 +1 @@ -2.1.0 +2.1.3 diff --git a/discount/configure.inc b/discount/configure.inc index 5115c86..458dd1e 100755 --- a/discount/configure.inc +++ b/discount/configure.inc @@ -385,7 +385,10 @@ EOF TLOGN " ($AC_CC)" if [ $status -eq 0 ]; then - if $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then + if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then + TLOG " yuck, you're using clang" + IS_BROKEN_CC=T + elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then TLOG " oh ick, it looks like gcc" IS_BROKEN_CC=T else @@ -826,9 +829,7 @@ EOF # AC_C_VOLATILE checks to see if the compiler supports the volatile keyword # AC_C_VOLATILE () { - cat > ngc$$.c << EOF -f() { volatile char me=1; } -EOF + echo 'f() { volatile char me=1; }' > ngc$$.c LOGN "checking for \"volatile\" keyword" if __MAKEDOTO ngc$$.c; then @@ -842,6 +843,23 @@ EOF } +# +# AC_C_INLINE checks to see if compiler supports the inline keyword +# +AC_C_INLINE() { + echo 'inline int foo() { return 1; }' > ngc$$.c + LOGN 'Checking for "inline" keyword' + if __MAKEDOTO ngc$$.c; then + rc=0 + else + AC_DEFINE inline '/**/' + rc=1 + fi + __remove ngc$$.c + return $rc +} + + # # AC_SCALAR_TYPES checks to see if the compiler can generate 2 and 4 byte ints. # @@ -859,7 +877,6 @@ say(char *w, char *v) : "s:@%s@:%s:g\n", w, v); } -void main(argc, argv) char **argv; { @@ -1162,7 +1179,7 @@ main() EOF if $AC_CC -o ngc$$ ngc$$.c $LIBS; then - if ngc$$; then + if ./ngc$$; then TLOG "(found)" AC_DEFINE 'HAVE_BASENAME' 1 AC_CHECK_HEADERS libgen.h diff --git a/discount/configure.sh b/discount/configure.sh index b067865..43ef971 100755 --- a/discount/configure.sh +++ b/discount/configure.sh @@ -12,6 +12,7 @@ ac_help='--enable-amalloc Enable memory allocation debugging --with-dl=X Use Discount, Extra, or Both types of definition list --with-id-anchor Use id= anchors for table-of-contents links --with-github-tags Allow `_` and `-` in <> tags +--with-fenced-code Allow fenced code blocks --enable-all-features Turn on all stable optional features --shared Build shared libraries (default is static)' @@ -53,6 +54,7 @@ BOTH) AC_DEFINE 'USE_EXTRA_DL' 1 *) AC_FAIL "Unknown value <$WITH_DL> for --with-dl (want 'discount', 'extra', or 'both')" ;; esac +test "$WITH_FENCED_CODE" && AC_DEFINE "WITH_FENCED_CODE" 1 test "$WITH_ID_ANCHOR" && AC_DEFINE 'WITH_ID_ANCHOR' 1 test "$WITH_GITHUB_TAGS" && AC_DEFINE 'WITH_GITHUB_TAGS' 1 @@ -70,6 +72,7 @@ AC_PROG ranlib AC_C_VOLATILE AC_C_CONST +AC_C_INLINE AC_SCALAR_TYPES sub hdr AC_CHECK_BASENAME diff --git a/discount/emmatch.c b/discount/emmatch.c index 8d362c5..9fb1ad9 100644 --- a/discount/emmatch.c +++ b/discount/emmatch.c @@ -110,7 +110,7 @@ emmatch(MMIOT *f, int first, int last) int e, e2, match; switch (start->b_count) { - case 2: if ( e = empair(f,first,last,match=2) ) + case 2: if ( (e = empair(f,first,last,match=2)) ) break; case 1: e = empair(f,first,last,match=1); break; diff --git a/discount/flags.c b/discount/flags.c index 5bf206c..5a2934b 100644 --- a/discount/flags.c +++ b/discount/flags.c @@ -45,7 +45,7 @@ mkd_flags_are(FILE *f, DWORD flags, int htmlplease) for (i=0; i < NR(flagnames); i++) { set = flags & flagnames[i].flag; name = flagnames[i].name; - if ( not = (*name == '!') ) { + if ( (not = (*name == '!')) ) { ++name; set = !set; } diff --git a/discount/generate.c b/discount/generate.c index 7f0f764..743b4d4 100644 --- a/discount/generate.c +++ b/discount/generate.c @@ -40,7 +40,7 @@ push(char *bfr, int size, MMIOT *f) /* look characters ahead of the cursor. */ -static int +static inline int peek(MMIOT *f, int i) { @@ -52,7 +52,7 @@ peek(MMIOT *f, int i) /* pull a byte from the input buffer */ -static int +static inline int pull(MMIOT *f) { return ( f->isp < S(f->in) ) ? T(f->in)[f->isp++] : EOF; @@ -61,14 +61,14 @@ pull(MMIOT *f) /* return a pointer to the current position in the input buffer. */ -static char* +static inline char* cursor(MMIOT *f) { return T(f->in) + f->isp; } -static int +static inline int isthisspace(MMIOT *f, int i) { int c = peek(f, i); @@ -77,7 +77,7 @@ isthisspace(MMIOT *f, int i) } -static int +static inline int isthisalnum(MMIOT *f, int i) { int c = peek(f, i); @@ -86,7 +86,7 @@ isthisalnum(MMIOT *f, int i) } -static int +static inline int isthisnonword(MMIOT *f, int i) { return isthisspace(f, i) || ispunct(peek(f,i)); @@ -183,9 +183,10 @@ Qem(MMIOT *f, char c, int count) /* generate html from a markup fragment */ void -___mkd_reparse(char *bfr, int size, int flags, MMIOT *f) +___mkd_reparse(char *bfr, int size, int flags, MMIOT *f, char *esc) { MMIOT sub; + struct escaped e; ___mkd_initmmiot(&sub, f->footnotes); @@ -193,6 +194,14 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f) sub.cb = f->cb; sub.ref_prefix = f->ref_prefix; + if ( esc ) { + sub.esc = &e; + e.up = f->esc; + e.text = esc; + } + else + sub.esc = f->esc; + push(bfr, size, &sub); EXPAND(sub.in) = 0; S(sub.in)--; @@ -206,6 +215,23 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f) } +/* + * check the escape list for special cases + */ +static int +escaped(MMIOT *f, char c) +{ + struct escaped *thing = f->esc; + + while ( thing ) { + if ( strchr(thing->text, c) ) + return 1; + thing = thing->up; + } + return 0; +} + + /* * write out a url, escaping problematic characters */ @@ -553,7 +579,7 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size) puturl(link + tag->szpat, size - tag->szpat, f, 0); } else - ___mkd_reparse(link + tag->szpat, size - tag->szpat, MKD_TAGTEXT, f); + ___mkd_reparse(link + tag->szpat, size - tag->szpat, MKD_TAGTEXT, f, 0); Qstring(tag->link_sfx, f); @@ -585,7 +611,7 @@ extra_linky(MMIOT *f, Cstring text, Footnote *ref) return 0; if ( f->flags & IS_LABEL ) - ___mkd_reparse(T(text), S(text), linkt.flags, f); + ___mkd_reparse(T(text), S(text), linkt.flags, f, 0); else { ref->flags |= REFERENCED; ref->refnumber = ++ f->reference; @@ -606,7 +632,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref) if ( image || (ref == 0) ) tag = &imaget; - else if ( tag = pseudo(ref->link) ) { + else if ( (tag = pseudo(ref->link)) ) { if ( f->flags & (MKD_NO_EXT|MKD_SAFELINK) ) return 0; } @@ -624,7 +650,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref) return 0; if ( f->flags & IS_LABEL ) - ___mkd_reparse(T(text), S(text), tag->flags, f); + ___mkd_reparse(T(text), S(text), tag->flags, f, 0); else if ( tag->link_pfx ) { printlinkyref(f, tag, T(ref->link), S(ref->link)); @@ -635,12 +661,12 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref) if ( S(ref->title) ) { Qstring(" title=\"", f); - ___mkd_reparse(T(ref->title), S(ref->title), MKD_TAGTEXT, f); + ___mkd_reparse(T(ref->title), S(ref->title), MKD_TAGTEXT, f, 0); Qchar('"', f); } Qstring(tag->text_pfx, f); - ___mkd_reparse(T(text), S(text), tag->flags, f); + ___mkd_reparse(T(text), S(text), tag->flags, f, 0); Qstring(tag->text_sfx, f); } else @@ -700,8 +726,8 @@ linkylinky(int image, MMIOT *f) S(key.tag) = S(name); } - if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes), - sizeof key, (stfu)__mkd_footsort) ) { + if ( (ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes), + sizeof key, (stfu)__mkd_footsort)) ) { if ( extra_footnote ) status = extra_linky(f,name,ref); else @@ -810,6 +836,8 @@ code(MMIOT *f, char *s, int length) for ( i=0; i < length; i++ ) if ( (c = s[i]) == 003) /* ^C: expand back to 2 spaces */ Qstring(" ", f); + else if ( c == '\\' && (i < length-1) && escaped(f, s[i+1]) ) + cputc(s[++i], f); else cputc(c, f); } /* code */ @@ -821,7 +849,7 @@ static void delspan(MMIOT *f, int size) { Qstring("", f); - ___mkd_reparse(cursor(f)-1, size, 0, f); + ___mkd_reparse(cursor(f)-1, size, 0, f, 0); Qstring("", f); } @@ -1093,8 +1121,8 @@ static struct smarties { { '\'', "'ve>", "rsquo", 0 }, { '\'', "'m>", "rsquo", 0 }, { '\'', "'d>", "rsquo", 0 }, - { '-', "--", "mdash", 1 }, - { '-', "<->", "ndash", 0 }, + { '-', "---", "mdash", 2 }, + { '-', "--", "ndash", 1 }, { '.', "...", "hellip", 2 }, { '.', ". . .", "hellip", 4 }, { '(', "(c)", "copy", 2 }, @@ -1146,7 +1174,7 @@ smartypants(int c, int *flags, MMIOT *f) break; else if ( c == '\'' && peek(f, j+1) == '\'' ) { Qstring("“", f); - ___mkd_reparse(cursor(f)+1, j-2, 0, f); + ___mkd_reparse(cursor(f)+1, j-2, 0, f, 0); Qstring("”", f); shift(f,j+1); return 1; @@ -1166,11 +1194,14 @@ smartypants(int c, int *flags, MMIOT *f) * let the caller figure it out. */ static int -tickhandler(MMIOT *f, int tickchar, int minticks, spanhandler spanner) +tickhandler(MMIOT *f, int tickchar, int minticks, int allow_space, spanhandler spanner) { int endticks, size; int tick = nrticks(0, tickchar, f); + if ( !allow_space && isspace(peek(f,tick)) ) + return 0; + if ( (tick >= minticks) && (size = matchticks(f,tickchar,tick,&endticks)) ) { if ( endticks < tick ) { size += (tick - endticks); @@ -1265,7 +1296,7 @@ text(MMIOT *f) shift(f,len); } Qstring("",f); - ___mkd_reparse(sup, len, 0, f); + ___mkd_reparse(sup, len, 0, f, "()"); Qstring("", f); } break; @@ -1294,11 +1325,11 @@ text(MMIOT *f) } break; - case '~': if ( (f->flags & (MKD_NOSTRIKETHROUGH|MKD_TAGTEXT|MKD_STRICT)) || !tickhandler(f,c,2,delspan) ) + case '~': if ( (f->flags & (MKD_NOSTRIKETHROUGH|MKD_TAGTEXT|MKD_STRICT)) || ! tickhandler(f,c,2,0, delspan) ) Qchar(c, f); break; - case '`': if ( tag_text(f) || !tickhandler(f,c,1,codespan) ) + case '`': if ( tag_text(f) || !tickhandler(f,c,1,1,codespan) ) Qchar(c, f); break; @@ -1324,16 +1355,16 @@ text(MMIOT *f) Qchar(c, f); break; - case '>': case '#': case '.': case '-': - case '+': case '{': case '}': case ']': - case '!': case '[': case '*': case '_': - case '\\':case '(': case ')': - case '`': Qchar(c, f); + case EOF: Qchar('\\', f); break; - default: - Qchar('\\', f); - if ( c != EOF ) - shift(f,-1); + + default: if ( escaped(f,c) || + strchr(">#.-+{}]![*_\\()`", c) ) + Qchar(c, f); + else { + Qchar('\\', f); + shift(f, -1); + } break; } break; @@ -1403,9 +1434,14 @@ static int splat(Line *p, char *block, Istring align, int force, MMIOT *f) { int first, - idx = 0, + idx = p->dle, colno = 0; + + ___mkd_tidy(&p->text); + if ( T(p->text)[S(p->text)-1] == '|' ) + --S(p->text); + Qstring("\n", f); while ( idx < S(p->text) ) { first = idx; @@ -1421,7 +1457,7 @@ splat(Line *p, char *block, Istring align, int force, MMIOT *f) Qprintf(f, "<%s%s>", block, alignments[ (colno < S(align)) ? T(align)[colno] : a_NONE ]); - ___mkd_reparse(T(p->text)+first, idx-first, 0, f); + ___mkd_reparse(T(p->text)+first, idx-first, 0, f, "|"); Qprintf(f, "\n", block); idx++; colno++; @@ -1443,22 +1479,27 @@ printtable(Paragraph *pp, MMIOT *f) Line *hdr, *dash, *body; Istring align; - int start; - int hcols; + int hcols,start; char *p; - - if ( !(pp->text && pp->text->next) ) - return 0; + enum e_alignments it; hdr = pp->text; dash= hdr->next; body= dash->next; - /* first figure out cell alignments */ + if ( T(hdr->text)[hdr->dle] == '|' ) { + /* trim leading pipe off all lines + */ + Line *r; + for ( r = pp->text; r; r = r->next ) + r->dle ++; + } + + /* figure out cell alignments */ CREATE(align); - for (p=T(dash->text), start=0; start < S(dash->text); ) { + for (p=T(dash->text), start=dash->dle; start < S(dash->text); ) { char first, last; int end; @@ -1471,8 +1512,10 @@ printtable(Paragraph *pp, MMIOT *f) last = p[end]; } } - EXPAND(align) = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT) - : (( last == ':') ? a_RIGHT : a_NONE ); + it = ( first == ':' ) ? (( last == ':') ? a_CENTER : a_LEFT) + : (( last == ':') ? a_RIGHT : a_NONE ); + + EXPAND(align) = it; start = 1+end; } @@ -1598,7 +1641,7 @@ definitionlist(Paragraph *p, MMIOT *f) for ( ; p ; p = p->next) { for ( tag = p->text; tag; tag = tag->next ) { Qstring("
", f); - ___mkd_reparse(T(tag->text), S(tag->text), 0, f); + ___mkd_reparse(T(tag->text), S(tag->text), 0, f, 0); Qstring("
\n", f); } diff --git a/discount/html5.c b/discount/html5.c index 8b86988..de91b90 100644 --- a/discount/html5.c +++ b/discount/html5.c @@ -10,8 +10,6 @@ mkd_with_html5_tags() if ( populated ) return; populated = 1; - mkd_prepare_tags(); - mkd_define_tag("ASIDE", 0); mkd_define_tag("FOOTER", 0); mkd_define_tag("HEADER", 0); diff --git a/discount/main.c b/discount/main.c index 39c1a16..3dccbef 100644 --- a/discount/main.c +++ b/discount/main.c @@ -18,6 +18,7 @@ #include "config.h" #include "amalloc.h" #include "pgm_options.h" +#include "tags.h" #if HAVE_LIBGEN_H #include @@ -58,8 +59,7 @@ complain(char *fmt, ...) fflush(stderr); } - -float +int main(int argc, char **argv) { int opt; @@ -78,7 +78,7 @@ main(int argc, char **argv) char *q; MMIOT *doc; - if ( q = getenv("MARKDOWN_FLAGS") ) + if ( (q = getenv("MARKDOWN_FLAGS")) ) flags = strtol(q, 0, 0); pgm = basename(argv[0]); diff --git a/discount/makepage.c b/discount/makepage.c index 548d381..be058e9 100644 --- a/discount/makepage.c +++ b/discount/makepage.c @@ -22,7 +22,7 @@ basename(char *p) char *pgm = "makepage"; -float +int main(argc, argv) int argc; char **argv; diff --git a/discount/markdown.c b/discount/markdown.c index 4005b98..d7703ad 100644 --- a/discount/markdown.c +++ b/discount/markdown.c @@ -22,6 +22,9 @@ typedef int (*stfu)(const void*,const void*); typedef ANCHOR(Paragraph) ParagraphRoot; +static Paragraph *Pp(ParagraphRoot *, Line *, int); +static Paragraph *compile(Line *, int, MMIOT *); + /* case insensitive string sort for Footnote tags. */ int @@ -77,7 +80,7 @@ mkd_firstnonblank(Line *p) } -static int +static inline int blankline(Line *p) { return ! (p && (S(p->text) > p->dle) ); @@ -173,6 +176,61 @@ splitline(Line *t, int cutpoint) } } +#define UNCHECK(l) ((l)->flags &= ~CHECKED) + +/* + * walk a line, seeing if it's any of half a dozen interesting regular + * types. + */ +static void +checkline(Line *l) +{ + int eol, i; + int dashes = 0, spaces = 0, + equals = 0, underscores = 0, + stars = 0, tildes = 0; + + l->flags |= CHECKED; + l->kind = chk_text; + l->count = 0; + + if (l->dle >= 4) { l->kind=chk_code; return; } + + for ( eol = S(l->text); eol > l->dle && isspace(T(l->text)[eol-1]); --eol ) + ; + + for (i=l->dle; itext)[i]; + + if ( c != ' ' ) l->count++; + + switch (c) { + case '-': dashes = 1; break; + case ' ': spaces = 1; break; + case '=': equals = 1; break; + case '_': underscores = 1; break; + case '*': stars = 1; break; + case '~': tildes = 1; break; + default: return; + } + } + + if ( dashes + equals + underscores + stars + tildes > 1 ) + return; + + if ( spaces ) { + if ( (underscores || stars || dashes) ) + l->kind = chk_hr; + return; + } + + if ( stars || underscores ) { l->kind = chk_hr; } + else if ( dashes ) { l->kind = chk_dash; } + else if ( tildes ) { l->kind = chk_tilde; } + else if ( equals ) { l->kind = chk_equal; } +} + + static Line * commentblock(Paragraph *p, int *unclosed) @@ -181,7 +239,7 @@ commentblock(Paragraph *p, int *unclosed) char *end; for ( t = p->text; t ; t = t->next) { - if ( end = strstr(T(t->text), "-->") ) { + if ( (end = strstr(T(t->text), "-->")) ) { splitline(t, 3 + (end - T(t->text)) ); ret = t->next; t->next = 0; @@ -229,7 +287,7 @@ htmlblock(Paragraph *p, struct kw *tag, int *unclosed) } } else { - if ( closing = (c == '/') ) c = flogetc(&f); + if ( (closing = (c == '/')) ) c = flogetc(&f); for ( i=0; i < tag->size; c=flogetc(&f) ) { if ( tag->id[i++] != toupper(c) ) @@ -261,47 +319,6 @@ htmlblock(Paragraph *p, struct kw *tag, int *unclosed) } -/* tables look like - * header|header{|header} - * ------|------{|......} - * {body lines} - */ -static int -istable(Line *t) -{ - char *p; - Line *dashes, *body; - int l; - int dashed = 0; - - /* three lines, first must contain |, - second must be ---|---, - third must contain | - */ - if ( !(t->flags & PIPECHAR) ) - return 0; - - dashes = t->next; - if ( !(dashes && (dashes->flags & PIPECHAR)) ) - return 0; - - body = dashes->next; - if ( !(body && (body->flags & PIPECHAR)) ) - return 0; - - /* second line must contain - or | and nothing - * else except for whitespace or : - */ - for ( p = T(dashes->text), l = S(dashes->text); l > 0; ++p, --l) - if ( *p == '-' ) - dashed = 1; - else if ( ! ((*p == '|') || (*p == ':') || isspace(*p)) ) - return 0; - - return dashed; -} - - /* footnotes look like ^{0,3}[stuff]: $ */ static int @@ -322,76 +339,46 @@ isfootnote(Line *t) } -static int +static inline int isquote(Line *t) { - int j; - - for ( j=0; j < 4; j++ ) - if ( T(t->text)[j] == '>' ) - return 1; - else if ( !isspace(T(t->text)[j]) ) - return 0; - return 0; + return (t->dle < 4 && T(t->text)[t->dle] == '>'); } -static int -dashchar(char c) -{ - return (c == '*') || (c == '-') || (c == '_'); -} - - -static int +static inline int iscode(Line *t) { return (t->dle >= 4); } -static int +static inline int ishr(Line *t) { - int i, count=0; - char dash = 0; - char c; + if ( ! (t->flags & CHECKED) ) + checkline(t); - if ( iscode(t) ) return 0; - - for ( i = 0; i < S(t->text); i++) { - c = T(t->text)[i]; - if ( (dash == 0) && dashchar(c) ) - dash = c; - - if ( c == dash ) ++count; - else if ( !isspace(c) ) - return 0; - } - return (count >= 3); + if ( t->count > 2 ) + return t->kind == chk_hr || t->kind == chk_dash || t->kind == chk_equal; + return 0; } static int issetext(Line *t, int *htyp) { - int i; - /* then check for setext-style HEADER - * ====== + Line *n; + + /* check for setext-style HEADER + * ====== */ - if ( t->next ) { - char *q = T(t->next->text); - int last = S(t->next->text); + if ( (n = t->next) ) { + if ( !(n->flags & CHECKED) ) + checkline(n); - if ( (*q == '=') || (*q == '-') ) { - /* ignore trailing whitespace */ - while ( (last > 1) && isspace(q[last-1]) ) - --last; - - for (i=1; i < last; i++) - if ( q[0] != q[i] ) - return 0; + if ( n->kind == chk_dash || n->kind == chk_equal ) { *htyp = SETEXT; return 1; } @@ -403,28 +390,31 @@ issetext(Line *t, int *htyp) static int ishdr(Line *t, int *htyp) { - int i; - - - /* first check for etx-style ###HEADER### - */ - - /* leading run of `#`'s ? - */ - for ( i=0; T(t->text)[i] == '#'; ++i) - ; - /* ANY leading `#`'s make this into an ETX header */ - if ( i && (i < S(t->text) || i > 1) ) { + if ( (t->dle == 0) && (S(t->text) > 1) && (T(t->text)[0] == '#') ) { *htyp = ETX; return 1; } + /* And if not, maybe it's a SETEXT header instead + */ return issetext(t, htyp); } +static inline int +end_of_block(Line *t) +{ + int dummy; + + if ( !t ) + return 0; + + return ( (S(t->text) <= t->dle) || ishr(t) || ishdr(t, &dummy) ); +} + + static Line* is_discount_dt(Line *t, int *clip) { @@ -458,13 +448,12 @@ static Line* is_extra_dt(Line *t, int *clip) { #if USE_EXTRA_DL - int i; if ( t && t->next && T(t->text)[0] != '=' && T(t->text)[S(t->text)-1] != '=') { Line *x; - if ( iscode(t) || blankline(t) || ishdr(t,&i) || ishr(t) ) + if ( iscode(t) || end_of_block(t) ) return 0; if ( (x = skipempty(t->next)) && is_extra_dd(x) ) { @@ -486,7 +475,7 @@ isdefinition(Line *t, int *clip, int *kind) Line *ret; *kind = 1; - if ( ret = is_discount_dt(t,clip) ) + if ( (ret = is_discount_dt(t,clip)) ) return ret; *kind=2; @@ -500,7 +489,7 @@ islist(Line *t, int *clip, DWORD flags, int *list_type) int i, j; char *q; - if ( /*iscode(t) ||*/ blankline(t) || ishdr(t,&i) || ishr(t) ) + if ( end_of_block(t) ) return 0; if ( !(flags & (MKD_NODLIST|MKD_STRICT)) && isdefinition(t,clip,list_type) ) @@ -571,6 +560,7 @@ headerblock(Paragraph *pp, int htyp) ++i; CLIP(p->text, 0, i); + UNCHECK(p); for (j=S(p->text); (j > 1) && (T(p->text)[j-1] == '#'); --j) ; @@ -607,6 +597,46 @@ codeblock(Paragraph *p) } +#ifdef WITH_FENCED_CODE +static int +iscodefence(Line *r, int size) +{ + if ( !(r->flags & CHECKED) ) + checkline(r); + + return (r->kind == chk_tilde) && (r->count >= size); +} + +static Paragraph * +fencedcodeblock(ParagraphRoot *d, Line **ptr) +{ + Line *first, *r; + Paragraph *ret; + + first = (*ptr); + + /* don't allow zero-length code fences + */ + if ( (first->next == 0) || iscodefence(first->next, first->count) ) + return 0; + + /* find the closing fence, discard the fences, + * return a Paragraph with the contents + */ + for ( r = first; r && r->next; r = r->next ) + if ( iscodefence(r->next, first->count) ) { + (*ptr) = r->next->next; + ret = Pp(d, first->next, CODE); + ___mkd_freeLine(first); + ___mkd_freeLine(r->next); + r->next = 0; + return ret; + } + return 0; +} +#endif + + static int centered(Line *first, Line *last) { @@ -630,19 +660,18 @@ endoftextblock(Line *t, int toplevelblock, DWORD flags) { int z; - if ( blankline(t)||isquote(t)||ishdr(t,&z)||ishr(t) ) - return 1; - - /* HORRIBLE STANDARDS KLUDGE: non-toplevel paragraphs absorb adjacent - * code blocks - */ - if ( toplevelblock && iscode(t) ) + if ( end_of_block(t) || isquote(t) ) return 1; - /* HORRIBLE STANDARDS KLUDGE: Toplevel paragraphs eat absorb adjacent - * list items, but sublevel blocks behave properly. + /* HORRIBLE STANDARDS KLUDGES: + * 1. non-toplevel paragraphs absorb adjacent code blocks + * 2. Toplevel paragraphs eat absorb adjacent list items, + * but sublevel blocks behave properly. + * (What this means is that we only need to check for code + * blocks at toplevel, and only check for list items at + * nested levels.) */ - return toplevelblock ? 0 : islist(t,&z,flags, &z); + return toplevelblock ? 0 : islist(t,&z,flags,&z); } @@ -713,7 +742,7 @@ isdivmarker(Line *p, int start, DWORD flags) * * one sick horrible thing about blockquotes is that even though * it just takes ^> to start a quote, following lines, if quoted, - * assume that the prefix is ``>''. This means that code needs + * assume that the prefix is ``> ''. This means that code needs * to be indented *5* spaces from the leading '>', but *4* spaces * from the start of the line. This does not appear to be * documented in the reference implementation, but it's the @@ -738,6 +767,7 @@ quoteblock(Paragraph *p, DWORD flags) if ( T(t->text)[qp] == ' ' ) qp++; CLIP(t->text, 0, qp); + UNCHECK(t); t->dle = mkd_firstnonblank(t); } @@ -760,7 +790,7 @@ quoteblock(Paragraph *p, DWORD flags) /* and this would be an "%id:" prefix */ prefix="id"; - if ( p->ident = malloc(4+strlen(prefix)+S(q->text)) ) + if ( (p->ident = malloc(4+strlen(prefix)+S(q->text))) ) sprintf(p->ident, "%s=\"%.*s\"", prefix, S(q->text)-(i+2), T(q->text)+(i+1) ); @@ -770,28 +800,6 @@ quoteblock(Paragraph *p, DWORD flags) } -/* - * A table block starts with a table header (see istable()), and continues - * until EOF or a line that /doesn't/ contain a |. - */ -static Line * -tableblock(Paragraph *p) -{ - Line *t, *q; - - for ( t = p->text; t && (q = t->next); t = t->next ) { - if ( !(t->flags & PIPECHAR) ) { - t->next = 0; - return q; - } - } - return 0; -} - - -static Paragraph *Pp(ParagraphRoot *, Line *, int); -static Paragraph *compile(Line *, int, MMIOT *); - typedef int (*linefn)(Line *); @@ -810,6 +818,7 @@ listitem(Paragraph *p, int indent, DWORD flags, linefn check) for ( t = p->text; t ; t = q) { CLIP(t->text, 0, clip); + UNCHECK(t); t->dle = mkd_firstnonblank(t); if ( (q = skipempty(t->next)) == 0 ) { @@ -870,6 +879,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind) if ( kind == 1 /* discount dl */ ) for ( q = labels; q; q = q->next ) { CLIP(q->text, 0, 1); + UNCHECK(q); S(q->text)--; } @@ -925,7 +935,7 @@ enumerated_block(Paragraph *top, int clip, MMIOT *f, int list_class) || islist(q, &clip, f->flags, &z) != list_class ) break; - if ( para = (q != text) ) { + if ( (para = (q != text)) ) { Line anchor; anchor.next = text; @@ -1119,6 +1129,58 @@ compile_document(Line *ptr, MMIOT *f) } +static int +first_nonblank_before(Line *j, int dle) +{ + return (j->dle < dle) ? j->dle : dle; +} + + +static int +actually_a_table(MMIOT *f, Line *pp) +{ + Line *r; + int j; + int c; + + /* tables need to be turned on */ + if ( f->flags & (MKD_STRICT|MKD_NOTABLES) ) + return 0; + + /* tables need three lines */ + if ( !(pp && pp->next && pp->next->next) ) { + return 0; + } + + /* all lines must contain |'s */ + for (r = pp; r; r = r->next ) + if ( !(r->flags & PIPECHAR) ) { + return 0; + } + + /* if the header has a leading |, all lines must have leading |'s */ + if ( T(pp->text)[pp->dle] == '|' ) { + for ( r = pp; r; r = r->next ) + if ( T(r->text)[first_nonblank_before(r,pp->dle)] != '|' ) { + return 0; + } + } + + /* second line must be only whitespace, -, |, or : */ + r = pp->next; + + for ( j=r->dle; j < S(r->text); ++j ) { + c = T(r->text)[j]; + + if ( !(isspace(c)||(c=='-')||(c==':')||(c=='|')) ) { + return 0; + } + } + + return 1; +} + + /* * break a collection of markdown input into * blocks of lists, code, html, and text to @@ -1149,6 +1211,10 @@ compile(Line *ptr, int toplevel, MMIOT *f) ptr = codeblock(p); } +#if WITH_FENCED_CODE + else if ( iscodefence(ptr,3) && (p=fencedcodeblock(&d, &ptr)) ) + /* yay, it's already done */ ; +#endif else if ( ishr(ptr) ) { p = Pp(&d, 0, HR); r = ptr; @@ -1175,13 +1241,12 @@ compile(Line *ptr, int toplevel, MMIOT *f) p = Pp(&d, ptr, HDR); ptr = headerblock(p, hdr_type); } - else if ( istable(ptr) && !(f->flags & (MKD_STRICT|MKD_NOTABLES)) ) { - p = Pp(&d, ptr, TABLE); - ptr = tableblock(p); - } else { p = Pp(&d, ptr, MARKUP); ptr = textblock(p, toplevel, f->flags); + /* tables are a special kind of paragraph */ + if ( actually_a_table(f, p->text) ) + p->typ = TABLE; } if ( (para||toplevel) && !p->align ) diff --git a/discount/markdown.h b/discount/markdown.h index f6b05fc..fae16ea 100644 --- a/discount/markdown.h +++ b/discount/markdown.h @@ -29,6 +29,12 @@ typedef struct line { int dle; /* leading indent on the line */ int flags; /* special attributes for this line */ #define PIPECHAR 0x01 /* line contains a | */ +#define CHECKED 0x02 + + enum { chk_text, chk_code, + chk_hr, chk_dash, + chk_tilde, chk_equal } kind; + int count; } Line; @@ -73,6 +79,12 @@ typedef struct callback_data { } Callback_data; +struct escaped { + char *text; + struct escaped *up; +} ; + + /* a magic markdown io thing holds all the data structures needed to * do the backend processing of a markdown document */ @@ -82,6 +94,7 @@ typedef struct mmiot { Qblock Q; int isp; int reference; + struct escaped *esc; char *ref_prefix; STRING(Footnote) *footnotes; DWORD flags; @@ -176,7 +189,7 @@ extern void ___mkd_initmmiot(MMIOT *, void *); extern void ___mkd_freemmiot(MMIOT *, void *); extern void ___mkd_freeLineRange(Line *, Line *); extern void ___mkd_xml(char *, int, FILE *); -extern void ___mkd_reparse(char *, int, int, MMIOT*); +extern void ___mkd_reparse(char *, int, int, MMIOT*, char*); extern void ___mkd_emblock(MMIOT*); extern void ___mkd_tidy(Cstring *); diff --git a/discount/mkd2html.c b/discount/mkd2html.c index ae15320..1d10e6d 100644 --- a/discount/mkd2html.c +++ b/discount/mkd2html.c @@ -64,8 +64,7 @@ fail(char *why, ...) exit(1); } - -void +int main(argc, argv) char **argv; { diff --git a/discount/mkdio.c b/discount/mkdio.c index 0bee521..291dbce 100644 --- a/discount/mkdio.c +++ b/discount/mkdio.c @@ -254,7 +254,7 @@ mkd_parse_line(char *bfr, int size, MMIOT *f, int flags) { ___mkd_initmmiot(f, 0); f->flags = flags & USER_FLAGS; - ___mkd_reparse(bfr, size, 0, f); + ___mkd_reparse(bfr, size, 0, f, 0); ___mkd_emblock(f); } @@ -269,7 +269,7 @@ mkd_line(char *bfr, int size, char **res, DWORD flags) mkd_parse_line(bfr, size, &f, flags); - if ( len = S(f.out) ) { + if ( (len = S(f.out)) ) { /* kludge alert; we know that T(f.out) is malloced memory, * so we can just steal it away. This is awful -- there * should be an opaque method that transparently moves diff --git a/discount/mkdio.h.in b/discount/mkdio.h.in index 36c0d8f..8f5490c 100644 --- a/discount/mkdio.h.in +++ b/discount/mkdio.h.in @@ -84,6 +84,7 @@ void mkd_ref_prefix(MMIOT*, char*); #define MKD_TAGTEXT 0x00000020 /* process text inside an html tag; no * , no , no html or [] expansion */ #define MKD_NO_EXT 0x00000040 /* don't allow pseudo-protocols */ +#define MKD_NOEXT MKD_NO_EXT /* ^^^ (aliased for user convenience) */ #define MKD_CDATA 0x00000080 /* generate code for xml ![CDATA[...]] */ #define MKD_NOSUPERSCRIPT 0x00000100 /* no A^B */ #define MKD_NORELAXED 0x00000200 /* emphasis happens /everywhere/ */ diff --git a/discount/mktags.c b/discount/mktags.c new file mode 100644 index 0000000..0d4680a --- /dev/null +++ b/discount/mktags.c @@ -0,0 +1,89 @@ +/* block-level tags for passing html blocks through the blender + */ +#include + +#define __WITHOUT_AMALLOC 1 +#include "cstring.h" +#include "tags.h" + +STRING(struct kw) blocktags; + + +/* define a html block tag + */ +static void +define_one_tag(char *id, int selfclose) +{ + struct kw *p = &EXPAND(blocktags); + + p->id = id; + p->size = strlen(id); + p->selfclose = selfclose; +} + + +/* case insensitive string sort (for qsort() and bsearch() of block tags) + */ +static int +casort(struct kw *a, struct kw *b) +{ + if ( a->size != b->size ) + return a->size - b->size; + return strncasecmp(a->id, b->id, b->size); +} + + +/* stupid cast to make gcc shut up about the function types being + * passed into qsort() and bsearch() + */ +typedef int (*stfu)(const void*,const void*); + + +/* load in the standard collection of html tags that markdown supports + */ +main() +{ + int i; + +#define KW(x) define_one_tag(x, 0) +#define SC(x) define_one_tag(x, 1) + + KW("STYLE"); + KW("SCRIPT"); + KW("ADDRESS"); + KW("BDO"); + KW("BLOCKQUOTE"); + KW("CENTER"); + KW("DFN"); + KW("DIV"); + KW("OBJECT"); + KW("H1"); + KW("H2"); + KW("H3"); + KW("H4"); + KW("H5"); + KW("H6"); + KW("LISTING"); + KW("NOBR"); + KW("UL"); + KW("P"); + KW("OL"); + KW("DL"); + KW("PLAINTEXT"); + KW("PRE"); + KW("TABLE"); + KW("WBR"); + KW("XMP"); + SC("HR"); + KW("IFRAME"); + KW("MAP"); + + qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort); + + printf("static struct kw blocktags[] = {\n"); + for (i=0; i < S(blocktags); i++) + printf(" { \"%s\", %d, %d },\n", T(blocktags)[i].id, T(blocktags)[i].size, T(blocktags)[i].selfclose ); + printf("};\n\n"); + printf("#define NR_blocktags %d\n", S(blocktags)); + exit(0); +} diff --git a/discount/pgm_options.c b/discount/pgm_options.c new file mode 100644 index 0000000..d876536 --- /dev/null +++ b/discount/pgm_options.c @@ -0,0 +1,137 @@ +/* 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 +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "amalloc.h" + +#if HAVE_LIBGEN_H +#include +#endif + +static struct _opt { + char *name; + char *desc; + int off; + int skip; + int sayenable; + mkd_flag_t flag; +} opts[] = { + { "tabstop", "default (4-space) tabstops", 0, 0, 1, MKD_TABSTOP }, + { "image", "images", 1, 0, 1, MKD_NOIMAGE }, + { "links", "links", 1, 0, 1, MKD_NOLINKS }, + { "relax", "emphasis inside words", 1, 1, 1, MKD_STRICT }, + { "strict", "emphasis inside words", 0, 0, 1, MKD_STRICT }, + { "tables", "tables", 1, 0, 1, MKD_NOTABLES }, + { "header", "pandoc-style headers", 1, 0, 1, MKD_NOHEADER }, + { "html", "raw html", 1, 0, 1, MKD_NOHTML }, + { "ext", "extended protocols", 1, 0, 1, MKD_NO_EXT }, + { "cdata", "generate cdata", 0, 0, 0, MKD_CDATA }, + { "smarty", "smartypants", 1, 0, 1, MKD_NOPANTS }, + { "pants", "smartypants", 1, 1, 1, MKD_NOPANTS }, + { "toc", "tables of contents", 0, 0, 1, MKD_TOC }, + { "autolink", "autolinking", 0, 0, 1, MKD_AUTOLINK }, + { "safelink", "safe links", 0, 0, 1, MKD_SAFELINK }, + { "strikethrough", "strikethrough", 1, 0, 1, MKD_NOSTRIKETHROUGH }, + { "del", "strikethrough", 1, 1, 1, MKD_NOSTRIKETHROUGH }, + { "superscript", "superscript", 1, 0, 1, MKD_NOSUPERSCRIPT }, + { "emphasis", "emphasis inside words", 0, 0, 1, MKD_NORELAXED }, + { "divquote", ">%class% blockquotes", 1, 0, 1, MKD_NODIVQUOTE }, + { "alphalist", "alpha lists", 1, 0, 1, MKD_NOALPHALIST }, + { "definitionlist","definition lists", 1, 0, 1, MKD_NODLIST }, + { "1.0", "markdown 1.0 compatibility", 0, 0, 1, MKD_1_COMPAT }, + { "footnotes", "markdown extra footnotes", 0, 0, 1, MKD_EXTRA_FOOTNOTE }, + { "footnote", "markdown extra footnotes", 0, 1, 1, MKD_EXTRA_FOOTNOTE }, +} ; + +#define NR(x) (sizeof x / sizeof x[0]) + + +typedef int (*stfu)(const void *, const void *); + +int +sort_by_name(struct _opt *a, struct _opt *b) +{ + return strcmp(a->name,b->name); +} + +int +sort_by_flag(struct _opt *a, struct _opt *b) +{ + return a->flag - b->flag; +} + + +void +show_flags(int byname) +{ + int i; + + if ( byname ) { + qsort(opts, NR(opts), sizeof(opts[0]), (stfu)sort_by_name); + + for (i=0; i < NR(opts); i++) + if ( ! opts[i].skip ) + fprintf(stderr, "%16s : %s\n", opts[i].name, opts[i].desc); + } + else { + qsort(opts, NR(opts), sizeof(opts[0]), (stfu)sort_by_flag); + + for (i=0; i < NR(opts); i++) + if ( ! opts[i].skip ) { + fprintf(stderr, "%08lx : ", (long)opts[i].flag); + if ( opts[i].sayenable ) + fprintf(stderr, opts[i].off ? "disable " : "enable "); + fprintf(stderr, "%s\n", opts[i].desc); + } + } +} + + +int +set_flag(mkd_flag_t *flags, char *optionstring) +{ + int i; + int enable; + char *arg; + + for ( arg = strtok(optionstring, ","); arg; arg = strtok(NULL, ",") ) { + if ( *arg == '+' || *arg == '-' ) + enable = (*arg++ == '+') ? 1 : 0; + else if ( strncasecmp(arg, "no", 2) == 0 ) { + arg += 2; + enable = 0; + } + else + enable = 1; + + for ( i=0; i < NR(opts); i++ ) + if ( strcasecmp(arg, opts[i].name) == 0 ) + break; + + if ( i < NR(opts) ) { + if ( opts[i].off ) + enable = !enable; + + if ( enable ) + *flags |= opts[i].flag; + else + *flags &= ~opts[i].flag; + } + else + return 0; + } + return 1; +} diff --git a/discount/pgm_options.h b/discount/pgm_options.h new file mode 100644 index 0000000..b7544cd --- /dev/null +++ b/discount/pgm_options.h @@ -0,0 +1,9 @@ +#ifndef PGM_OPTIONS_D +#define PGM_OPTIONS_D + +#include + +int set_flag(mkd_flag_t *flags, char *optionstring); +void show_flags(int byname); + +#endif/*PGM_OPTIONS_D*/ diff --git a/discount/setup.c b/discount/setup.c index 79f47aa..988a6aa 100644 --- a/discount/setup.c +++ b/discount/setup.c @@ -18,7 +18,6 @@ #include "amalloc.h" #include "tags.h" -static int need_to_setup = 1; static int need_to_initrng = 1; void @@ -29,19 +28,12 @@ mkd_initialize() need_to_initrng = 0; INITRNG(time(0)); } - if ( need_to_setup ) { - need_to_setup = 0; - mkd_prepare_tags(); - } } void mkd_shlib_destructor() { - if ( !need_to_setup ) { - need_to_setup = 1; - mkd_deallocate_tags(); - } + mkd_deallocate_tags(); } diff --git a/discount/tags.c b/discount/tags.c index 00affc1..b5043dd 100644 --- a/discount/tags.c +++ b/discount/tags.c @@ -4,19 +4,33 @@ #include "cstring.h" #include "tags.h" -STRING(struct kw) blocktags; +STRING(struct kw) extratags; + +/* the standard collection of tags are built and sorted when + * discount is configured, so all we need to do is pull them + * in and use them. + * + * Additional tags still need to be allocated, sorted, and deallocated. + */ +#include "blocktags" -/* define a html block tag +/* define an additional html block tag */ void mkd_define_tag(char *id, int selfclose) { - struct kw *p = &EXPAND(blocktags); - - p->id = id; - p->size = strlen(id); - p->selfclose = selfclose; + struct kw *p; + + /* only add the new tag if it doesn't exist in + * either the standard or extra tag tables. + */ + if ( !(p = mkd_search_tags(id, strlen(id))) ) { + p = &EXPAND(extratags); + p->id = id; + p->size = strlen(id); + p->selfclose = selfclose; + } } @@ -37,87 +51,41 @@ casort(struct kw *a, struct kw *b) typedef int (*stfu)(const void*,const void*); -/* sort the list of html block tags for later searching +/* sort the list of extra html block tags for later searching */ void mkd_sort_tags() { - qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort); + qsort(T(extratags), S(extratags), sizeof(struct kw), (stfu)casort); } - /* look for a token in the html block tag list */ struct kw* mkd_search_tags(char *pat, int len) { struct kw key; + struct kw *ret; key.id = pat; key.size = len; - return bsearch(&key, T(blocktags), S(blocktags), sizeof key, (stfu)casort); -} - - -static int populated = 0; + if ( (ret=bsearch(&key,blocktags,NR_blocktags,sizeof key,(stfu)casort)) ) + return ret; + if ( S(extratags) ) + return bsearch(&key,T(extratags),S(extratags),sizeof key,(stfu)casort); + + return 0; +} -/* load in the standard collection of html tags that markdown supports - */ -void -mkd_prepare_tags() -{ - -#define KW(x) mkd_define_tag(x, 0) -#define SC(x) mkd_define_tag(x, 1) - if ( populated ) return; - populated = 1; - - KW("STYLE"); - KW("SCRIPT"); - KW("ADDRESS"); - KW("BDO"); - KW("BLOCKQUOTE"); - KW("CENTER"); - KW("DFN"); - KW("DIV"); - KW("OBJECT"); - KW("H1"); - KW("H2"); - KW("H3"); - KW("H4"); - KW("H5"); - KW("H6"); - KW("LISTING"); - KW("NOBR"); - KW("UL"); - KW("P"); - KW("OL"); - KW("DL"); - KW("PLAINTEXT"); - KW("PRE"); - KW("TABLE"); - KW("WBR"); - KW("XMP"); - SC("HR"); - SC("BR"); - KW("IFRAME"); - KW("MAP"); - - mkd_sort_tags(); -} /* mkd_prepare_tags */ - - -/* destroy the blocktags list (for shared libraries) +/* destroy the extratags list (for shared libraries) */ void mkd_deallocate_tags() { - if ( S(blocktags) > 0 ) { - populated = 0; - DELETE(blocktags); - } + if ( S(extratags) > 0 ) + DELETE(extratags); } /* mkd_deallocate_tags */ diff --git a/discount/tests/code.t b/discount/tests/code.t index 8e8f20c..92df860 100644 --- a/discount/tests/code.t +++ b/discount/tests/code.t @@ -31,5 +31,61 @@ try 'backslashes in code(1)' ' printf "%s: \n", $1;' \ try 'backslashes in code(2)' '`printf "%s: \n", $1;`' \ '

printf "%s: \n", $1;

' +if ./markdown -V | grep FENCED-CODE >/dev/null; then + +try 'fenced code block' \ +'~~~ +code! +~~~' \ + '
code!
+
' + +try 'fenced code block in list' \ +'1. ~~~ +code block +~~~' \ +'
    +
  1. code block
    +
  2. +
' + +try 'fenced code block in blockquote' \ +'>~~~ +code +~~~' \ +'
code
+
' + +try 'unterminated fenced code block' \ +'~~~ +code' \ +'

~~~ +code

' + +try 'fenced code block with tildes' \ +'~~~~~ +~~~ +code with tildes +~~~ +~~~~~' \ +'
~~~
+code with tildes
+~~~
+
' + +try 'paragraph with trailing fenced block' \ +'text text text +text text text +~~~ +code code code? +~~~' \ +'

text text text +text text text +~~~ +code code code? +~~~

' + +fi + summary $0 exit $rc diff --git a/discount/tests/defects.t b/discount/tests/defects.t new file mode 100644 index 0000000..9aaa84d --- /dev/null +++ b/discount/tests/defects.t @@ -0,0 +1,17 @@ +. tests/functions.sh + +title "reported defects" + +rc=0 +MARKDOWN_FLAGS= + +try 'masses of non-block html' \ +'foo
+
+bar
' \ +'

foo
+
+bar

' + +summary $0 +exit $rc diff --git a/discount/tests/dl.t b/discount/tests/dl.t index 99d1fe4..5465a81 100644 --- a/discount/tests/dl.t +++ b/discount/tests/dl.t @@ -37,15 +37,10 @@ if [ "$DL" = "DISCOUNT" -o "$DL" = "BOTH" ]; then try -fnodefinitionlist '=tag= does nothing' "$SRC" \ - '

=this=

- -
is an ugly
-
- -

=test=

- -
eh?
-
' + '

=this= + is an ugly +=test= + eh?

' fi if [ "$DL" = "EXTRA" -o "$DL" = "BOTH" ]; then diff --git a/discount/tests/functions.sh b/discount/tests/functions.sh index ae0b2a3..3ca8656 100644 --- a/discount/tests/functions.sh +++ b/discount/tests/functions.sh @@ -57,8 +57,13 @@ try() { ./echo ./echo "$1" fi - ./echo "wanted: $3" - ./echo "got : $Q" + ./echo "source:" + ./echo "$2" | sed -e 's/^/ /' + ./echo "diff:" + (./echo "$3" >> $$.w + ./echo "$Q" >> $$.g + diff $$.w $$.g ) | sed -e 's/^/ /' + rm -f $$.w $$.g rc=1 fi } diff --git a/discount/tests/html.t b/discount/tests/html.t index 6d98226..81c0383 100644 --- a/discount/tests/html.t +++ b/discount/tests/html.t @@ -21,15 +21,6 @@ text' \ '
-

text

' - -try 'self-closing block tags (br)' \ - '
- -text' \ - '
- -

text

' try 'html comments' \ diff --git a/discount/tests/para.t b/discount/tests/para.t index 29445e5..74a6598 100644 --- a/discount/tests/para.t +++ b/discount/tests/para.t @@ -8,10 +8,8 @@ MARKDOWN_FLAGS= try 'paragraph followed by code' \ 'a b' \ - '

a

- -
b
-
' + '

a + b

' try 'single-line paragraph' 'a' '

a

' diff --git a/discount/tests/peculiarities.t b/discount/tests/peculiarities.t index f97597f..77d41dc 100644 --- a/discount/tests/peculiarities.t +++ b/discount/tests/peculiarities.t @@ -13,7 +13,7 @@ try 'list followed by header .......... ' \ '
  • AAA -

    – BBB

  • +

    - BBB

' try 'ul with mixed item prefixes' \ diff --git a/discount/tests/reddit.t b/discount/tests/reddit.t index 268cbcf..3215edc 100644 --- a/discount/tests/reddit.t +++ b/discount/tests/reddit.t @@ -6,7 +6,7 @@ rc=0 MARKDOWN_FLAGS= try 'smiley faces?' '[8-9] <]:-( x ---> [4]' \ - '

[8-9] <]:–( x —–> [4]

' + '

[8-9] <]:-( x —> [4]

' try 'really long ETX headers' \ '#####################################################hi' \ diff --git a/discount/tests/smarty.t b/discount/tests/smarty.t index 8c9ccc5..0ce2ee4 100644 --- a/discount/tests/smarty.t +++ b/discount/tests/smarty.t @@ -10,9 +10,10 @@ try '(r) -> ®' '(r)' '

®

' try '(tm) -> ™' '(tm)' '

' try '... -> …' '...' '

' -try '"--" -> —' '--' '

' +try '"?--" -> –' '?--' '

?–

' +try '"?---" -> —' '?---' '

?—

' -try '"-" -> –' 'regular -' '

regular –

' +try '"--" -> –' 'regular --' '

regular –

' try 'A-B -> A-B' 'A-B' '

A-B

' try '"fancy" -> “fancy”' '"fancy"' '

“fancy”

' try "'fancy'" "'fancy'" '

‘fancy’

' diff --git a/discount/tests/strikethrough.t b/discount/tests/strikethrough.t index 9016a5c..ffb0c50 100644 --- a/discount/tests/strikethrough.t +++ b/discount/tests/strikethrough.t @@ -10,6 +10,7 @@ try -fnodel '... with -fnodel' '~~deleted~~' '

~~deleted~~

' try 'mismatched tildes' '~~~tick~~' '

~tick

' try 'mismatched tildes(2)' '~~tick~~~' '

~~tick~~~

' try 'single tildes' '~tick~' '

~tick~

' +try 'tildes wrapped in spaces' '~~~ ~~~' '

~~~ ~~~

' summary $0 exit $rc diff --git a/discount/tests/tables.t b/discount/tests/tables.t index 97e55ea..4f82b72 100644 --- a/discount/tests/tables.t +++ b/discount/tests/tables.t @@ -12,13 +12,11 @@ try 'single-column table' \ ' - - @@ -33,7 +31,7 @@ hello|sailor' \ '
hello
sailor
- + @@ -75,7 +73,7 @@ hello| '
a a b
- + @@ -85,7 +83,7 @@ hello| - + @@ -99,7 +97,7 @@ hello|sailor' \ '
a a b
sailor
- + @@ -119,7 +117,7 @@ hello|sailor|boy' \ '
a a b
- + @@ -137,7 +135,7 @@ try -fnotables 'tables with -fnotables' \ -|- hello|sailor' \ '

a|b -–|– +-|- hello|sailor

' try 'deceptive non-table text' \ @@ -152,7 +150,7 @@ try 'table headers only' \ 'a|b|c -|-|-' \ '

a|b|c -–|–|–

' +-|-|-

' try 'escaped title line' \ 'A\|B @@ -177,7 +175,7 @@ try 'escaped dashes line' \ -\|- C |D' \ '

A |B -–|– +-|- C |D

' try 'escaped content line' \ @@ -204,8 +202,75 @@ try 'content line w/o dashes' \ --|- CD' \ '

A |B -—|– +–|- CD

' +try 'table followed by text' \ + ' +A|B +-|- +C|D + +foo?' \ +'
a a b
+ + + + + + + + + + + + +
AB
CD
+ + +

foo?

' + +try "table with flanking |'s" \ +' +|A|B| +|-|-| +|D|C|' \ +' + + + + + + + + + + + + +
AB
DC
' + +try "table with leading |'s and alignment" \ +'|AA|BB|CC +|:-|::|-: +|aa|bb|cc' \ +' + + + + + + + + + + + + + + +
AABBCC
aabbcc
' + + summary $0 exit $rc diff --git a/discount/tests/toc.t b/discount/tests/toc.t index 5b02548..7f6057a 100644 --- a/discount/tests/toc.t +++ b/discount/tests/toc.t @@ -23,9 +23,11 @@ hi' \ try '-T -ftoc' 'toc item with link' \ '##[H2](H2) here' \ '

H2 here

' @@ -56,9 +58,11 @@ hi' \ try '-T -ftoc' 'toc item with link' \ '##[H2](H2) here' \ '

H2 here

' diff --git a/discount/theme.1 b/discount/theme.1 index 473b913..3bcf38a 100644 --- a/discount/theme.1 +++ b/discount/theme.1 @@ -9,6 +9,7 @@ .Sh SYNOPSIS .Nm .Op Fl d Pa root +.Op Fl E .Op Fl f .Op Fl o Pa file .Op Fl p Pa pagename @@ -94,7 +95,7 @@ that this copy of theme was compiled with. .El .Pp If input is coming from a file and the output was not set with the -.Ar o +.Fl o option, .Nm writes the output to .Pa file-sans-text.html @@ -115,6 +116,21 @@ Set the .Em "document root" to .Ar root +.It Fl E +Normally +theme will not expand +.Pa "" +or +.Pa "" +in the +.Pa "" +section, or +.Pa "" +in the +.Pa "" +section, but the +.Fl E +option overrides this and allows expansions everywhere. .It Fl f Forcibly overwrite existing html files. .It Fl o Pa filename diff --git a/discount/theme.c b/discount/theme.c index 637fe5e..52bded7 100644 --- a/discount/theme.c +++ b/discount/theme.c @@ -37,6 +37,8 @@ char *pgm = "theme"; char *output = 0; char *pagename = 0; char *root = 0; +int everywhere = 0; /* expand all ctx) ) return -1; @@ -38,16 +40,23 @@ mkd_toc(Document *p, char **doc) for ( srcp = tp->down; srcp; srcp = srcp->next ) { if ( srcp->typ == HDR && srcp->text ) { - if ( last_hnumber >= srcp->hnumber ) { - while ( last_hnumber > srcp->hnumber ) { - Csprintf(&res, "%*s\n", last_hnumber-1,""); - --last_hnumber; - } + while ( last_hnumber > srcp->hnumber ) { + if ( (last_hnumber - srcp->hnumber) > 1 ) + Csprintf(&res, "\n"); + Csprintf(&res, "\n%*s\n%*s", + last_hnumber-1, "", last_hnumber-1, ""); + --last_hnumber; } + if ( last_hnumber == srcp->hnumber ) + Csprintf(&res, "\n"); + else if ( (srcp->hnumber > last_hnumber) && !first ) + Csprintf(&res, "\n"); + while ( srcp->hnumber > last_hnumber ) { - Csprintf(&res, "%*s%s\n", last_hnumber, ""); + Csprintf(&res, "\n%*s\n%*s", + last_hnumber, "", last_hnumber, ""); } if ( (size = S(res)) > 0 ) { diff --git a/discount/tools/cols.c b/discount/tools/cols.c index 68ecc59..73cdd5e 100644 --- a/discount/tools/cols.c +++ b/discount/tools/cols.c @@ -1,10 +1,11 @@ #include #include +int main(argc, argv) char **argv; { - register c; + int register c; int xp; int width; diff --git a/discount/tools/echo.c b/discount/tools/echo.c index c7aa8ff..b434726 100644 --- a/discount/tools/echo.c +++ b/discount/tools/echo.c @@ -2,7 +2,7 @@ #include #include - +int main(argc, argv) char **argv; { diff --git a/discount/version.c.in b/discount/version.c.in index 07ec94d..aaa0722 100644 --- a/discount/version.c.in +++ b/discount/version.c.in @@ -23,5 +23,8 @@ char markdown_version[] = VERSION #endif #if WITH_GITHUB_TAGS " GITHUB-TAGS" +#endif +#if WITH_FENCED_CODE + " FENCED-CODE" #endif ; diff --git a/discount/xml.c b/discount/xml.c index 5e58389..65fa075 100644 --- a/discount/xml.c +++ b/discount/xml.c @@ -46,7 +46,7 @@ mkd_generatexml(char *p, int size, FILE *out) while ( size-- > 0 ) { c = *p++; - if ( entity = mkd_xmlchar(c) ) + if ( (entity = mkd_xmlchar(c)) ) fputs(entity, out); else fputc(c, out); @@ -69,7 +69,7 @@ mkd_xml(char *p, int size, char **res) while ( size-- > 0 ) { c = *p++; - if ( entity = mkd_xmlchar(c) ) + if ( (entity = mkd_xmlchar(c)) ) Cswrite(&f, entity, strlen(entity)); else Csputc(c, &f); diff --git a/discount/xmlpage.c b/discount/xmlpage.c index 96ed2b7..e2925b5 100644 --- a/discount/xmlpage.c +++ b/discount/xmlpage.c @@ -30,7 +30,7 @@ mkd_xhtmlpage(Document *p, int flags, FILE *out) fprintf(out, "\n"); fprintf(out, "\n"); - if ( title = mkd_doc_title(p) ) + if ( (title = mkd_doc_title(p)) ) fprintf(out, "%s\n", title); mkd_generatecss(p, out); fprintf(out, "\n"); From 27b25fd2d192e8a48ab895eeecb9385d8544d304 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Mon, 23 Jan 2012 21:59:07 +0000 Subject: [PATCH 04/22] Added blocktags. This file is generated automatically by the makefile. It would be better if this were automated. --- discount/blocktags | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 discount/blocktags diff --git a/discount/blocktags b/discount/blocktags new file mode 100644 index 0000000..e7bdf73 --- /dev/null +++ b/discount/blocktags @@ -0,0 +1,33 @@ +static struct kw blocktags[] = { + { "P", 1, 0 }, + { "DL", 2, 0 }, + { "H1", 2, 0 }, + { "H2", 2, 0 }, + { "H3", 2, 0 }, + { "H4", 2, 0 }, + { "H5", 2, 0 }, + { "H6", 2, 0 }, + { "HR", 2, 1 }, + { "OL", 2, 0 }, + { "UL", 2, 0 }, + { "BDO", 3, 0 }, + { "DFN", 3, 0 }, + { "DIV", 3, 0 }, + { "MAP", 3, 0 }, + { "PRE", 3, 0 }, + { "WBR", 3, 0 }, + { "XMP", 3, 0 }, + { "NOBR", 4, 0 }, + { "STYLE", 5, 0 }, + { "TABLE", 5, 0 }, + { "CENTER", 6, 0 }, + { "IFRAME", 6, 0 }, + { "OBJECT", 6, 0 }, + { "SCRIPT", 6, 0 }, + { "ADDRESS", 7, 0 }, + { "LISTING", 7, 0 }, + { "PLAINTEXT", 9, 0 }, + { "BLOCKQUOTE", 10, 0 }, +}; + +#define NR_blocktags 29 From 9f3beb652bde0fb74443a8312f03a701b7bc5175 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Mon, 23 Jan 2012 22:12:02 +0000 Subject: [PATCH 05/22] Add script build phase to build discount blocktags target. --- MarkdownLive.xcodeproj/project.pbxproj | 17 +++++++++++++ discount/blocktags | 33 -------------------------- 2 files changed, 17 insertions(+), 33 deletions(-) delete mode 100644 discount/blocktags diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index c8575e9..5081996 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -334,6 +334,7 @@ isa = PBXNativeTarget; buildConfigurationList = ABECD8C613C8B8CA00B77CFD /* Build configuration list for PBXNativeTarget "ORCDiscount" */; buildPhases = ( + AB5240A414CE111D0029A1EF /* ShellScript */, ABECD8BD13C8B8CA00B77CFD /* Headers */, ABECD8BE13C8B8CA00B77CFD /* Resources */, ABECD8BF13C8B8CA00B77CFD /* Sources */, @@ -399,6 +400,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + AB5240A414CE111D0029A1EF /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd ./discount\n./configure.sh\nmake blocktags"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 8D15AC300486D014006FF6A4 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/discount/blocktags b/discount/blocktags deleted file mode 100644 index e7bdf73..0000000 --- a/discount/blocktags +++ /dev/null @@ -1,33 +0,0 @@ -static struct kw blocktags[] = { - { "P", 1, 0 }, - { "DL", 2, 0 }, - { "H1", 2, 0 }, - { "H2", 2, 0 }, - { "H3", 2, 0 }, - { "H4", 2, 0 }, - { "H5", 2, 0 }, - { "H6", 2, 0 }, - { "HR", 2, 1 }, - { "OL", 2, 0 }, - { "UL", 2, 0 }, - { "BDO", 3, 0 }, - { "DFN", 3, 0 }, - { "DIV", 3, 0 }, - { "MAP", 3, 0 }, - { "PRE", 3, 0 }, - { "WBR", 3, 0 }, - { "XMP", 3, 0 }, - { "NOBR", 4, 0 }, - { "STYLE", 5, 0 }, - { "TABLE", 5, 0 }, - { "CENTER", 6, 0 }, - { "IFRAME", 6, 0 }, - { "OBJECT", 6, 0 }, - { "SCRIPT", 6, 0 }, - { "ADDRESS", 7, 0 }, - { "LISTING", 7, 0 }, - { "PLAINTEXT", 9, 0 }, - { "BLOCKQUOTE", 10, 0 }, -}; - -#define NR_blocktags 29 From ea9dd91c3470d5e1f9be794fb2bf889ffa4fbdc9 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Mon, 23 Jan 2012 22:26:31 +0000 Subject: [PATCH 06/22] Updated discount to fix compiler warning. v2.1.3 --- discount/mktags.c | 1 + 1 file changed, 1 insertion(+) diff --git a/discount/mktags.c b/discount/mktags.c index 0d4680a..c954dee 100644 --- a/discount/mktags.c +++ b/discount/mktags.c @@ -41,6 +41,7 @@ typedef int (*stfu)(const void*,const void*); /* load in the standard collection of html tags that markdown supports */ +int main() { int i; From b3583b882965ab0a773dfbb6aa595ef796aac43f Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Mon, 23 Jan 2012 22:37:55 +0000 Subject: [PATCH 07/22] Script build phase now updates discount blocktags. --- discount/blocktags | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 discount/blocktags diff --git a/discount/blocktags b/discount/blocktags new file mode 100644 index 0000000..e7bdf73 --- /dev/null +++ b/discount/blocktags @@ -0,0 +1,33 @@ +static struct kw blocktags[] = { + { "P", 1, 0 }, + { "DL", 2, 0 }, + { "H1", 2, 0 }, + { "H2", 2, 0 }, + { "H3", 2, 0 }, + { "H4", 2, 0 }, + { "H5", 2, 0 }, + { "H6", 2, 0 }, + { "HR", 2, 1 }, + { "OL", 2, 0 }, + { "UL", 2, 0 }, + { "BDO", 3, 0 }, + { "DFN", 3, 0 }, + { "DIV", 3, 0 }, + { "MAP", 3, 0 }, + { "PRE", 3, 0 }, + { "WBR", 3, 0 }, + { "XMP", 3, 0 }, + { "NOBR", 4, 0 }, + { "STYLE", 5, 0 }, + { "TABLE", 5, 0 }, + { "CENTER", 6, 0 }, + { "IFRAME", 6, 0 }, + { "OBJECT", 6, 0 }, + { "SCRIPT", 6, 0 }, + { "ADDRESS", 7, 0 }, + { "LISTING", 7, 0 }, + { "PLAINTEXT", 9, 0 }, + { "BLOCKQUOTE", 10, 0 }, +}; + +#define NR_blocktags 29 From d3922b34a7aea005207ae427b06498aff4dc9283 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Tue, 24 Jan 2012 20:34:30 +0000 Subject: [PATCH 08/22] Updated mkdio.h and config.h. Added README and update.sh to the project so that the fake sunmodule nature of the discount folder is clear. --- MarkdownLive.xcodeproj/project.pbxproj | 4 ++++ discount-config/config.h | 4 ---- discount-config/mkdio.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 5081996..e9291e1 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -112,6 +112,8 @@ 795F6DB9105D75D300D1F90A /* mkdioWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mkdioWrapper.h; sourceTree = ""; }; 8D15AC360486D014006FF6A4 /* MarkdownLive-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "MarkdownLive-Info.plist"; sourceTree = ""; }; 8D15AC370486D014006FF6A4 /* MarkdownLive.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarkdownLive.app; sourceTree = BUILT_PRODUCTS_DIR; }; + AB8AB90814CF4D2F00DBF8D5 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; + AB8AB90914CF4D2F00DBF8D5 /* update.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update.sh; sourceTree = ""; }; ABCE3DDF13C8DFFF00DF3CD0 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; ABECD8C213C8B8CA00B77CFD /* ORCDiscount.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ORCDiscount.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ABECD8C313C8B8CA00B77CFD /* ORCDiscount-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ORCDiscount-Info.plist"; sourceTree = ""; }; @@ -176,6 +178,8 @@ 22ECEEC512E7C258003B50DC /* discount-config */ = { isa = PBXGroup; children = ( + AB8AB90814CF4D2F00DBF8D5 /* README.markdown */, + AB8AB90914CF4D2F00DBF8D5 /* update.sh */, 226936B912E7C8B600171322 /* mkdio.h */, 22ECEEC612E7C258003B50DC /* config.h */, ); diff --git a/discount-config/config.h b/discount-config/config.h index 9d87b77..06ec203 100644 --- a/discount-config/config.h +++ b/discount-config/config.h @@ -1,7 +1,3 @@ -/* - * 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 diff --git a/discount-config/mkdio.h b/discount-config/mkdio.h index b151518..5fe2b9f 100644 --- a/discount-config/mkdio.h +++ b/discount-config/mkdio.h @@ -84,6 +84,7 @@ void mkd_ref_prefix(MMIOT*, char*); #define MKD_TAGTEXT 0x00000020 /* process text inside an html tag; no * , no , no html or [] expansion */ #define MKD_NO_EXT 0x00000040 /* don't allow pseudo-protocols */ +#define MKD_NOEXT MKD_NO_EXT /* ^^^ (aliased for user convenience) */ #define MKD_CDATA 0x00000080 /* generate code for xml ![CDATA[...]] */ #define MKD_NOSUPERSCRIPT 0x00000100 /* no A^B */ #define MKD_NORELAXED 0x00000200 /* emphasis happens /everywhere/ */ From 6969f150c949b8652e33aa1ac0d0edb898b73eed Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Tue, 24 Jan 2012 20:48:32 +0000 Subject: [PATCH 09/22] Modified update.sh to generate blocktags. Removed superfluous build script from project. Removed the pre-existant copy of block tags. --- MarkdownLive.xcodeproj/project.pbxproj | 17 ------------- discount-config/blocktags | 33 ++++++++++++++++++++++++++ discount-config/update.sh | 7 +++++- 3 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 discount-config/blocktags diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index e9291e1..94456ca 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -338,7 +338,6 @@ isa = PBXNativeTarget; buildConfigurationList = ABECD8C613C8B8CA00B77CFD /* Build configuration list for PBXNativeTarget "ORCDiscount" */; buildPhases = ( - AB5240A414CE111D0029A1EF /* ShellScript */, ABECD8BD13C8B8CA00B77CFD /* Headers */, ABECD8BE13C8B8CA00B77CFD /* Resources */, ABECD8BF13C8B8CA00B77CFD /* Sources */, @@ -404,22 +403,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - AB5240A414CE111D0029A1EF /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "cd ./discount\n./configure.sh\nmake blocktags"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 8D15AC300486D014006FF6A4 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/discount-config/blocktags b/discount-config/blocktags new file mode 100644 index 0000000..e7bdf73 --- /dev/null +++ b/discount-config/blocktags @@ -0,0 +1,33 @@ +static struct kw blocktags[] = { + { "P", 1, 0 }, + { "DL", 2, 0 }, + { "H1", 2, 0 }, + { "H2", 2, 0 }, + { "H3", 2, 0 }, + { "H4", 2, 0 }, + { "H5", 2, 0 }, + { "H6", 2, 0 }, + { "HR", 2, 1 }, + { "OL", 2, 0 }, + { "UL", 2, 0 }, + { "BDO", 3, 0 }, + { "DFN", 3, 0 }, + { "DIV", 3, 0 }, + { "MAP", 3, 0 }, + { "PRE", 3, 0 }, + { "WBR", 3, 0 }, + { "XMP", 3, 0 }, + { "NOBR", 4, 0 }, + { "STYLE", 5, 0 }, + { "TABLE", 5, 0 }, + { "CENTER", 6, 0 }, + { "IFRAME", 6, 0 }, + { "OBJECT", 6, 0 }, + { "SCRIPT", 6, 0 }, + { "ADDRESS", 7, 0 }, + { "LISTING", 7, 0 }, + { "PLAINTEXT", 9, 0 }, + { "BLOCKQUOTE", 10, 0 }, +}; + +#define NR_blocktags 29 diff --git a/discount-config/update.sh b/discount-config/update.sh index 745f3d3..2c5efc7 100755 --- a/discount-config/update.sh +++ b/discount-config/update.sh @@ -14,6 +14,9 @@ status_msg "Running configure.sh..." cd `dirname $0`/../discount/ ./configure.sh +# make the blocktags +make blocktags + status_msg "Copying important files..." if head -n 1 config.h | grep -q "^/\*$"; then @@ -25,9 +28,11 @@ else 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' +cp blocktags ../discount-config/blocktags && echo 'blocktags' status_msg "Clean files from working directory..." -git clean -f +# clean the working directory of generated files and folders +git clean -f -d status_msg "Done!" From 082cc3329d8cfd7eddb4a70be7fb4b240345b9d3 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Tue, 24 Jan 2012 20:54:44 +0000 Subject: [PATCH 10/22] Added generated blocktags to the project. --- MarkdownLive.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 94456ca..1857c29 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 8D15AC310486D014006FF6A4 /* MyDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; + AB8AB90E14CF513900DBF8D5 /* blocktags in Resources */ = {isa = PBXBuildFile; fileRef = AB8AB90D14CF513900DBF8D5 /* blocktags */; }; ABE8DDF913CA38B5005852B5 /* styles.css in Resources */ = {isa = PBXBuildFile; fileRef = 226936E612E7CDC500171322 /* styles.css */; }; ABECD8C713C8B90E00B77CFD /* mkdio.c in Sources */ = {isa = PBXBuildFile; fileRef = 795F6C4E105D6EC400D1F90A /* mkdio.c */; }; ABECD8C813C8B92900B77CFD /* markdown.c in Sources */ = {isa = PBXBuildFile; fileRef = 795F6C50105D6ECE00D1F90A /* markdown.c */; }; @@ -114,6 +115,7 @@ 8D15AC370486D014006FF6A4 /* MarkdownLive.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarkdownLive.app; sourceTree = BUILT_PRODUCTS_DIR; }; AB8AB90814CF4D2F00DBF8D5 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; AB8AB90914CF4D2F00DBF8D5 /* update.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update.sh; sourceTree = ""; }; + AB8AB90D14CF513900DBF8D5 /* blocktags */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = blocktags; sourceTree = ""; }; ABCE3DDF13C8DFFF00DF3CD0 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; ABECD8C213C8B8CA00B77CFD /* ORCDiscount.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ORCDiscount.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ABECD8C313C8B8CA00B77CFD /* ORCDiscount-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ORCDiscount-Info.plist"; sourceTree = ""; }; @@ -178,6 +180,7 @@ 22ECEEC512E7C258003B50DC /* discount-config */ = { isa = PBXGroup; children = ( + AB8AB90D14CF513900DBF8D5 /* blocktags */, AB8AB90814CF4D2F00DBF8D5 /* README.markdown */, AB8AB90914CF4D2F00DBF8D5 /* update.sh */, 226936B912E7C8B600171322 /* mkdio.h */, @@ -390,6 +393,7 @@ 1DDD582C0DA1D0D100B32029 /* MyDocument.xib in Resources */, 1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */, 795F6C87105D70A300D1F90A /* MarkdownLiveApp.icns in Resources */, + AB8AB90E14CF513900DBF8D5 /* blocktags in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From c109bb9df541160d3662a220091d21bafa36a118 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Tue, 24 Jan 2012 21:39:52 +0000 Subject: [PATCH 11/22] Removed extraneous blocktags --- discount/blocktags | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 discount/blocktags diff --git a/discount/blocktags b/discount/blocktags deleted file mode 100644 index e7bdf73..0000000 --- a/discount/blocktags +++ /dev/null @@ -1,33 +0,0 @@ -static struct kw blocktags[] = { - { "P", 1, 0 }, - { "DL", 2, 0 }, - { "H1", 2, 0 }, - { "H2", 2, 0 }, - { "H3", 2, 0 }, - { "H4", 2, 0 }, - { "H5", 2, 0 }, - { "H6", 2, 0 }, - { "HR", 2, 1 }, - { "OL", 2, 0 }, - { "UL", 2, 0 }, - { "BDO", 3, 0 }, - { "DFN", 3, 0 }, - { "DIV", 3, 0 }, - { "MAP", 3, 0 }, - { "PRE", 3, 0 }, - { "WBR", 3, 0 }, - { "XMP", 3, 0 }, - { "NOBR", 4, 0 }, - { "STYLE", 5, 0 }, - { "TABLE", 5, 0 }, - { "CENTER", 6, 0 }, - { "IFRAME", 6, 0 }, - { "OBJECT", 6, 0 }, - { "SCRIPT", 6, 0 }, - { "ADDRESS", 7, 0 }, - { "LISTING", 7, 0 }, - { "PLAINTEXT", 9, 0 }, - { "BLOCKQUOTE", 10, 0 }, -}; - -#define NR_blocktags 29 From b6d88e41e77c95844ae15a880a00743ea8c8443f Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 11:24:34 +0000 Subject: [PATCH 12/22] Added the discount-update script to automate updating of discount. Updated the discount-config README accordingly. --- MarkdownLive.xcodeproj/project.pbxproj | 24 ++++++++++++++---------- discount-config/README.markdown | 7 ++++++- discount-config/update-discount.sh | 17 +++++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100755 discount-config/update-discount.sh diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 1857c29..e70b2bb 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 8D15AC310486D014006FF6A4 /* MyDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; + AB40558C14D01D86009A583A /* update-discount.sh in Resources */ = {isa = PBXBuildFile; fileRef = AB40558B14D01D86009A583A /* update-discount.sh */; }; AB8AB90E14CF513900DBF8D5 /* blocktags in Resources */ = {isa = PBXBuildFile; fileRef = AB8AB90D14CF513900DBF8D5 /* blocktags */; }; ABE8DDF913CA38B5005852B5 /* styles.css in Resources */ = {isa = PBXBuildFile; fileRef = 226936E612E7CDC500171322 /* styles.css */; }; ABECD8C713C8B90E00B77CFD /* mkdio.c in Sources */ = {isa = PBXBuildFile; fileRef = 795F6C4E105D6EC400D1F90A /* mkdio.c */; }; @@ -113,6 +114,7 @@ 795F6DB9105D75D300D1F90A /* mkdioWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mkdioWrapper.h; sourceTree = ""; }; 8D15AC360486D014006FF6A4 /* MarkdownLive-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "MarkdownLive-Info.plist"; sourceTree = ""; }; 8D15AC370486D014006FF6A4 /* MarkdownLive.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarkdownLive.app; sourceTree = BUILT_PRODUCTS_DIR; }; + AB40558B14D01D86009A583A /* update-discount.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "update-discount.sh"; sourceTree = ""; }; AB8AB90814CF4D2F00DBF8D5 /* README.markdown */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; AB8AB90914CF4D2F00DBF8D5 /* update.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update.sh; sourceTree = ""; }; AB8AB90D14CF513900DBF8D5 /* blocktags */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = blocktags; sourceTree = ""; }; @@ -180,6 +182,7 @@ 22ECEEC512E7C258003B50DC /* discount-config */ = { isa = PBXGroup; children = ( + AB40558B14D01D86009A583A /* update-discount.sh */, AB8AB90D14CF513900DBF8D5 /* blocktags */, AB8AB90814CF4D2F00DBF8D5 /* README.markdown */, AB8AB90914CF4D2F00DBF8D5 /* update.sh */, @@ -261,18 +264,18 @@ 795F6C4D105D6EA500D1F90A /* discount */ = { isa = PBXGroup; children = ( - 795F6C4E105D6EC400D1F90A /* mkdio.c */, - 22ECEED912E7C2E8003B50DC /* markdown.h */, - 795F6C50105D6ECE00D1F90A /* markdown.c */, - 795F6C52105D6ED800D1F90A /* generate.c */, - 795F6C54105D6EE100D1F90A /* resource.c */, - 795F6C61105D6F6E00D1F90A /* xml.c */, 795F6C65105D6F8500D1F90A /* Csio.c */, 2269367E12E7C53000171322 /* emmatch.c */, + 795F6C52105D6ED800D1F90A /* generate.c */, 2269369A12E7C6AB00171322 /* html5.c */, - 2269369F12E7C6BE00171322 /* tags.h */, - 2269369E12E7C6BE00171322 /* tags.c */, + 795F6C50105D6ECE00D1F90A /* markdown.c */, + 22ECEED912E7C2E8003B50DC /* markdown.h */, + 795F6C4E105D6EC400D1F90A /* mkdio.c */, + 795F6C54105D6EE100D1F90A /* resource.c */, 226936C912E7CA2800171322 /* setup.c */, + 2269369E12E7C6BE00171322 /* tags.c */, + 2269369F12E7C6BE00171322 /* tags.h */, + 795F6C61105D6F6E00D1F90A /* xml.c */, ); path = discount; sourceTree = ""; @@ -394,6 +397,7 @@ 1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */, 795F6C87105D70A300D1F90A /* MarkdownLiveApp.icns in Resources */, AB8AB90E14CF513900DBF8D5 /* blocktags in Resources */, + AB40558C14D01D86009A583A /* update-discount.sh in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -492,7 +496,6 @@ ABECD8C413C8B8CA00B77CFD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -518,7 +521,6 @@ ABECD8C513C8B8CA00B77CFD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; @@ -593,6 +595,7 @@ GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "./discount-config"; MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -620,6 +623,7 @@ GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_PARAMETER = NO; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "./discount-config"; MACOSX_DEPLOYMENT_TARGET = 10.6; SDKROOT = macosx; SEPARATE_STRIP = YES; diff --git a/discount-config/README.markdown b/discount-config/README.markdown index d280612..2d14905 100644 --- a/discount-config/README.markdown +++ b/discount-config/README.markdown @@ -1,6 +1,6 @@ # [Discount][] instructions # -This folder holds the files generated by discount's `configure.sh` script that are used by MarkdownLive. +This folder holds the files generated by discount's `configure.sh` script that are used by MarkdownLive and QLMarkdown. ## Upgrading discount ## @@ -9,6 +9,11 @@ Discount is included as a [fake submodule][]. To upgrade or test other versions rm -rf discount/ git clone git://github.com/Orc/discount.git discount +<<<<<<< HEAD +======= +The discount folder will contain a .git folder following the clone however this folder is not included in the enclosing repository and will not be propagated by a push or clone. + +>>>>>>> 0f7eb8d... Updated discount-config README ## Config files ## When discount is changed, regenerate the config files. The included `update.sh` script should do this automatically. diff --git a/discount-config/update-discount.sh b/discount-config/update-discount.sh new file mode 100755 index 0000000..49ac2a5 --- /dev/null +++ b/discount-config/update-discount.sh @@ -0,0 +1,17 @@ +#!/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 "Removing discount folder..." +rm -rf ../discount/ + +status_msg "Cloning discount ..." +git clone git://github.com/Orc/discount.git ../discount + +./update.sh \ No newline at end of file From d2cd50458f54ab5968b31e8b3f24db623c3b23d3 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 11:29:22 +0000 Subject: [PATCH 13/22] Ran ./discount-config/update-discount.sh to update discount. --- MarkdownLive.xcodeproj/project.pbxproj | 2 ++ discount-config/config.h | 2 ++ discount/Makefile.in | 2 +- discount/configure.inc | 5 +++-- discount/configure.sh | 19 +++++++++++++++---- discount/cstring.h | 4 ++-- discount/emmatch.c | 2 +- discount/flags.c | 2 +- discount/generate.c | 6 +++--- discount/main.c | 4 ++-- discount/makepage.c | 1 - discount/markdown.c | 16 ++++++++-------- discount/mkd2html.c | 4 ++-- discount/mkdio.c | 4 ++-- discount/mktags.c | 1 - discount/theme.c | 4 ++-- discount/tools/cols.c | 3 +-- discount/tools/echo.c | 2 +- discount/xml.c | 4 ++-- discount/xmlpage.c | 2 +- 20 files changed, 51 insertions(+), 38 deletions(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index e70b2bb..acc5d1d 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -599,6 +599,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; + WARNING_CFLAGS = "-Wall"; }; name = Debug; }; @@ -628,6 +629,7 @@ SDKROOT = macosx; SEPARATE_STRIP = YES; STRIP_INSTALLED_PRODUCT = YES; + WARNING_CFLAGS = "-Wall"; }; name = Release; }; diff --git a/discount-config/config.h b/discount-config/config.h index 06ec203..d76e691 100644 --- a/discount-config/config.h +++ b/discount-config/config.h @@ -4,6 +4,8 @@ #define OS_DARWIN 1 #define USE_DISCOUNT_DL 1 +#define while(x) while( (x) != 0 ) +#define if(x) if( (x) != 0 ) #define DWORD unsigned int #define WORD unsigned short #define BYTE unsigned char diff --git a/discount/Makefile.in b/discount/Makefile.in index 78d2079..27ce349 100644 --- a/discount/Makefile.in +++ b/discount/Makefile.in @@ -1,4 +1,4 @@ -CC=@CC@ -Wall -I. +CC=@CC@ -I. LFLAGS=-L. CFLAGS=@CFLAGS@ AR=@AR@ diff --git a/discount/configure.inc b/discount/configure.inc index 458dd1e..daf7e17 100755 --- a/discount/configure.inc +++ b/discount/configure.inc @@ -387,9 +387,11 @@ EOF if [ $status -eq 0 ]; then if $AC_CC -x c /dev/null -dM -E 2>&1 | grep '__clang__' >/dev/null; then TLOG " yuck, you're using clang" + IS_CLANG=T IS_BROKEN_CC=T elif $AC_CC -v 2>&1 | grep 'gcc version' >/dev/null; then TLOG " oh ick, it looks like gcc" + IS_GCC=T IS_BROKEN_CC=T else TLOG " ok" @@ -425,8 +427,6 @@ EOF AC_FAIL " does not compile code properly" fi - AC_SUB 'CC' "$AC_CC" - __remove ngc$$ ngc$$.c ngc$$.o return $status @@ -940,6 +940,7 @@ AC_OUTPUT () { AC_SUB 'LIBS' "$AC_LIBS" AC_SUB 'CONFIGURE_FILES' "$__config_files" AC_SUB 'GENERATED_FILES' "$*" + AC_SUB 'CC' "$AC_CC" AC_SUB 'CFLAGS' "$AC_CFLAGS" AC_SUB 'LDFLAGS' "$AC_LDFLAGS" AC_SUB 'srcdir' "$AC_SRCDIR" diff --git a/discount/configure.sh b/discount/configure.sh index 43ef971..44c8986 100755 --- a/discount/configure.sh +++ b/discount/configure.sh @@ -62,10 +62,21 @@ AC_PROG_CC test "$TRY_SHARED" && AC_COMPILER_PIC && AC_CC_SHLIBS -case "$AC_CC $AC_CFLAGS" in -*-Wall*) AC_DEFINE 'while(x)' 'while( (x) != 0 )' - AC_DEFINE 'if(x)' 'if( (x) != 0 )' ;; -esac +if [ "IS_BROKEN_CC" ]; then + case "$AC_CC $AC_CFLAGS" in + *-pedantic*) ;; + *) # hack around deficiencies in gcc and clang + # + AC_DEFINE 'while(x)' 'while( (x) != 0 )' + AC_DEFINE 'if(x)' 'if( (x) != 0 )' + + if [ "$IS_CLANG" ]; then + AC_CC="$AC_CC -Wno-implicit-int" + elif [ "$IS_GCC" ]; then + AC_CC="$AC_CC -Wno-return-type -Wno-implicit-int" + fi ;; + esac +fi AC_PROG ar || AC_FAIL "$TARGET requires ar" AC_PROG ranlib diff --git a/discount/cstring.h b/discount/cstring.h index 96ad841..a03ba2c 100644 --- a/discount/cstring.h +++ b/discount/cstring.h @@ -27,9 +27,9 @@ #define DELETE(x) ALLOCATED(x) ? (free(T(x)), S(x) = (x).alloc = 0) \ : ( S(x) = 0 ) #define CLIP(t,i,sz) \ - ( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \ + S(t) -= ( ((i) >= 0) && ((sz) > 0) && (((i)+(sz)) <= S(t)) ) ? \ (memmove(&T(t)[i], &T(t)[i+sz], (S(t)-(i+sz)+1)*sizeof(T(t)[0])), \ - S(t) -= (sz)) : -1 + (sz)) : 0 #define RESERVE(x, sz) T(x) = ((x).alloc > S(x) + (sz) \ ? T(x) \ diff --git a/discount/emmatch.c b/discount/emmatch.c index 9fb1ad9..8d362c5 100644 --- a/discount/emmatch.c +++ b/discount/emmatch.c @@ -110,7 +110,7 @@ emmatch(MMIOT *f, int first, int last) int e, e2, match; switch (start->b_count) { - case 2: if ( (e = empair(f,first,last,match=2)) ) + case 2: if ( e = empair(f,first,last,match=2) ) break; case 1: e = empair(f,first,last,match=1); break; diff --git a/discount/flags.c b/discount/flags.c index 5a2934b..5bf206c 100644 --- a/discount/flags.c +++ b/discount/flags.c @@ -45,7 +45,7 @@ mkd_flags_are(FILE *f, DWORD flags, int htmlplease) for (i=0; i < NR(flagnames); i++) { set = flags & flagnames[i].flag; name = flagnames[i].name; - if ( (not = (*name == '!')) ) { + if ( not = (*name == '!') ) { ++name; set = !set; } diff --git a/discount/generate.c b/discount/generate.c index 743b4d4..8e82afd 100644 --- a/discount/generate.c +++ b/discount/generate.c @@ -632,7 +632,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref) if ( image || (ref == 0) ) tag = &imaget; - else if ( (tag = pseudo(ref->link)) ) { + else if ( tag = pseudo(ref->link) ) { if ( f->flags & (MKD_NO_EXT|MKD_SAFELINK) ) return 0; } @@ -726,8 +726,8 @@ linkylinky(int image, MMIOT *f) S(key.tag) = S(name); } - if ( (ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes), - sizeof key, (stfu)__mkd_footsort)) ) { + if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes), + sizeof key, (stfu)__mkd_footsort) ) { if ( extra_footnote ) status = extra_linky(f,name,ref); else diff --git a/discount/main.c b/discount/main.c index 3dccbef..adc19ac 100644 --- a/discount/main.c +++ b/discount/main.c @@ -59,7 +59,7 @@ complain(char *fmt, ...) fflush(stderr); } -int + main(int argc, char **argv) { int opt; @@ -78,7 +78,7 @@ main(int argc, char **argv) char *q; MMIOT *doc; - if ( (q = getenv("MARKDOWN_FLAGS")) ) + if ( q = getenv("MARKDOWN_FLAGS") ) flags = strtol(q, 0, 0); pgm = basename(argv[0]); diff --git a/discount/makepage.c b/discount/makepage.c index be058e9..51ea45e 100644 --- a/discount/makepage.c +++ b/discount/makepage.c @@ -22,7 +22,6 @@ basename(char *p) char *pgm = "makepage"; -int main(argc, argv) int argc; char **argv; diff --git a/discount/markdown.c b/discount/markdown.c index d7703ad..7f3cbe9 100644 --- a/discount/markdown.c +++ b/discount/markdown.c @@ -239,7 +239,7 @@ commentblock(Paragraph *p, int *unclosed) char *end; for ( t = p->text; t ; t = t->next) { - if ( (end = strstr(T(t->text), "-->")) ) { + if ( end = strstr(T(t->text), "-->") ) { splitline(t, 3 + (end - T(t->text)) ); ret = t->next; t->next = 0; @@ -287,7 +287,7 @@ htmlblock(Paragraph *p, struct kw *tag, int *unclosed) } } else { - if ( (closing = (c == '/')) ) c = flogetc(&f); + if ( closing = (c == '/') ) c = flogetc(&f); for ( i=0; i < tag->size; c=flogetc(&f) ) { if ( tag->id[i++] != toupper(c) ) @@ -475,7 +475,7 @@ isdefinition(Line *t, int *clip, int *kind) Line *ret; *kind = 1; - if ( (ret = is_discount_dt(t,clip)) ) + if ( ret = is_discount_dt(t,clip) ) return ret; *kind=2; @@ -790,7 +790,7 @@ quoteblock(Paragraph *p, DWORD flags) /* and this would be an "%id:" prefix */ prefix="id"; - if ( (p->ident = malloc(4+strlen(prefix)+S(q->text))) ) + if ( p->ident = malloc(4+strlen(prefix)+S(q->text)) ) sprintf(p->ident, "%s=\"%.*s\"", prefix, S(q->text)-(i+2), T(q->text)+(i+1) ); @@ -872,7 +872,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind) if ( (text = skipempty(q->next)) == 0 ) break; - if (( para = (text != q->next) )) + if ( para = (text != q->next) ) ___mkd_freeLineRange(q, text); q->next = 0; @@ -895,7 +895,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind) if ( (q = skipempty(text)) == 0 ) break; - if (( para = (q != text) )) { + if ( para = (q != text) ) { Line anchor; anchor.next = text; @@ -935,7 +935,7 @@ enumerated_block(Paragraph *top, int clip, MMIOT *f, int list_class) || islist(q, &clip, f->flags, &z) != list_class ) break; - if ( (para = (q != text)) ) { + if ( para = (q != text) ) { Line anchor; anchor.next = text; @@ -1221,7 +1221,7 @@ compile(Line *ptr, int toplevel, MMIOT *f) ptr = ptr->next; ___mkd_freeLine(r); } - else if (( list_class = islist(ptr, &indent, f->flags, &list_type) )) { + else if ( list_class = islist(ptr, &indent, f->flags, &list_type) ) { if ( list_class == DL ) { p = Pp(&d, ptr, DL); ptr = definition_block(p, indent, f, list_type); diff --git a/discount/mkd2html.c b/discount/mkd2html.c index 1d10e6d..0315565 100644 --- a/discount/mkd2html.c +++ b/discount/mkd2html.c @@ -45,7 +45,7 @@ basename(char *path) { char *p; - if (( p = strrchr(path, '/') )) + if ( p = strrchr(path, '/') ) return 1+p; return path; } @@ -64,7 +64,7 @@ fail(char *why, ...) exit(1); } -int + main(argc, argv) char **argv; { diff --git a/discount/mkdio.c b/discount/mkdio.c index 291dbce..ab4b7ee 100644 --- a/discount/mkdio.c +++ b/discount/mkdio.c @@ -24,7 +24,7 @@ new_Document() Document *ret = calloc(sizeof(Document), 1); if ( ret ) { - if (( ret->ctx = calloc(sizeof(MMIOT), 1) )) { + if ( ret->ctx = calloc(sizeof(MMIOT), 1) ) { ret->magic = VALID_DOCUMENT; return ret; } @@ -269,7 +269,7 @@ mkd_line(char *bfr, int size, char **res, DWORD flags) mkd_parse_line(bfr, size, &f, flags); - if ( (len = S(f.out)) ) { + if ( len = S(f.out) ) { /* kludge alert; we know that T(f.out) is malloced memory, * so we can just steal it away. This is awful -- there * should be an opaque method that transparently moves diff --git a/discount/mktags.c b/discount/mktags.c index c954dee..0d4680a 100644 --- a/discount/mktags.c +++ b/discount/mktags.c @@ -41,7 +41,6 @@ typedef int (*stfu)(const void*,const void*); /* load in the standard collection of html tags that markdown supports */ -int main() { int i; diff --git a/discount/theme.c b/discount/theme.c index 52bded7..d58a791 100644 --- a/discount/theme.c +++ b/discount/theme.c @@ -56,7 +56,7 @@ basename(char *path) { char *p; - if (( p = strrchr(path, '/') )) + if ( p = strrchr(path, '/') ) return 1+p; return path; } @@ -498,7 +498,7 @@ spin(FILE *template, MMIOT *doc, FILE *output) } } /* spin */ -int + main(argc, argv) char **argv; { diff --git a/discount/tools/cols.c b/discount/tools/cols.c index 73cdd5e..68ecc59 100644 --- a/discount/tools/cols.c +++ b/discount/tools/cols.c @@ -1,11 +1,10 @@ #include #include -int main(argc, argv) char **argv; { - int register c; + register c; int xp; int width; diff --git a/discount/tools/echo.c b/discount/tools/echo.c index b434726..c7aa8ff 100644 --- a/discount/tools/echo.c +++ b/discount/tools/echo.c @@ -2,7 +2,7 @@ #include #include -int + main(argc, argv) char **argv; { diff --git a/discount/xml.c b/discount/xml.c index 65fa075..5e58389 100644 --- a/discount/xml.c +++ b/discount/xml.c @@ -46,7 +46,7 @@ mkd_generatexml(char *p, int size, FILE *out) while ( size-- > 0 ) { c = *p++; - if ( (entity = mkd_xmlchar(c)) ) + if ( entity = mkd_xmlchar(c) ) fputs(entity, out); else fputc(c, out); @@ -69,7 +69,7 @@ mkd_xml(char *p, int size, char **res) while ( size-- > 0 ) { c = *p++; - if ( (entity = mkd_xmlchar(c)) ) + if ( entity = mkd_xmlchar(c) ) Cswrite(&f, entity, strlen(entity)); else Csputc(c, &f); diff --git a/discount/xmlpage.c b/discount/xmlpage.c index e2925b5..96ed2b7 100644 --- a/discount/xmlpage.c +++ b/discount/xmlpage.c @@ -30,7 +30,7 @@ mkd_xhtmlpage(Document *p, int flags, FILE *out) fprintf(out, "\n"); fprintf(out, "\n"); - if ( (title = mkd_doc_title(p)) ) + if ( title = mkd_doc_title(p) ) fprintf(out, "%s\n", title); mkd_generatecss(p, out); fprintf(out, "\n"); From 5383b106d52835c38c52d2afccb3835a4aa8f3fb Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 11:35:27 +0000 Subject: [PATCH 14/22] Updated README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1508b9f..dffb5d9 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,9 @@ A Cocoa markdown preview editor using [Discount][discount]. Implements the ORCDiscount framework. +<<<<<<< HEAD +======= +To update to the latest version of discount run `./discount-config/update-discount.sh` +>>>>>>> 7a7787f... Updated README [discount]: https://github.com/Orc/discount \ No newline at end of file From 650678bd649e6014ec75edebdf48b7698b83ed94 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 15:25:24 +0000 Subject: [PATCH 15/22] Updated README --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index dffb5d9..e744a4f 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,6 @@ A Cocoa markdown preview editor using [Discount][discount]. Implements the ORCDiscount framework. -<<<<<<< HEAD -======= To update to the latest version of discount run `./discount-config/update-discount.sh` ->>>>>>> 7a7787f... Updated README [discount]: https://github.com/Orc/discount \ No newline at end of file From 19fb9a37cf3e1e5c90e36276fa4a7fddd3328ca0 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 15:47:37 +0000 Subject: [PATCH 16/22] Updated config README --- discount-config/README.markdown | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/discount-config/README.markdown b/discount-config/README.markdown index 2d14905..affaadd 100644 --- a/discount-config/README.markdown +++ b/discount-config/README.markdown @@ -4,16 +4,21 @@ This folder holds the files generated by discount's `configure.sh` script that a ## Upgrading discount ## +To upgrade discount run `./discount-config/update-discount.sh` +This script automates the steps oulined below: + +1. Upgrade the discount repo +2. Generate dynamic configuration infotmation + +## Manually 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 -<<<<<<< HEAD -======= The discount folder will contain a .git folder following the clone however this folder is not included in the enclosing repository and will not be propagated by a push or clone. ->>>>>>> 0f7eb8d... Updated discount-config README ## Config files ## When discount is changed, regenerate the config files. The included `update.sh` script should do this automatically. From 9f64c033b1958365f5bf4bf19c054f23859063b0 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Wed, 25 Jan 2012 15:52:06 +0000 Subject: [PATCH 17/22] Updated config READNE --- discount-config/README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discount-config/README.markdown b/discount-config/README.markdown index affaadd..d225f0f 100644 --- a/discount-config/README.markdown +++ b/discount-config/README.markdown @@ -1,6 +1,6 @@ # [Discount][] instructions # -This folder holds the files generated by discount's `configure.sh` script that are used by MarkdownLive and QLMarkdown. +This folder holds the files generated by discount's `configure.sh` script that are used by MarkdownLive. ## Upgrading discount ## From 79b6e1ff06de82f456ca548c26dc6971669063d6 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Thu, 26 Jan 2012 21:56:06 +0000 Subject: [PATCH 18/22] Updated .gitignore and cleaned up project folder. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5883e90..a4c9527 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ build/* !default.perspectivev3 *.xcworkspace !default.xcworkspace -xcuserdata +xcuserdata/ profile *.moved-aside From 3db8c6d7f0c8bb3f0ba5ddde0737bb50ef0728eb Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Fri, 23 Nov 2012 21:56:01 +0000 Subject: [PATCH 19/22] Modernised project. Cleaned up 32/64 bit build settings. --- MarkdownLive.xcodeproj/project.pbxproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index acc5d1d..0640aac 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -364,7 +364,7 @@ 2A37F4A9FDCFA73011CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0450; }; buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "MarkdownLive" */; compatibilityVersion = "Xcode 3.2"; @@ -496,6 +496,7 @@ ABECD8C413C8B8CA00B77CFD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -521,6 +522,7 @@ ABECD8C513C8B8CA00B77CFD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; @@ -547,6 +549,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)\"/**"; GCC_DYNAMIC_NO_PIC = NO; @@ -564,6 +567,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)\"/**"; GCC_MODEL_TUNING = G5; From 781cd69c36b347bb4c89381bd30a81bcb07ffa2e Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Sat, 24 Nov 2012 21:29:00 +0000 Subject: [PATCH 20/22] Set Build Active Arch Only to no for ORCDiscount framework so that 32 bit debug builds do not get broken when importing project as a sub-project or into a workspace. --- MarkdownLive.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 0640aac..5276bae 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -508,6 +508,7 @@ GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = "ORCDiscount-Info.plist"; INSTALL_PATH = "@executable_path/../Frameworks"; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-framework", Foundation, @@ -533,6 +534,7 @@ GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = "ORCDiscount-Info.plist"; INSTALL_PATH = "@executable_path/../Frameworks"; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( "-framework", Foundation, From a60466a2412ad2597fd71c73b0a0f8c783d67acf Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Tue, 8 Aug 2017 09:54:58 +0100 Subject: [PATCH 21/22] Modernise project --- MarkdownLive.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index 5276bae..c93858c 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -584,10 +584,9 @@ C05733CC08A9546B00998B17 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_GC = supported; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -605,6 +604,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; + VALID_ARCHS = x86_64; WARNING_CFLAGS = "-Wall"; }; name = Debug; @@ -612,12 +612,11 @@ C05733CD08A9546B00998B17 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_GC = supported; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; @@ -635,6 +634,7 @@ SDKROOT = macosx; SEPARATE_STRIP = YES; STRIP_INSTALLED_PRODUCT = YES; + VALID_ARCHS = x86_64; WARNING_CFLAGS = "-Wall"; }; name = Release; From 42eefd7803504156955892a9805bf4f9923645d8 Mon Sep 17 00:00:00 2001 From: Jonathan Mitchell Date: Sat, 12 Aug 2017 23:49:36 +0100 Subject: [PATCH 22/22] Modernise project --- MarkdownLive.xcodeproj/project.pbxproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MarkdownLive.xcodeproj/project.pbxproj b/MarkdownLive.xcodeproj/project.pbxproj index c93858c..d06b0e6 100644 --- a/MarkdownLive.xcodeproj/project.pbxproj +++ b/MarkdownLive.xcodeproj/project.pbxproj @@ -364,7 +364,7 @@ 2A37F4A9FDCFA73011CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0450; + LastUpgradeCheck = 0500; }; buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "MarkdownLive" */; compatibilityVersion = "Xcode 3.2"; @@ -584,7 +584,6 @@ C05733CC08A9546B00998B17 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_OPTIMIZATION_LEVEL = 0; @@ -612,7 +611,6 @@ C05733CD08A9546B00998B17 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES;