From 0c89d377042dc01781c789640d48b3dbced3dab1 Mon Sep 17 00:00:00 2001 From: "Tate, Hongliang Tian" <tatetian@gmail.com> Date: Mon, 2 Mar 2015 13:52:26 +0800 Subject: [PATCH] Update README --- PseudoCode.js | 13 ++--------- README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/PseudoCode.js b/PseudoCode.js index b158275..1c3809f 100644 --- a/PseudoCode.js +++ b/PseudoCode.js @@ -1,14 +1,6 @@ /* - -Pseudocode formater that uses a TeX-style grammar - -As stated in the manual of Algorithms package, `Because the mechanisms used to -build the various algorithmic structures make it difficult to` use the most -intuitive grammar in ... we shall NOT strictly follow the format of our TeX -counterpart. Some details are improved to make it more natural. - -The TeX-style pseudocode language (follows **algoritmic** environment) represented -in a context-free grammar: +The TeX-style pseudocode language (follows **algoritmic** environment) +represented in a context-free grammar: <pseudo> :== ( <algorithm> | <algorithmic> )[0..n] @@ -851,7 +843,6 @@ TextEnvironment.prototype.renderToHTML = function() { } } - return this._html.toMarkup(); }; diff --git a/README.md b/README.md index a5f1dd2..45c955a 100644 --- a/README.md +++ b/README.md @@ -1 +1,59 @@ -# PseudoCode.js +# PseudoCode.js - Beautiful pseudocode for the Web + +PseudoCode.js is a JavaScript library that renders pseudocode beautifully to +HTML. The grammar of pseudocode specified by PseudoCode.js +resembles that of Tex/LaTeX and its algorithm packages. TeX allows simple +construction of math formulas. And LaTeX users who are already familiar with +the algorithm packages can easily adopt PseduoCode.js. + +## Demo + +## Usage +Download PseudoCodo.js and KaTeX, and host them on your server. KaTeX is +required as PseudoCode.js relies on KaTeX to render TeX's math formulas. +And then include the these `js` and `css` files in your HTML files as +follows: + +```html +<link rel="stylesheet" href="//path/to/katex/katex.min.css"> +<script src="//path/to/katex/katex.min.js"></script> +<link rel="stylesheet" href="//path/to/pseudocode/pseudocode.min.css"> +<script src="//path/to/pseudocode/pseudocode.min.js"></script> +``` + +Assume your to-be-renderd pseudocode is in an `<pre>` DOM element: +```html +<pre id="hello-world-code" style="display:hidden;"> +\begin{algorithmc} +\PRINT \texttt{'hello world'} +\end{algorithmc} +</pre> +``` + +To render the above code as a HTML element and append to a parent DOM element, +call `PseudoCode.render`: +```js +var code = document.getElementById("test-basics").textContent; +var parentEl = document.body; +var options = {lineNumber: true}; +PseudoCode.render(code, parentEl, options); +``` + +To generate a string of rendered HTML, call `PseudoCode.renderToString`: +```js +var code = document.getElementById("test-basics").textContent; +var options = {lineNumber: true}; +var htmlStr = PseudoCode.renderToString(code, options); +console.log(htmlStr); +``` + +## Features + + +## TeX suport +Pseudocode.js is by no means a full-featured TeX implementation in JavaScript. +It only support a subset of TeX/LaTeX commands that are supposed to be +more likely to be used in an algorithm environtment. + +## Acknowledgement +Pseudocode.js is powered by KaTeX to render math expressions. -- GitLab