Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add native test executable.

  • Loading branch information...
commit f9a6ee257cae803d5e2711c2fcf2afca56bdda5f 1 parent dd3bd68
@bootstraponline bootstraponline authored
View
2  .gitignore
@@ -5,3 +5,5 @@ smartypants
*.exe
*.bc
*.js
+*.html
+test
View
7 Makefile.native
@@ -36,7 +36,7 @@ SUNDOWN_SRC=\
html/houdini_html_e.o \
html/houdini_href_e.o
-all: libsundown.so html_blocks
+all: libsundown.so test html_blocks
.PHONY: all clean
@@ -44,6 +44,11 @@ all: libsundown.so html_blocks
libsundown.so: $(SUNDOWN_SRC)
$(CC) $(LDFLAGS) -shared -Wl $^ -o $@
+# executables
+
+test: examples/test.o $(SUNDOWN_SRC)
+ $(CC) $(LDFLAGS) $^ -o $@
+
# perfect hashing
html_blocks: src/html_blocks.h
View
159 data.md
@@ -0,0 +1,159 @@
+GitHub Flavored Markdown
+================================
+
+*View the [source of this content](http://github.github.com/github-flavored-markdown/sample_content.html).*
+
+Let's get the whole "linebreak" thing out of the way. The next paragraph contains two phrases separated by a single newline character:
+
+Roses are red
+Violets are blue
+
+The next paragraph has the same phrases, but now they are separated by two spaces and a newline character:
+
+Roses are red
+Violets are blue
+
+Oh, and one thing I cannot stand is the mangling of words with multiple underscores in them like perform_complicated_task or do_this_and_do_that_and_another_thing.
+
+A bit of the GitHub spice
+-------------------------
+
+In addition to the changes in the previous section, certain references are auto-linked:
+
+* SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* \#Num: #1
+* User/#Num: mojombo#1
+* User/Project#Num: mojombo/god#1
+
+These are dangerous goodies though, and we need to make sure email addresses don't get mangled:
+
+My email addy is tom@github.com.
+
+Math is hard, let's go shopping
+-------------------------------
+
+In first grade I learned that 5 > 3 and 2 < 7. Maybe some arrows. 1 -> 2 -> 3. 9 <- 8 <- 7.
+
+Triangles man! a^2 + b^2 = c^2
+
+We all like making lists
+------------------------
+
+The above header should be an H2 tag. Now, for a list of fruits:
+
+* Red Apples
+* Purple Grapes
+* Green Kiwifruits
+
+Let's get crazy:
+
+1. This is a list item with two paragraphs. Lorem ipsum dolor
+ sit amet, consectetuer adipiscing elit. Aliquam hendrerit
+ mi posuere lectus.
+
+ Vestibulum enim wisi, viverra nec, fringilla in, laoreet
+ vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
+ sit amet velit.
+
+2. Suspendisse id sem consectetuer libero luctus adipiscing.
+
+What about some code **in** a list? That's insane, right?
+
+1. In Ruby you can map like this:
+
+ ['a', 'b'].map { |x| x.uppercase }
+
+2. In Rails, you can do a shortcut:
+
+ ['a', 'b'].map(&:uppercase)
+
+Some people seem to like definition lists
+
+<dl>
+ <dt>Lower cost</dt>
+ <dd>The new version of this product costs significantly less than the previous one!</dd>
+ <dt>Easier to use</dt>
+ <dd>We've changed the product so that it's much easier to use!</dd>
+</dl>
+
+I am a robot
+------------
+
+Maybe you want to print `robot` to the console 1000 times. Why not?
+
+ def robot_invasion
+ puts("robot " * 1000)
+ end
+
+You see, that was formatted as code because it's been indented by four spaces.
+
+How about we throw some angle braces and ampersands in there?
+
+ <div class="footer">
+ &copy; 2004 Foo Corporation
+ </div>
+
+Set in stone
+------------
+
+Preformatted blocks are useful for ASCII art:
+
+<pre>
+ ,-.
+ , ,-. ,-.
+ / \ ( )-( )
+ \ | ,.>-( )-<
+ \|,' ( )-( )
+ Y ___`-' `-'
+ |/__/ `-'
+ |
+ |
+ | -hrr-
+ ___|_____________
+</pre>
+
+Playing the blame game
+----------------------
+
+If you need to blame someone, the best way to do so is by quoting them:
+
+> I, at any rate, am convinced that He does not throw dice.
+
+Or perhaps someone a little less eloquent:
+
+> I wish you'd have given me this written question ahead of time so I
+> could plan for it... I'm sure something will pop into my head here in
+> the midst of this press conference, with all the pressure of trying to
+> come up with answer, but it hadn't yet...
+>
+> I don't want to sound like
+> I have made no mistakes. I'm confident I have. I just haven't - you
+> just put me under the spot here, and maybe I'm not as quick on my feet
+> as I should be in coming up with one.
+
+Table for two
+-------------
+
+<table>
+ <tr>
+ <th>ID</th><th>Name</th><th>Rank</th>
+ </tr>
+ <tr>
+ <td>1</td><td>Tom Preston-Werner</td><td>Awesome</td>
+ </tr>
+ <tr>
+ <td>2</td><td>Albert Einstein</td><td>Nearly as awesome</td>
+ </tr>
+</table>
+
+Crazy linking action
+--------------------
+
+I get 10 times more traffic from [Google] [1] than from
+[Yahoo] [2] or [MSN] [3].
+
+ [1]: http://google.com/ "Google"
+ [2]: http://search.yahoo.com/ "Yahoo Search"
+ [3]: http://search.msn.com/ "MSN Search"
View
68 examples/test.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, Vicent Marti
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "markdown.h"
+#include "html.h"
+#include "buffer.h"
+#include "sundown.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define READ_UNIT 1024
+#define OUTPUT_UNIT 64
+
+/* main • main function, interfacing STDIO with the parser */
+int
+main(int argc, char **argv)
+{
+ struct buf *ib;
+ int ret;
+ FILE *in = stdin;
+
+ /* opening the file if given from the command line */
+ if (argc > 1) {
+ in = fopen(argv[1], "r");
+ if (!in) {
+ fprintf(stderr,"Unable to open input file \"%s\": %s\n", argv[1], strerror(errno));
+ return 1;
+ }
+ }
+
+ /* reading everything */
+ ib = bufnew(READ_UNIT);
+ bufgrow(ib, READ_UNIT);
+ while ((ret = fread(ib->data + ib->size, 1, ib->asize - ib->size, in)) > 0) {
+ ib->size += ret;
+ bufgrow(ib, ib->size + READ_UNIT);
+ }
+
+ if (in != stdin)
+ fclose(in);
+
+ char* data = str_to_html(bufcstr(ib));
+ /* writing the result to stdout */
+ ret = fwrite(data, 1, strlen(data), stdout);
+
+ /* cleanup */
+ bufrelease(ib);
+
+ return (ret < 0) ? -1 : 0;
+}
+
+/* vim: set filetype=c: */
View
7 native.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+echo "Cleaning"
+make clean
+echo "Making native"
+make -f Makefile.native
+echo "Saving native output"
+./test data.md > output.html
View
7 readme.md
@@ -1,4 +1,4 @@
-Emscripten, swig, and native branch are depreciated. The master branch now contains all the relevant code and build files.
+The master branch now contains all code and build files. Other branches are no longer used.
#### 3 Make files.
@@ -6,6 +6,7 @@ Emscripten, swig, and native branch are depreciated. The master branch now conta
- Makefile.native - BridJ, mostly unmodified upstream makefile
- Makefile.swig - SWIG
-Run `bash to_js.sh` to compile JavaScript version.
+`./to_js.sh` builds the emscripten library
+`./native.sh` builds the native library and a test executable
-Use latest emcc with latest [closure compiler](http://code.google.com/p/closure-compiler/downloads/list) in `emscripten/third_party/closure-compiler`.
+To increase the chance of a working emscripten build, use unmodified emcc with bundled closure.

0 comments on commit f9a6ee2

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