summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-16 21:43:39 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-16 21:43:39 -0800
commitcc6bb4bd3cf241835cd31066bc06d005684459ac (patch)
tree66cec3ab36db0877acd5d35c2124f4afae53d4ad /js
parentc9994effcff67d4fddab23c2364218a09e807768 (diff)
Defer closing of fenced code blocks.
Instead of closing a fenced code block when we see the closing fence, we set fenceLength to -1, which then signals the code that checks for block enders that it is time to close the block. This allows us to process a blank line after the fenced code and set _lastLineBlank appropriately. Addresses #285 for JS implementation.
Diffstat (limited to 'js')
-rw-r--r--js/lib/blocks.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index 9286e3a..c70af15 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -308,11 +308,18 @@ var incorporateLine = function(ln) {
case 'CodeBlock':
if (container._isFenced) { // fenced
- // skip optional spaces of fence offset
- i = container._fenceOffset;
- while (i > 0 && ln.charCodeAt(offset) === C_SPACE) {
- offset++;
- i--;
+ if (container._fenceLength === -1) {
+ all_matched = false;
+ if (blank) {
+ container._lastLineBlank = true;
+ }
+ } else {
+ // skip optional spaces of fence offset
+ i = container._fenceOffset;
+ while (i > 0 && ln.charCodeAt(offset) === C_SPACE) {
+ offset++;
+ i--;
+ }
}
} else { // indented
if (indent >= CODE_INDENT) {
@@ -533,7 +540,7 @@ var incorporateLine = function(ln) {
ln.slice(first_nonspace).match(reClosingCodeFence));
if (match && match[0].length >= container._fenceLength) {
// don't add closing fence to container; instead, close it:
- this.finalize(container, this.lineNumber);
+ container._fenceLength = -1; // -1 means we've passed closer
} else {
this.addLine(ln, offset);
}