Skip to content

Commit 48e3316

Browse files
committed
Update README and use commentDelimiter as option name
1 parent 3cc52bc commit 48e3316

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ HTML.
55

66
Pseudocode.js accepts a TeX-style input that borrows the algorithmic constructs
77
from LaTeX's algorithm packages and produces a HTML output that looks (almost)
8-
identical to its LaTeX's counterpart. The usage of a TeX-style grammar enables
8+
identical to its LaTeX counterpart. The usage of a TeX-style grammar enables
99
simple construction of math formulas. And any user who already has some LaTeX
1010
experience should find pseudocode.js very intuitive.
1111

1212
## Demo
13-
Visit the [project website](http://www.tatetian.me/pseudocode.js) for a live demo.
13+
Visit the [project website](http://www.tatetian.me/pseudocode.js) for demo.
1414

1515
## Usage
16-
Download [pseudocode.js](), and host the files on your server.
17-
And then include the `js` and `css` files in your HTML files:
16+
Download [pseudocode.js](https://github.com/tatetian/pseudocode.js/releases),
17+
and host the files on your server. And then include the `js` and `css` files in
18+
your HTML files:
1819

1920
```html
2021
<link rel="stylesheet" href="//path/to/pseudocode/pseudocode.min.css">
2122
<script src="//path/to/pseudocode/pseudocode.min.js"></script>
2223
```
2324

24-
Assume your pseudocode is in an `<pre>` DOM element:
25+
Assume the pseudocode to be rendered is in a `<pre>` DOM element:
2526
```html
2627
<pre id="hello-world-code" style="display:hidden;">
2728
\begin{algorithmc}
@@ -60,7 +61,8 @@ The grammar of Pseudocode.js is mostly compatible with `algorithmic` package wit
6061
a few improvement to make it even more easier to use.
6162

6263
### Example
63-
64+
To give you a sense of the grammar for pseudocode, here is an example that
65+
illustrates a quicksort algorithm:
6466
```tex
6567
% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
6668
\begin{algorithm}
@@ -89,7 +91,6 @@ a few improvement to make it even more easier to use.
8991
\end{algorithm}</textarea>
9092
```
9193

92-
9394
### Grammar
9495

9596
Commands for typesetting algorithms must be enclosed in an `algorithmic` environment:
@@ -156,9 +157,9 @@ $i \gets i + 1$
156157
\upshape, \itshape, \slshape, \scshape
157158
\bfseries, \mdseries, \lfseries
158159
# LaTeX's font commands
159-
\textnormal, \textrm, \textsf, \texttt
160-
\textup, \textit, \textsl, \textsc
161-
\uppercase, \lowercase
160+
\textnormal{<text>}, \textrm{<text>}, \textsf{<text>}, \texttt{<text>}
161+
\textup{<text>}, \textit{<text>}, \textsl{<text>}, \textsc{<text>}
162+
\uppercase{<text>}, \lowercase{<text>}
162163
\textbf, \textmd, \textlf
163164
# And it's possible to group text with braces
164165
normal text {\small the size gets smaller} back to normal again
@@ -181,20 +182,30 @@ To display the caption of an algorithm, use `algorithm` environtment as a 'float
181182
```
182183

183184
### Options
184-
Function `pseudocode.renderToString` and `pseudocode.renderToString` accepts
185+
Function `pseudocode.renderToString` and `pseudocode.renderToString` can accept
185186
an option as the last argument.
186187

187188
* `indentSize`: The indent size of inside a control block, e.g. if, for,
188-
etc. The unit must be in 'em'. Default value: '1.2em'.
189-
* `commentSymbol`: The delimiters used to start and end a comment region.
190-
Note that only line comments are supported. Default value: '//'.
191-
* `lineNumber`: Whether line numbering is enabled. Default value: false.
192-
* `lineNumberPunc`: The punctuation that follows line number. Default
193-
value: ':'.
189+
etc. The unit must be in 'em'.
190+
* `commentDelimiter`: The delimiters used to start and end a comment region.
191+
Note that only line comments are supported.
192+
* `lineNumber`: Whether line numbering is enabled.
193+
* `lineNumberPunc`: The punctuation that follows line number.
194194
* `noEnd`: Whether block ending, like `end if`, end procedure`, etc., are
195-
showned. Default value: false.
196-
* `captionCount`: Set the caption counter to this new value.
195+
showned.
196+
* `captionCount`: Reset the caption counter to this number.
197197

198+
The values of the options, if not reset specifically, are:
199+
```js
200+
var DEFAULT_OPTIONS = {
201+
indentSize: '1.2em',
202+
commentDelimiter: '//'
203+
lineNumber: false,
204+
lineNumberPunc: ':',
205+
noEnd: false,
206+
captionCount: undefined
207+
};
208+
```
198209

199210
## Acknowledgement
200211
Pseudocode.js is powered by [KaTeX](http://khan.github.io/KaTeX) to render math formulas.

pseudocode.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* TODO:
55
* * demo
66
* * Support color
7+
* * Case-insensitive
8+
* * elsif
79
**/
810

911
var ParseError = require('./src/ParseError');

src/Renderer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
* TODO: rename commentSymbol to commentDelimiters
32
* */
43
var katex = require('katex');
54
var utils = require('./utils');
@@ -396,7 +395,7 @@ HTMLBuilder.prototype._escapeHtml = function(string) {
396395
* The following are possible options:
397396
* indentSize - The indent size of inside a control block, e.g. if, for,
398397
* etc. The unit must be in 'em'. Default value: '1.2em'.
399-
* commentSymbol - The delimiters used to start and end a comment region.
398+
* commentDelimiter - The delimiters used to start and end a comment region.
400399
* Note that only line comments are supported. Default value: '//'.
401400
* lineNumber - Whether line numbering is enabled. Default value: false.
402401
* lineNumberPunc - The punctuation that follows line number. Default
@@ -410,7 +409,7 @@ function RendererOptions(options) {
410409
options = options || {};
411410
this.indentSize = options.indentSize ?
412411
this._parseEmVal(options.indentSize) : 1.2;
413-
this.commentSymbol = options.commentSymbol || ' // ';
412+
this.commentDelimiter = options.commentDelimiter || ' // ';
414413
this.lineNumberPunc = options.lineNumberPunc || ':';
415414
this.lineNumber = options.lineNumber !== undefined ? options.lineNumber : false;
416415
this.noEnd = options.noEnd !== undefined ? options.noEnd : false;
@@ -758,7 +757,7 @@ Renderer.prototype._buildTree = function(node) {
758757
case 'comment':
759758
textNode = node.children[0];
760759
this._html.beginSpan('ps-comment');
761-
this._html.putText(this._options.commentSymbol);
760+
this._html.putText(this._options.commentDelimiter);
762761
this._buildTree(textNode);
763762
this._html.endSpan();
764763
break;

0 commit comments

Comments
 (0)