Skip to content

Commit 2e18bd9

Browse files
committed
Add options to reset caption counter
1 parent 762b1f4 commit 2e18bd9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Renderer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ TextEnvironment.prototype._renderCloseText = function(node) {
145145
node.children, newTextStyle);
146146
if (node.whitespace) this._html.putText(' ');
147147
this._html.putSpan(closeTextEnv.renderToHTML());
148-
}
148+
};
149149

150150
TextEnvironment.prototype.renderToHTML = function() {
151151
this._html = new HTMLBuilder();
@@ -209,7 +209,7 @@ TextEnvironment.prototype.renderToHTML = function() {
209209
// \CALL{funcName}{funcArgs}
210210
// ==>
211211
// funcName(funcArgs)
212-
this._html.beginSpan('ps-funcname').putText(text).endSpan()
212+
this._html.beginSpan('ps-funcname').putText(text).endSpan();
213213
this._html.write('(');
214214
var argsTextNode = node.children[0];
215215
this._renderCloseText(argsTextNode);
@@ -413,6 +413,8 @@ function RendererOptions(options) {
413413
this.lineNumberPunc = options.lineNumberPunc || ':';
414414
this.lineNumber = options.lineNumber !== undefined ? options.lineNumber : false;
415415
this.noEnd = options.noEnd !== undefined ? options.noEnd : false;
416+
if (options.captionCount !== undefined)
417+
Renderer.captionCount = options.captionCount;
416418
}
417419

418420
RendererOptions.prototype._parseEmVal = function(emVal) {
@@ -438,7 +440,7 @@ function Renderer(parser, options) {
438440
}
439441

440442
/* The global counter for the numbering of the algorithm environment */
441-
Renderer._captionCount = 0;
443+
Renderer.captionCount = 0;
442444

443445
Renderer.prototype.toMarkup = function() {
444446
var html = this._html = new HTMLBuilder();
@@ -567,7 +569,7 @@ Renderer.prototype._buildTree = function(node) {
567569
child = node.children[ci];
568570
if (child.type !== 'caption') continue;
569571
lastCaptionNode = child;
570-
Renderer._captionCount++;
572+
Renderer.captionCount++;
571573
}
572574
// Then, build the header for algorithm
573575
if (lastCaptionNode) {
@@ -748,7 +750,7 @@ Renderer.prototype._buildTree = function(node) {
748750
break;
749751
case 'caption':
750752
this._newLine();
751-
this._typeKeyword('Algorithm ' + Renderer._captionCount + ' ');
753+
this._typeKeyword('Algorithm ' + Renderer.captionCount + ' ');
752754
textNode = node.children[0];
753755
this._buildTree(textNode);
754756
break;

static/test-suite.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
});
138138
var testExamples = document.getElementById("test-examples").textContent;
139139
pseudocode.render(testExamples, document.body, {
140+
captionCount: 0,
140141
lineNumber: true,
141142
noEnd: false
142143
});

0 commit comments

Comments
 (0)