Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit 2c46fcb478295212be8716afad3c0be0b5f7ff97 @sekimura committed
Showing with 7,174 additions and 0 deletions.
  1. +6 −0 Changes
  2. +8 −0 MANIFEST
  3. +17 −0 Makefile.PL
  4. +40 −0 README
  5. +39 −0 XS.xs
  6. +29 −0 amalloc.h
  7. +28 −0 config.h
  8. +68 −0 cstring.h
  9. +86 −0 lib/Text/Markdown/XS.pm
  10. +131 −0 markdown.h
  11. +65 −0 mkdio.h
  12. +6,376 −0 ppport.h
  13. +15 −0 t/Text-Markdown-XS.t
  14. +233 −0 xt/index.text
  15. +33 −0 xt/test.pl
6 Changes
@@ -0,0 +1,6 @@
+Revision history for Perl extension Text::Markdown::XS.
+
+0.01 Thu Feb 12 22:49:17 2009
+ - original version; created by h2xs 1.23 with options
+ -A -n Text::Markdown::XS
+
8 MANIFEST
@@ -0,0 +1,8 @@
+Changes
+Makefile.PL
+MANIFEST
+ppport.h
+README
+XS.xs
+t/Text-Markdown-XS.t
+lib/Text/Markdown/XS.pm
17 Makefile.PL
@@ -0,0 +1,17 @@
+use 5.010000;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ NAME => 'Text::Markdown::XS',
+ VERSION_FROM => 'lib/Text/Markdown/XS.pm', # finds $VERSION
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => 'lib/Text/Markdown/XS.pm', # retrieve abstract from module
+ AUTHOR => 'Masayoshi Sekimura <sekimura@>') : ()),
+ LIBS => ['-lmarkdown'], # e.g., '-lm'
+ DEFINE => '', # e.g., '-DHAVE_SOMETHING'
+ INC => '-I.', # e.g., '-I. -I/usr/include/other'
+ # Un-comment this if you add C files to link with later:
+ # OBJECT => '$(O_FILES)', # link all the C files too
+);
40 README
@@ -0,0 +1,40 @@
+Text-Markdown-XS version 0.01
+=============================
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the
+README file from a module distribution so that people browsing the
+archive can use it get an idea of the modules uses. It is usually a
+good idea to provide version information here so that people can
+decide whether fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+ blah blah blah
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2009 by Masayoshi Sekimura
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.0 or,
+at your option, any later version of Perl 5 you may have available.
+
+
39 XS.xs
@@ -0,0 +1,39 @@
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include "ppport.h"
+
+#include "cstring.h"
+#include "markdown.h"
+
+typedef struct {
+ char sym;
+ char * xml_sym;
+} e_char;
+
+
+
+MODULE = Text::Markdown::XS PACKAGE = Text::Markdown::XS
+
+SV *
+_markdown(text)
+ char *text;
+ PREINIT:
+ SV* r = &PL_sv_undef;
+ CODE:
+ int rc;
+ int flags = 0x0004;
+ char *ret;
+ int szret;
+ Document *doc;
+ if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
+ exit(1);
+ }
+ mkd_compile(doc, flags);
+ szret = mkd_document(doc, &ret);
+
+ r = newSVpv(ret, 0);
+ RETVAL = r;
+ OUTPUT:
+ RETVAL
29 amalloc.h
@@ -0,0 +1,29 @@
+/*
+ * debugging malloc()/realloc()/calloc()/free() that attempts
+ * to keep track of just what's been allocated today.
+ */
+#ifndef AMALLOC_D
+#define AMALLOC_D
+
+#include "config.h"
+
+#ifdef USE_AMALLOC
+
+extern void *amalloc(int);
+extern void *acalloc(int,int);
+extern void *arealloc(void*,int);
+extern void afree(void*);
+extern void adump();
+
+#define malloc amalloc
+#define calloc acalloc
+#define realloc arealloc
+#define free afree
+
+#else
+
+#define adump() (void)1
+
+#endif
+
+#endif/*AMALLOC_D*/
28 config.h
@@ -0,0 +1,28 @@
+/*
+ * configuration for markdown, generated Thu Feb 12 22:57:30 PST 2009
+ * by sekimura@liz
+ */
+#ifndef __AC_MARKDOWN_D
+#define __AC_MARKDOWN_D 1
+
+
+#define OS_LINUX 1
+#define DWORD unsigned long
+#define WORD unsigned short
+#define BYTE unsigned char
+#define HAVE_BASENAME 1
+#define HAVE_LIBGEN_H 1
+#define HAVE_PWD_H 1
+#define HAVE_GETPWUID 1
+#define HAVE_SRANDOM 1
+#define INITRNG(x) srandom((unsigned int)x)
+#define HAVE_RANDOM 1
+#define COINTOSS() (random()&1)
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_FCHDIR 1
+#define TABSTOP 4
+#define HAVE_MALLOC_H 1
+#define PATH_SED "/bin/sed"
+
+#endif/* __AC_MARKDOWN_D */
68 cstring.h
@@ -0,0 +1,68 @@
+/* two template types: STRING(t) which defines a pascal-style string
+ * of element (t) [STRING(char) is the closest to the pascal string],
+ * and ANCHOR(t) which defines a baseplate that a linked list can be
+ * built up from. [The linked list /must/ contain a ->next pointer
+ * for linking the list together with.]
+ */
+#ifndef _CSTRING_D
+#define _CSTRING_D
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "amalloc.h"
+
+/* expandable Pascal-style string.
+ */
+#define STRING(type) struct { type *text; int size, alloc; }
+
+#define CREATE(x) T(x) = (void*)(S(x) = (x).alloc = 0)
+#define EXPAND(x) (S(x)++)[(S(x) < (x).alloc) \
+ ? (T(x)) \
+ : (T(x) = T(x) ? realloc(T(x), sizeof T(x)[0] * ((x).alloc += 100)) \
+ : malloc(sizeof T(x)[0] * ((x).alloc += 100)) )]
+
+#define DELETE(x) (x).alloc ? (free(T(x)), S(x) = (x).alloc = 0) \
+ : ( S(x) = 0 )
+#define CLIP(t,i,sz) \
+ ( ((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
+
+#define RESERVE(x, sz) T(x) = ((x).alloc > S(x) + (sz) \
+ ? T(x) \
+ : T(x) \
+ ? realloc(T(x), sizeof T(x)[0] * ((x).alloc = 100+(sz)+S(x))) \
+ : malloc(sizeof T(x)[0] * ((x).alloc = 100+(sz)+S(x))))
+#define SUFFIX(t,p,sz) \
+ memcpy(((S(t) += (sz)) - (sz)) + \
+ (T(t) = T(t) ? realloc(T(t), sizeof T(t)[0] * ((t).alloc += sz)) \
+ : malloc(sizeof T(t)[0] * ((t).alloc += sz))), \
+ (p), sizeof(T(t)[0])*(sz))
+
+#define PREFIX(t,p,sz) \
+ RESERVE( (t), (sz) ); \
+ if ( S(t) ) { memmove(T(t)+(sz), T(t), S(t)); } \
+ memcpy( T(t), (p), (sz) ); \
+ S(t) += (sz)
+
+/* reference-style links (and images) are stored in an array
+ */
+#define T(x) (x).text
+#define S(x) (x).size
+
+/* abstract anchor type that defines a list base
+ * with a function that attaches an element to
+ * the end of the list.
+ *
+ * the list base field is named .text so that the T()
+ * macro will work with it.
+ */
+#define ANCHOR(t) struct { t *text, *end; }
+
+#define ATTACH(t, p) ( (t).text ?( ((t).end->next = (p)), ((t).end = (p)) ) \
+ :( ((t).text = (t).end = (p)) ) )
+
+typedef STRING(char) Cstring;
+
+#endif/*_CSTRING_D*/
86 lib/Text/Markdown/XS.pm
@@ -0,0 +1,86 @@
+package Text::Markdown::XS;
+
+use 5.010000;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+# Items to export into callers namespace by default. Note: do not export
+# names by default without a very good reason. Use EXPORT_OK instead.
+# Do not simply export all your public functions/methods/constants.
+
+# This allows declaration use Text::Markdown::XS ':all';
+# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
+# will save memory.
+our %EXPORT_TAGS = ( 'all' => [ qw(
+
+) ] );
+
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+
+our @EXPORT = qw(
+
+);
+
+our $VERSION = '0.01';
+
+require XSLoader;
+XSLoader::load('Text::Markdown::XS', $VERSION);
+
+# Preloaded methods go here.
+
+1;
+__END__
+# Below is stub documentation for your module. You'd better edit it!
+
+=head1 NAME
+
+Text::Markdown::XS - Perl extension for blah blah blah
+
+=head1 SYNOPSIS
+
+ use Text::Markdown::XS;
+ blah blah blah
+
+=head1 DESCRIPTION
+
+Stub documentation for Text::Markdown::XS, created by h2xs. It looks like the
+author of the extension was negligent enough to leave the stub
+unedited.
+
+Blah blah blah.
+
+=head2 EXPORT
+
+None by default.
+
+
+
+=head1 SEE ALSO
+
+Mention other useful documentation such as the documentation of
+related modules or operating system documentation (such as man pages
+in UNIX), or any relevant external documentation such as RFCs or
+standards.
+
+If you have a mailing list set up for your module, mention it here.
+
+If you have a web site set up for your module, mention it here.
+
+=head1 AUTHOR
+
+Masayoshi Sekimura, E<lt>sekimura@E<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2009 by Masayoshi Sekimura
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.10.0 or,
+at your option, any later version of Perl 5 you may have available.
+
+
+=cut
131 markdown.h
@@ -0,0 +1,131 @@
+#ifndef _MARKDOWN_D
+#define _MARKDOWN_D
+
+#include "cstring.h"
+
+/* reference-style links (and images) are stored in an array
+ * of footnotes.
+ */
+typedef struct footnote {
+ Cstring tag; /* the tag for the reference link */
+ Cstring link; /* what this footnote points to */
+ Cstring title; /* what it's called (TITLE= attribute) */
+ int height, width; /* dimensions (for image link) */
+} Footnote;
+
+/* each input line is read into a Line, which contains the line,
+ * the offset of the first non-space character [this assumes
+ * that all tabs will be expanded to spaces!], and a pointer to
+ * the next line.
+ */
+typedef struct line {
+ Cstring text;
+ struct line *next;
+ int dle;
+} Line;
+
+
+/* a paragraph is a collection of Lines, with links to the next paragraph
+ * and (if it's a QUOTE, UL, or OL) to the reparsed contents of this
+ * paragraph.
+ */
+typedef struct paragraph {
+ struct paragraph *next; /* next paragraph */
+ struct paragraph *down; /* recompiled contents of this paragraph */
+ struct line *text; /* all the text in this paragraph */
+ char *ident; /* %id% tag for QUOTE */
+ enum { WHITESPACE=0, CODE, QUOTE, MARKUP,
+ HTML, STYLE, DL, UL, OL, AL, LISTITEM,
+ HDR, HR } typ;
+ enum { IMPLICIT=0, PARA, CENTER} align;
+ int hnumber; /* <Hn> for typ == HDR */
+} Paragraph;
+
+enum { ETX, SETEXT }; /* header types */
+
+
+typedef struct ablock {
+ enum { bTEXT, bSTAR, bUNDER } b_type;
+ int b_count;
+ char b_char;
+ Cstring b_text;
+ Cstring b_post;
+} ablock;
+
+typedef STRING(ablock) Qblock;
+
+
+/* a magic markdown io thing holds all the data structures needed to
+ * do the backend processing of a markdown document
+ */
+typedef struct mmiot {
+ Cstring out;
+ Cstring in;
+ Qblock Q;
+ int isp;
+ STRING(Footnote) *footnotes;
+ int flags;
+#define DENY_A 0x0001
+#define DENY_IMG 0x0002
+#define DENY_SMARTY 0x0004
+#define DENY_HTML 0x0008
+#define STRICT 0x0010
+#define INSIDE_TAG 0x0020
+#define NO_PSEUDO_PROTO 0x0040
+#define CDATA_OUTPUT 0x0080
+#define TOC 0x1000
+#define USER_FLAGS 0xF0FF
+#define EMBEDDED DENY_A|DENY_IMG|NO_PSEUDO_PROTO|CDATA_OUTPUT
+ char *base;
+} MMIOT;
+
+
+/*
+ * the mkdio text input functions return a document structure,
+ * which contains a header (retrieved from the document if
+ * markdown was configured * with the * --enable-pandoc-header
+ * and the document begins with a pandoc-style header) and the
+ * root of the linked list of Lines.
+ */
+typedef struct document {
+ Line *headers; /* title -> author(s) -> date */
+ ANCHOR(Line) content; /* uncompiled text, not valid after compile() */
+ Paragraph *code; /* intermediate code generated by compile() */
+ int compiled; /* set after mkd_compile() */
+ int html; /* set after (internal) htmlify() */
+ int tabstop; /* for properly expanding tabs (ick) */
+ MMIOT *ctx; /* backend buffers, flags, and structures */
+ char *base; /* url basename for url fragments */
+} Document;
+
+
+extern int mkd_firstnonblank(Line *);
+extern int mkd_compile(Document *, int);
+extern int mkd_document(Document *, char **);
+extern int mkd_generatehtml(Document *, FILE *);
+extern int mkd_style(Document *, FILE *);
+extern void mkd_cleanup(Document *);
+extern int mkd_text(char *, int, FILE*, int);
+extern void mkd_basename(Document*, char *);
+extern void mkd_string_to_anchor(char*,int, void(*)(int,void*), void*);
+
+extern Document *mkd_in(FILE *, int);
+extern Document *mkd_string(char*,int, int);
+
+#define NO_HEADER 0x0100
+#define STD_TABSTOP 0x0200
+#define INPUT_MASK (NO_HEADER|STD_TABSTOP)
+
+
+/* internal resource handling functions.
+ */
+extern void ___mkd_freeLine(Line *);
+extern void ___mkd_freeLines(Line *);
+extern void ___mkd_freeParagraph(Paragraph *);
+extern void ___mkd_freefootnotes(MMIOT *);
+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 *);
+
+#endif/*_MARKDOWN_D*/
65 mkdio.h
@@ -0,0 +1,65 @@
+#ifndef _MKDIO_D
+#define _MKDIO_D
+
+#include <stdio.h>
+
+typedef void MMIOT;
+
+/* line builder for markdown()
+ */
+MMIOT *mkd_in(FILE*,int); /* assemble input from a file */
+MMIOT *mkd_string(char*,int,int); /* assemble input from a buffer */
+
+void mkd_basename(MMIOT*,char*);
+
+/* compilation, debugging, cleanup
+ */
+int mkd_compile(MMIOT*, int);
+int mkd_generatehtml(MMIOT*,FILE*);
+int mkd_generatetoc(MMIOT*,FILE*);
+int mkd_xhtmlpage(MMIOT*,int,FILE*);
+int mkd_cleanup(MMIOT*);
+
+/* markup functions
+ */
+int mkd_text(char *, int, FILE*, int);
+int mkd_style(MMIOT*, FILE*);
+int mkd_dump(MMIOT*, FILE*, int, char*);
+int markdown(MMIOT*, FILE*, int);
+void mkd_basename(MMIOT*,char*);
+void mkd_string_to_anchor(char *, int, int (*)(int,void*), void*);
+
+/* header block access
+ */
+char* mkd_doc_title(MMIOT*);
+char* mkd_doc_author(MMIOT*);
+char* mkd_doc_date(MMIOT*);
+
+/* compiled data access
+ */
+int mkd_document(MMIOT*, char**);
+
+/* version#.
+ */
+extern char markdown_version[];
+
+/* special flags for markdown() and mkd_text()
+ */
+#define MKD_NOLINKS 0x0001 /* don't do link processing, block <a> tags */
+#define MKD_NOIMAGE 0x0002 /* don't do image processing, block <img> */
+#define MKD_NOPANTS 0x0004 /* don't run smartypants() */
+#define MKD_NOHTML 0x0008 /* don't allow raw html through AT ALL */
+#define MKD_STRICT 0x0010 /* disable SUPERSCRIPT, RELAXED_EMPHASIS */
+#define MKD_TAGTEXT 0x0020 /* don't expand `_` and `*` */
+#define MKD_NO_EXT 0x0040 /* don't allow pseudo-protocols */
+#define MKD_CDATA 0x0080 /* generate code for xml ![CDATA[...]] */
+#define MKD_TOC 0x1000 /* do table-of-contents processing */
+#define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
+
+/* special flags for mkd_in() and mkd_string()
+ */
+#define MKD_NOHEADER 0x0100 /* don't process header blocks */
+#define MKD_TABSTOP 0x0200 /* expand tabs to 4 spaces */
+
+
+#endif/*_MKDIO_D*/
6,376 ppport.h
6,376 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
15 t/Text-Markdown-XS.t
@@ -0,0 +1,15 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl Text-Markdown-XS.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 1;
+BEGIN { use_ok('Text::Markdown::XS') };
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
233 xt/index.text
@@ -0,0 +1,233 @@
+
+Download
+--------
+
+[Markdown 1.0.1][dl] (18 KB) -- 17 Dec 2004
+
+[dl]: http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
+
+
+Introduction
+------------
+
+Markdown is a text-to-HTML conversion tool for web writers. Markdown
+allows you to write using an easy-to-read, easy-to-write plain text
+format, then convert it to structurally valid XHTML (or HTML).
+
+Thus, "Markdown" is two things: (1) a plain text formatting syntax;
+and (2) a software tool, written in Perl, that converts the plain text
+formatting to HTML. See the [Syntax][] page for details pertaining to
+Markdown's formatting syntax. You can try it out, right now, using the
+online [Dingus][].
+
+ [syntax]: /projects/markdown/syntax
+ [dingus]: /projects/markdown/dingus
+
+The overriding design goal for Markdown's formatting syntax is to make
+it as readable as possible. The idea is that a Markdown-formatted
+document should be publishable as-is, as plain text, without looking
+like it's been marked up with tags or formatting instructions. While
+Markdown's syntax has been influenced by several existing text-to-HTML
+filters, the single biggest source of inspiration for Markdown's
+syntax is the format of plain text email.
+
+The best way to get a feel for Markdown's formatting syntax is simply
+to look at a Markdown-formatted document. For example, you can view
+the Markdown source for the article text on this page here:
+<http://daringfireball.net/projects/markdown/index.text>
+
+(You can use this '.text' suffix trick to view the Markdown source for
+the content of each of the pages in this section, e.g. the
+[Syntax][s_src] and [License][l_src] pages.)
+
+ [s_src]: /projects/markdown/syntax.text
+ [l_src]: /projects/markdown/license.text
+
+Markdown is free software, available under a BSD-style open source
+license. See the [License] [pl] page for more information.
+
+ [pl]: /projects/markdown/license
+
+
+Discussion List <a id="discussion-list" />
+---------------
+
+I've set up a public [mailing list for discussion about Markdown] [ml].
+Any topic related to Markdown -- both its formatting syntax and
+its software -- is fair game for discussion. Anyone who is interested
+is welcome to join.
+
+It's my hope that the mailing list will lead to good ideas for future
+improvements to Markdown.
+
+ [ml]: http://six.pairlist.net/mailman/listinfo/markdown-discuss
+
+
+Installation and Requirements <a id="install" />
+-----------------------------
+
+Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.
+Markdown also requires the standard Perl library module [Digest::MD5]
+[md5], which is probably already installed on your server.
+
+ [md5]: http://search.cpan.org/dist/Digest-MD5/MD5.pm
+
+
+### Movable Type ###
+
+Markdown works with Movable Type version 2.6 or later (including
+Movable Type 3.0).
+
+1. Copy the "Markdown.pl" file into your Movable Type "plugins"
+ directory. The "plugins" directory should be in the same directory
+ as "mt.cgi"; if the "plugins" directory doesn't already exist, use
+ your FTP program to create it. Your installation should look like
+ this:
+
+ (mt home)/plugins/Markdown.pl
+
+2. Once installed, Markdown will appear as an option in Movable Type's
+ Text Formatting pop-up menu. This is selectable on a per-post basis:
+
+ ![Screenshot of Movable Type 'Text Formatting' Menu][tfmenu]
+
+ Markdown translates your posts to HTML when you publish; the posts
+ themselves are stored in your MT database in Markdown format.
+
+3. If you also install SmartyPants 1.5 (or later), Markdown will
+ offer a second text formatting option: "Markdown With
+ SmartyPants". This option is the same as the regular "Markdown"
+ formatter, except that it automatically uses SmartyPants to create
+ typographically correct curly quotes, em-dashes, and ellipses. See
+ the [SmartyPants web page][sp] for more information.
+
+4. To make Markdown (or "Markdown With SmartyPants") your default
+ text formatting option for new posts, go to Weblog Config:
+ Preferences.
+
+Note that by default, Markdown produces XHTML output. To configure
+Markdown to produce HTML 4 output, see "Configuration", below.
+
+ [sp]: http://daringfireball.net/projects/smartypants/
+
+
+
+### Blosxom ###
+
+Markdown works with Blosxom version 2.0 or later.
+
+1. Rename the "Markdown.pl" plug-in to "Markdown" (case is
+ important). Movable Type requires plug-ins to have a ".pl"
+ extension; Blosxom forbids it.
+
+2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder.
+ If you're not sure where your Blosxom plug-ins folder is, see the
+ Blosxom documentation for information.
+
+3. That's it. The entries in your weblog will now automatically be
+ processed by Markdown.
+
+4. If you'd like to apply Markdown formatting only to certain
+ posts, rather than all of them, Markdown can optionally be used in
+ conjunction with Blosxom's [Meta][] plug-in. First, install the
+ Meta plug-in. Next, open the Markdown plug-in file in a text
+ editor, and set the configuration variable `$g_blosxom_use_meta`
+ to 1. Then, simply include a "`meta-markup: Markdown`" header line
+ at the top of each post you compose using Markdown.
+
+ [meta]: http://www.blosxom.com/plugins/meta/meta.htm
+
+
+### BBEdit ###
+
+Markdown works with BBEdit 6.1 or later on Mac OS X. It also works
+with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later. If
+you're running Mac OS X 10.2 (Jaguar), you may need to install the
+Perl module [Digest::MD5] [md5] from CPAN; Digest::MD5 comes
+pre-installed on Mac OS X 10.3 (Panther).
+
+1. Copy the "Markdown.pl" file to appropriate filters folder in your
+ "BBEdit Support" folder. On Mac OS X, this should be:
+
+ BBEdit Support/Unix Support/Unix Filters/
+
+ See the BBEdit documentation for more details on the location of
+ these folders.
+
+ You can rename "Markdown.pl" to whatever you wish.
+
+2. That's it. To use Markdown, select some text in a BBEdit document,
+ then choose Markdown from the Filters sub-menu in the "#!" menu, or
+ the Filters floating palette
+
+
+
+Configuration <a id="configuration"></a>
+-------------
+
+By default, Markdown produces XHTML output for tags with empty elements.
+E.g.:
+
+ <br />
+
+Markdown can be configured to produce HTML-style tags; e.g.:
+
+ <br>
+
+
+### Movable Type ###
+
+You need to use a special `MTMarkdownOptions` container tag in each
+Movable Type template where you want HTML 4-style output:
+
+ <MTMarkdownOptions output='html4'>
+ ... put your entry content here ...
+ </MTMarkdownOptions>
+
+The easiest way to use MTMarkdownOptions is probably to put the
+opening tag right after your `<body>` tag, and the closing tag right
+before `</body>`.
+
+To suppress Markdown processing in a particular template, i.e. to
+publish the raw Markdown-formatted text without translation into
+(X)HTML, set the `output` attribute to 'raw':
+
+ <MTMarkdownOptions output='raw'>
+ ... put your entry content here ...
+ </MTMarkdownOptions>
+
+
+### Command-Line ###
+
+Use the `--html4tags` command-line switch to produce HTML output from a
+Unix-style command line. E.g.:
+
+ % perl Markdown.pl --html4tags foo.text
+
+Type `perldoc Markdown.pl`, or read the POD documentation within the
+Markdown.pl source code for more information.
+
+
+Acknowledgements <a id="acknowledgements" />
+----------------
+
+[Aaron Swartz][] deserves a tremendous amount of credit for helping to
+design Markdown's formatting syntax. Markdown is *much* better thanks
+to Aaron's ideas, feedback, and testing. Also, Aaron's [html2text][]
+is a very handy (and free) utility for turning HTML into
+Markdown-formatted plain text.
+
+[Nathaniel Irons][], [Dan Benjamin][], [Daniel Bogan][], and [Jason Perkins][]
+also deserve thanks for their feedback.
+
+[Michel Fortin][] has ported Markdown to PHP; it's a splendid port, and highly recommended for anyone looking for a PHP implementation of Markdown.
+
+ [Aaron Swartz]: http://www.aaronsw.com/
+ [Nathaniel Irons]: http://bumppo.net/
+ [Dan Benjamin]: http://hivelogic.com/
+ [Daniel Bogan]: http://waferbaby.com/
+ [Jason Perkins]: http://pressedpants.com/
+ [Michel Fortin]: http://www.michelf.com/projects/php-markdown/
+ [html2text]: http://www.aaronsw.com/2002/html2text/
+
+ [tfmenu]: /graphics/markdown/mt_textformat_menu.png
33 xt/test.pl
@@ -0,0 +1,33 @@
+#/usr/bin/perl
+
+use ExtUtils::testlib;
+
+use Text::Markdown 'markdown';
+use Text::Markdown::XS;
+use Benchmark;
+use File::Slurp;
+use Text::Diff;
+
+my $text = read_file('index.text');
+warn "XXXX";
+my $a = Text::Markdown::XS::_markdown($text);
+my $b = Text::Markdown::markdown($text);
+$a .= "\n";
+
+unless ( $a eq $b ) {
+print diff \$a, \$b;
+# die "BOO";
+}
+my $count = 1000;
+timethese($count, {
+ 'Text::Markdown::XS' => sub { Text::Markdown::XS::_markdown($text) },
+ 'Text::Markdown' => sub { Text::Markdown::markdown($text) },
+});
+
+
+#warn Text::Markdown::markdown(<<EOF);
+Text::Markdown::XS::_markdown(<<EOF);
+* test
+* Yup, test
+EOF
+

0 comments on commit 2c46fcb

Please sign in to comment.
Something went wrong with that request. Please try again.