55
66Pseudocode.js accepts a TeX-style input that borrows the algorithmic constructs
77from 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
99simple construction of math formulas. And any user who already has some LaTeX
1010experience 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
6061a 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
9596Commands 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
164165normal 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
185186an 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
200211Pseudocode.js is powered by [ KaTeX] ( http://khan.github.io/KaTeX ) to render math formulas.
0 commit comments