summaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-22 22:39:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-22 22:39:26 -0800
commit4570eb2bff2e1b71fa5b6408abbc69c98ff5ff24 (patch)
tree16bab9f8f34dd6fc22a1b7f27b02b7f92b2939d6 /js/lib
parenta71423f6ee1b77d9f79d42599ea00b4ca99f5da0 (diff)
Revert "Remove distinction btw atx and setext header in AST."
This reverts commit a71423f6ee1b77d9f79d42599ea00b4ca99f5da0. Not quite sure about this change, so reverting for now. Note that we still have a distinction between fenced and indented code blocks in the AST. These two distinctions seem to stand or fall together.
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/blocks.js20
-rw-r--r--js/lib/html-renderer.js3
2 files changed, 14 insertions, 9 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index cd42090..65c2c46 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -261,7 +261,8 @@ var incorporateLine = function(ln, line_number) {
}
break;
- case 'Header':
+ case 'ATXHeader':
+ case 'SetextHeader':
case 'HorizontalRule':
// a header can never container > 1 line, so fail to match:
all_matched = false;
@@ -365,7 +366,7 @@ var incorporateLine = function(ln, line_number) {
// ATX header
offset = first_nonspace + match[0].length;
closeUnmatchedBlocks(this);
- container = this.addChild('Header', line_number, first_nonspace);
+ container = this.addChild('ATXHeader', line_number, first_nonspace);
container.level = match[0].trim().length; // number of #s
// remove trailing ###s:
container.strings =
@@ -395,7 +396,7 @@ var incorporateLine = function(ln, line_number) {
((match = ln.slice(first_nonspace).match(/^(?:=+|-+) *$/)))) {
// setext header line
closeUnmatchedBlocks(this);
- container.t = 'Header'; // convert Paragraph to SetextHeader
+ container.t = 'SetextHeader'; // convert Paragraph to SetextHeader
container.level = match[0][0] === '=' ? 1 : 2;
offset = ln.length;
@@ -468,7 +469,7 @@ var incorporateLine = function(ln, line_number) {
// on an empty list item.
container.last_line_blank = blank &&
!(container.t == 'BlockQuote' ||
- container.t == 'Header' ||
+ container.t == 'SetextHeader' ||
container.t == 'FencedCode' ||
(container.t == 'ListItem' &&
container.children.length === 0 &&
@@ -499,7 +500,8 @@ var incorporateLine = function(ln, line_number) {
}
break;
- case 'Header':
+ case 'ATXHeader':
+ case 'SetextHeader':
case 'HorizontalRule':
// nothing to do; we already added the contents.
break;
@@ -510,7 +512,7 @@ var incorporateLine = function(ln, line_number) {
} else if (blank) {
// do nothing
} else if (container.t != 'HorizontalRule' &&
- container.t != 'Header') {
+ container.t != 'SetextHeader') {
// create paragraph container for line
container = this.addChild('Paragraph', line_number, first_nonspace);
this.addLine(ln, first_nonspace);
@@ -559,7 +561,8 @@ var finalize = function(block, line_number) {
}
break;
- case 'Header':
+ case 'ATXHeader':
+ case 'SetextHeader':
case 'HtmlBlock':
block.string_content = block.strings.join('\n');
break;
@@ -629,7 +632,8 @@ var processInlines = function(block) {
newblock.inline_content =
this.inlineParser.parse(block.string_content.trim(), this.refmap);
break;
- case 'Header':
+ case 'SetextHeader':
+ case 'ATXHeader':
newblock.inline_content =
this.inlineParser.parse(block.string_content.trim(), this.refmap);
newblock.level = block.level;
diff --git a/js/lib/html-renderer.js b/js/lib/html-renderer.js
index faf5231..e55b103 100644
--- a/js/lib/html-renderer.js
+++ b/js/lib/html-renderer.js
@@ -103,7 +103,8 @@ var renderBlock = function(block, in_tight_list) {
return inTags(tag, attr, this.innersep +
this.renderBlocks(block.children, block.tight) +
this.innersep);
- case 'Header':
+ case 'ATXHeader':
+ case 'SetextHeader':
tag = 'h' + block.level;
return inTags(tag, [], this.renderInlines(block.inline_content));
case 'IndentedCode':