From 78d53ae2866c9bb3e24d0b2d5c7f65cd2f8b4898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Mon, 8 Sep 2014 11:05:24 +0200 Subject: Fix some compatibility issues - Use `String.charAt(index)` instead of array like syntax for browser compatibility. - Use `Array.slice(index, length)` instead of `Array.slice(index)` for browser compatibility. --- js/stmd.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/js/stmd.js b/js/stmd.js index 15d7345..1ee2206 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); -- cgit v1.2.3 From e752b9776d434f63768c50e4c73c533a43529052 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 24 Sep 2014 22:22:51 -0700 Subject: Makefile: Use ?= so variables can be set on command line. --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 11e2141..f5f408e 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 $(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) -- cgit v1.2.3 From c006aececef112f61dd44cad43f0596221f29700 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 24 Sep 2014 22:47:47 -0700 Subject: Suppress 'missing field initializer' warnings from gperf generated header. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f5f408e..671d30d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc $(OPTFLAGS) +CFLAGS?=-g -O3 -Wall -Wextra -std=c99 -Isrc -Wno-missing-field-initializers $(OPTFLAGS) LDFLAGS?=-g -O3 -Wall -Werror SRCDIR?=src DATADIR?=data @@ -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 -- cgit v1.2.3 From efc3e5d7a234587c79ac847213437f936de2499b Mon Sep 17 00:00:00 2001 From: Andrew January Date: Mon, 29 Sep 2014 13:12:29 +0100 Subject: Changes append to prepend When adding something to the beginning it is "prepending", not "appending" --- spec.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.txt b/spec.txt index fce8792..b89105f 100644 --- a/spec.txt +++ b/spec.txt @@ -2010,7 +2010,7 @@ The following rules define [block quotes](#block-quote): 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*. -- cgit v1.2.3 From 749b3000e8cc3202c52e30f2cd5e585175e9e17d Mon Sep 17 00:00:00 2001 From: Andrew January Date: Mon, 29 Sep 2014 13:24:54 +0100 Subject: Changes urls to use example.com As per RFC 2606 it is recommended to use example.com for sample urls in specifications. One example is left using "foo+special@Bar.baz-bar0.com" because it is designed to demonstrate the complexity of email addresses that should be permitted. --- spec.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spec.txt b/spec.txt index fce8792..9a7e675 100644 --- a/spec.txt +++ b/spec.txt @@ -3686,9 +3686,9 @@ raw HTML: . . - + . -

http://google.com?find=\*

+

http://example.com?find=\*

. . @@ -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

. . @@ -5548,15 +5548,15 @@ These are not autolinks: . . -http://google.com +http://example.com . -

http://google.com

+

http://example.com

. . -foo@bar.baz.com +foo@bar.example.com . -

foo@bar.baz.com

+

foo@bar.example.com

. ## Raw HTML @@ -6146,5 +6146,3 @@ an `emph`. The document can be rendered as HTML, or in any other format, given an appropriate renderer. - - -- cgit v1.2.3 From 205b4aafe8c4aeb03700b450d2805f6f5b9fdc3f Mon Sep 17 00:00:00 2001 From: Andrew January Date: Mon, 29 Sep 2014 13:27:12 +0100 Subject: Adds missing newlines --- spec.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec.txt b/spec.txt index 9a7e675..c9d207a 100644 --- a/spec.txt +++ b/spec.txt @@ -6146,3 +6146,5 @@ an `emph`. The document can be rendered as HTML, or in any other format, given an appropriate renderer. + + -- cgit v1.2.3