aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rwxr-xr-xjs/stmd.js38
-rw-r--r--spec.txt18
3 files changed, 34 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 11e2141..671d30d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
-CFLAGS=-g -O3 -Wall -Wextra -std=c99 -Isrc $(OPTFLAGS)
-LDFLAGS=-g -O3 -Wall -Werror
-SRCDIR=src
-DATADIR=data
+CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers $(OPTFLAGS)
+LDFLAGS?=-g -O3 -Wall -Werror
+SRCDIR?=src
+DATADIR?=data
-PROG=./stmd
+PROG?=./stmd
.PHONY: all oldtests test spec benchjs testjs
all: $(SRCDIR)/case_fold_switch.inc $(PROG)
@@ -42,6 +42,7 @@ benchjs:
node js/bench.js ${BENCHINP}
HTML_OBJ=$(SRCDIR)/html/html.o $(SRCDIR)/html/houdini_href_e.o $(SRCDIR)/html/houdini_html_e.o $(SRCDIR)/html/houdini_html_u.o
+
STMD_OBJ=$(SRCDIR)/inlines.o $(SRCDIR)/buffer.o $(SRCDIR)/blocks.o $(SRCDIR)/scanners.c $(SRCDIR)/print.o $(SRCDIR)/utf8.o $(SRCDIR)/references.c
$(PROG): $(SRCDIR)/html/html_unescape.h $(SRCDIR)/case_fold_switch.inc $(HTML_OBJ) $(STMD_OBJ) $(SRCDIR)/main.c
diff --git a/js/stmd.js b/js/stmd.js
index 4b3d83e..f7f48fd 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -139,7 +139,7 @@ var match = function(re) {
// Returns the character at the current subject position, or null if
// there are no more characters.
var peek = function() {
- return this.subject[this.pos] || null;
+ return this.subject.charAt(this.pos) || null;
};
// Parse zero or more space characters, including at most one newline
@@ -185,13 +185,13 @@ var parseBackticks = function(inlines) {
var parseEscaped = function(inlines) {
var subj = this.subject,
pos = this.pos;
- if (subj[pos] === '\\') {
- if (subj[pos + 1] === '\n') {
+ if (subj.charAt(pos) === '\\') {
+ if (subj.charAt(pos + 1) === '\n') {
inlines.push({ t: 'Hardbreak' });
this.pos = this.pos + 2;
return 2;
- } else if (reEscapable.test(subj[pos + 1])) {
- inlines.push({ t: 'Str', c: subj[pos + 1] });
+ } else if (reEscapable.test(subj.charAt(pos + 1))) {
+ inlines.push({ t: 'Str', c: subj.charAt(pos + 1) });
this.pos = this.pos + 2;
return 2;
} else {
@@ -245,7 +245,7 @@ var scanDelims = function(c) {
var startpos = this.pos;
char_before = this.pos === 0 ? '\n' :
- this.subject[this.pos - 1];
+ this.subject.charAt(this.pos - 1);
while (this.peek() === c) {
numdelims++;
@@ -309,7 +309,7 @@ var parseEmphasis = function(inlines) {
// into an Emph whose contents are the succeeding inlines
inlines[delimpos].t = 'Emph';
inlines[delimpos].c = inlines.slice(delimpos + 1);
- inlines.splice(delimpos + 1);
+ inlines.splice(delimpos + 1, inlines.length - delimpos - 1);
break;
} else {
if (this.parseInline(inlines) === 0) {
@@ -326,7 +326,7 @@ var parseEmphasis = function(inlines) {
this.pos += 2;
inlines[delimpos].t = 'Strong';
inlines[delimpos].c = inlines.slice(delimpos + 1);
- inlines.splice(delimpos + 1);
+ inlines.splice(delimpos + 1, inlines.length - delimpos - 1);
break;
} else {
if (this.parseInline(inlines) === 0) {
@@ -500,7 +500,7 @@ var parseLink = function(inlines) {
((dest = this.parseLinkDestination()) !== null) &&
this.spnl() &&
// make sure there's a space before the title:
- (/^\s/.test(this.subject[this.pos - 1]) &&
+ (/^\s/.test(this.subject.charAt(this.pos - 1)) &&
(title = this.parseLinkTitle() || '') || true) &&
this.spnl() &&
this.match(/^\)/)) {
@@ -857,7 +857,7 @@ var parseListMarker = function(ln, offset) {
if ((match = rest.match(/^[*+-]( +|$)/))) {
spaces_after_marker = match[1].length;
data.type = 'Bullet';
- data.bullet_char = match[0][0];
+ data.bullet_char = match[0].charAt(0);
} else if ((match = rest.match(/^(\d+)([.)])( +|$)/))) {
spaces_after_marker = match[3].length;
@@ -932,10 +932,10 @@ var incorporateLine = function(ln, line_number) {
switch (container.t) {
case 'BlockQuote':
- var matched = indent <= 3 && ln[first_nonspace] === '>';
+ var matched = indent <= 3 && ln.charAt(first_nonspace) === '>';
if (matched) {
offset = first_nonspace + 1;
- if (ln[offset] === ' ') {
+ if (ln.charAt(offset) === ' ') {
offset++;
}
} else {
@@ -975,7 +975,7 @@ var incorporateLine = function(ln, line_number) {
case 'FencedCode':
// skip optional spaces of fence offset
i = container.fence_offset;
- while (i > 0 && ln[offset] === ' ') {
+ while (i > 0 && ln.charAt(offset) === ' ') {
offset++;
i--;
}
@@ -1052,11 +1052,11 @@ var incorporateLine = function(ln, line_number) {
break;
}
- } else if (ln[first_nonspace] === '>') {
+ } else if (ln.charAt(first_nonspace) === '>') {
// blockquote
offset = first_nonspace + 1;
// optional following space
- if (ln[offset] === ' ') {
+ if (ln.charAt(offset) === ' ') {
offset++;
}
closeUnmatchedBlocks(this);
@@ -1079,7 +1079,7 @@ var incorporateLine = function(ln, line_number) {
closeUnmatchedBlocks(this);
container = this.addChild('FencedCode', line_number, first_nonspace);
container.fence_length = fence_length;
- container.fence_char = match[0][0];
+ container.fence_char = match[0].charAt(0);
container.fence_offset = first_nonspace - offset;
offset = first_nonspace + fence_length;
break;
@@ -1097,7 +1097,7 @@ var incorporateLine = function(ln, line_number) {
// setext header line
closeUnmatchedBlocks(this);
container.t = 'SetextHeader'; // convert Paragraph to SetextHeader
- container.level = match[0][0] === '=' ? 1 : 2;
+ container.level = match[0].charAt(0) === '=' ? 1 : 2;
offset = ln.length;
} else if (matchAt(reHrule, ln, first_nonspace) !== null) {
@@ -1189,7 +1189,7 @@ var incorporateLine = function(ln, line_number) {
case 'FencedCode':
// check for closing code fence:
match = (indent <= 3 &&
- ln[first_nonspace] == container.fence_char &&
+ ln.charAt(first_nonspace) == container.fence_char &&
ln.slice(first_nonspace).match(/^(?:`{3,}|~{3,})(?= *$)/));
if (match && match[0].length >= container.fence_length) {
// don't add closing fence to container; instead, close it:
@@ -1248,7 +1248,7 @@ var finalize = function(block, line_number) {
block.string_content = block.strings.join('\n').replace(/^ */m,'');
// try parsing the beginning as link reference definitions:
- while (block.string_content[0] === '[' &&
+ while (block.string_content.charAt(0) === '[' &&
(pos = this.inlineParser.parseReference(block.string_content,
this.refmap))) {
block.string_content = block.string_content.slice(pos);
diff --git a/spec.txt b/spec.txt
index fce8792..bc2e381 100644
--- a/spec.txt
+++ b/spec.txt
@@ -2010,7 +2010,7 @@ The following rules define [block quotes](#block-quote):
<a id="block-quote"></a>
1. **Basic case.** If a string of lines *Ls* constitute a sequence
- of blocks *Bs*, then the result of appending a [block quote
+ of blocks *Bs*, then the result of prepending a [block quote
marker](#block-quote-marker) to the beginning of each line in *Ls*
is a [block quote](#block-quote) containing *Bs*.
@@ -3686,9 +3686,9 @@ raw HTML:
.
.
-<http://google.com?find=\*>
+<http://example.com?find=\*>
.
-<p><a href="http://google.com?find=%5C*">http://google.com?find=\*</a></p>
+<p><a href="http://example.com?find=%5C*">http://example.com?find=\*</a></p>
.
.
@@ -5504,9 +5504,9 @@ spec](http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#e-m
Examples of email autolinks:
.
-<foo@bar.baz.com>
+<foo@bar.example.com>
.
-<p><a href="mailto:foo@bar.baz.com">foo@bar.baz.com</a></p>
+<p><a href="mailto:foo@bar.example.com">foo@bar.example.com</a></p>
.
.
@@ -5548,15 +5548,15 @@ These are not autolinks:
.
.
-http://google.com
+http://example.com
.
-<p>http://google.com</p>
+<p>http://example.com</p>
.
.
-foo@bar.baz.com
+foo@bar.example.com
.
-<p>foo@bar.baz.com</p>
+<p>foo@bar.example.com</p>
.
## Raw HTML