summaryrefslogtreecommitdiff
path: root/js/lib/blocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/blocks.js')
-rw-r--r--js/lib/blocks.js22
1 files changed, 2 insertions, 20 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index d184b51..7d24406 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -1,3 +1,5 @@
+"use strict";
+
var Node = require('./node');
var unescapeString = require('./common').unescapeString;
@@ -37,7 +39,6 @@ var reLineEnding = /\r\n|\n|\r/;
// Returns true if string contains only space characters.
var isBlank = function(s) {
- "use strict";
return !(reNonSpace.test(s));
};
@@ -45,8 +46,6 @@ var tabSpaces = [' ', ' ', ' ', ' '];
// Convert tabs to spaces on each line using a 4-space tab stop.
var detabLine = function(text) {
- "use strict";
-
var start = 0;
var offset;
var lastStop = 0;
@@ -65,7 +64,6 @@ var detabLine = function(text) {
// Attempt to match a regex in string s at offset offset.
// Return index of match or -1.
var matchAt = function(re, s, offset) {
- "use strict";
var res = s.slice(offset).match(re);
if (res) {
return offset + res.index;
@@ -76,7 +74,6 @@ var matchAt = function(re, s, offset) {
// destructively trip final blank lines in an array of strings
var stripFinalBlankLines = function(lns) {
- "use strict";
var i = lns.length - 1;
while (!reNonSpace.test(lns[i])) {
lns.pop();
@@ -90,7 +87,6 @@ var stripFinalBlankLines = function(lns) {
// Returns true if parent block can contain child block.
var canContain = function(parent_type, child_type) {
- "use strict";
return ( parent_type === 'Document' ||
parent_type === 'BlockQuote' ||
parent_type === 'Item' ||
@@ -99,7 +95,6 @@ var canContain = function(parent_type, child_type) {
// Returns true if block type can accept lines of text.
var acceptsLines = function(block_type) {
- "use strict";
return ( block_type === 'Paragraph' ||
block_type === 'IndentedCode' ||
block_type === 'FencedCode' );
@@ -108,7 +103,6 @@ var acceptsLines = function(block_type) {
// Returns true if block ends with a blank line, descending if needed
// into lists and sublists.
var endsWithBlankLine = function(block) {
- "use strict";
while (block) {
if (block.last_line_blank) {
return true;
@@ -127,7 +121,6 @@ var endsWithBlankLine = function(block) {
// all the lists. (This is used to implement the "two blank lines
// break of of all lists" feature.)
var breakOutOfLists = function(block, line_number) {
- "use strict";
var b = block;
var last_list = null;
do {
@@ -150,7 +143,6 @@ var breakOutOfLists = function(block, line_number) {
// Add a line to the block at the tip. We assume the tip
// can accept lines -- that check should be done before calling this.
var addLine = function(ln, offset) {
- "use strict";
var s = ln.slice(offset);
if (!(this.tip.open)) {
throw { msg: "Attempted to add line (" + ln + ") to closed container." };
@@ -162,7 +154,6 @@ var addLine = function(ln, offset) {
// accept children, close and finalize it and try its parent,
// and so on til we find a block that can accept children.
var addChild = function(tag, line_number, offset) {
- "use strict";
while (!canContain(this.tip.t, tag)) {
this.finalize(this.tip, line_number - 1);
}
@@ -179,7 +170,6 @@ var addChild = function(tag, line_number, offset) {
// Parse a list marker and return data on the marker (type,
// start, delimiter, bullet character, padding) or null.
var parseListMarker = function(ln, offset) {
- "use strict";
var rest = ln.slice(offset);
var match;
var spaces_after_marker;
@@ -220,7 +210,6 @@ var parseListMarker = function(ln, offset) {
// with the same delimiter and bullet character. This is used
// in agglomerating list items into lists.
var listsMatch = function(list_data, item_data) {
- "use strict";
return (list_data.type === item_data.type &&
list_data.delimiter === item_data.delimiter &&
list_data.bullet_char === item_data.bullet_char);
@@ -230,8 +219,6 @@ var listsMatch = function(list_data, item_data) {
// We parse markdown text by calling this on each line of input,
// then finalizing the document.
var incorporateLine = function(ln, line_number) {
- "use strict";
-
var all_matched = true;
var first_nonspace;
var offset = 0;
@@ -570,7 +557,6 @@ var incorporateLine = function(ln, line_number) {
// of paragraphs for reference definitions. Reset the tip to the
// parent of the closed block.
var finalize = function(block, line_number) {
- "use strict";
var pos;
// don't do anything if the block is already closed
if (!block.open) {
@@ -654,7 +640,6 @@ var finalize = function(block, line_number) {
// Walk through a block & children recursively, parsing string content
// into inline content where appropriate. Returns new object.
var processInlines = function(block) {
- "use strict";
var node, event;
var walker = block.walker();
while ((event = walker.next())) {
@@ -667,7 +652,6 @@ var processInlines = function(block) {
};
var Document = function() {
- "use strict";
var doc = new Node('Document', [[1, 1], [0, 0]]);
doc.string_content = undefined;
doc.strings = [];
@@ -676,7 +660,6 @@ var Document = function() {
// The main parsing function. Returns a parsed document AST.
var parse = function(input) {
- "use strict";
this.doc = Document();
this.tip = this.doc;
this.refmap = {};
@@ -705,7 +688,6 @@ var parse = function(input) {
// The DocParser object.
function DocParser(options){
- "use strict";
return {
doc: Document(),
tip: this.doc,