-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
184 changed files
with
27,304 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,13 @@ | |
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
*~ | ||
*.bak | ||
*.diff | ||
*# | ||
scanners.c | ||
*.zip | ||
bstrlib.txt | ||
stmd.dSYM/* | ||
stmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Copyright (c) 2014, John MacFarlane | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of John MacFarlane nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
CFLAGS=-g -O3 -Wall -Wextra -std=c99 -Isrc $(OPTFLAGS) | ||
LDFLAGS=-g -O3 -Wall -Werror | ||
SRCDIR=src | ||
DATADIR=data | ||
|
||
PROG=./stmd | ||
|
||
.PHONY: all oldtests test spec benchjs testjs | ||
all: $(SRCDIR)/case_fold_switch.c $(PROG) | ||
|
||
spec: test spec.html | ||
|
||
spec.md: spec.txt | ||
perl spec2md.pl < $< > $@ | ||
|
||
spec.html: spec.md template.html | ||
pandoc --no-highlight --number-sections --template template.html -s --toc -S $< > $@ # | perl -pe 's/␣/<span class="space"> <\/span>/g' > $@ | ||
|
||
spec.pdf: spec.md template.tex specfilter.hs | ||
pandoc -s $< --template template.tex \ | ||
--filter ./specfilter.hs -o $@ --latex-engine=xelatex --toc \ | ||
--number-sections -V documentclass=report -V tocdepth=2 \ | ||
-V classoption=twosides | ||
|
||
oldtests: | ||
make -C oldtests --quiet clean all | ||
|
||
test: spec.txt | ||
perl runtests.pl $(PROG) $< | ||
|
||
testjs: spec.txt | ||
node js/test.js | ||
# perl runtests.pl js/markdown $< | ||
|
||
benchjs: | ||
node js/bench.js | ||
|
||
$(PROG): $(SRCDIR)/main.c $(SRCDIR)/inlines.o $(SRCDIR)/blocks.o $(SRCDIR)/detab.o $(SRCDIR)/bstrlib.o $(SRCDIR)/scanners.o $(SRCDIR)/print.o $(SRCDIR)/html.o $(SRCDIR)/utf8.o | ||
$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
$(SRCDIR)/scanners.c: $(SRCDIR)/scanners.re | ||
re2c --case-insensitive -bis $< > $@ | ||
|
||
$(SRCDIR)/case_fold_switch.c: $(DATADIR)/CaseFolding-3.2.0.txt | ||
perl mkcasefold.pl < $< > $@ | ||
|
||
.PHONY: leakcheck clean fuzztest dingus | ||
|
||
dingus: | ||
cd js && echo "Starting dingus server at http://localhost:9000" && python -m SimpleHTTPServer 9000 | ||
|
||
leakcheck: $(PROG) | ||
cat oldtests/*/*.markdown | valgrind --leak-check=full --dsymutil=yes $(PROG) | ||
|
||
fuzztest: | ||
for i in `seq 1 10`; do \ | ||
time cat /dev/urandom | head -c 100000 | iconv -f latin1 -t utf-8 | $(PROG) >/dev/null; done | ||
|
||
clean: | ||
-rm test $(SRCDIR)/*.o $(SRCDIR)/scanners.c | ||
-rm -r *.dSYM | ||
-rm spec.md fuzz.txt spec.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
stmd | ||
==== | ||
Standard markdown | ||
================= | ||
|
||
Standard markdown is a specification of markdown syntax, together | ||
with implementations (`stmd`) in C and javascript. | ||
|
||
The C implementation provides both a library and a standalone program | ||
that converts markdown to HTML. It is written in standard C99 and has | ||
no library dependencies. (However, if you check it out from the | ||
repository, you'll need `re2c` to generate `scanners.c` from | ||
`scanners.re`. This is only a build dependency for developers, since | ||
`scanners.c` can be provided in a released source tarball.) | ||
|
||
The javascript implementation is a single javascript file | ||
that can be linked to an HTML page. A standalone version (using | ||
`node.js`) is also provided (`js/markdown`), and there is a | ||
"dingus" for playing with it interactively. (`make dingus` will start | ||
this.) | ||
|
||
The spec contains over 400 embedded examples which serve as | ||
conformance tests. To run the tests for `stmd`, do `make test`. | ||
To run them for another markdown program, say `myprog`, | ||
do `make test PROG=myprog`. To run the tests for `stmd.js`, | ||
do `make testjs`. | ||
|
||
The source of the spec is `spec.txt`. This is basically a markdown | ||
file, with code examples written in a shorthand form: | ||
|
||
. | ||
markdown source | ||
. | ||
expected HTML output | ||
. | ||
|
||
To build an HTML version of the spec, do `make spec.html`. | ||
To build a PDF version, do `make spec.pdf`. Both these commands | ||
require that pandoc is installed, and creating a PDF requires | ||
a latex installation. | ||
|
||
a spec for "standard markdown," with matching C and javascript implementations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- add library function to convert a string | ||
- add README/library documentation | ||
- add man page for prog and library | ||
- document/clean up code | ||
|
Oops, something went wrong.