Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ We assume the pseudocode to be rendered is in a `<pre>` DOM element.
Here is an example that illustrates a quicksort algorithm:

```html
<pre id="quicksort" style="display:hidden;">
<pre id="quicksort" class="pseudocode" style="display:hidden;">
% This quicksort algorithm is extracted from Chapter 7, Introduction to Algorithms (3rd edition)
\begin{algorithm}
\caption{Quicksort}
Expand Down Expand Up @@ -116,7 +116,7 @@ Here is an example that illustrates a quicksort algorithm:
</pre>
```

#### Step 4 &middot; Render the element using pseudocode.js
#### Step 4A &middot; Render the element using pseudocode.js
Insert the following Javascript snippet at the end of your document:

```html
Expand All @@ -125,6 +125,14 @@ Insert the following Javascript snippet at the end of your document:
</script>
```

#### Step 4B &middot; Render the class using pseudocode.js
Insert the following Javascript snippet at the end of your document:

```html
<script>
pseudocode.renderClass("pseudocode");
</script>
```

### Grammar
There are several packages for typesetting algorithms in LaTeX, among which
Expand Down
7 changes: 7 additions & 0 deletions pseudocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,11 @@ module.exports = {
}
}
},

renderClass: function(class_name, options) {
[].forEach.call(
document.getElementsByClassName(class_name),
function (el) { this.renderElement(el, options); }
);
},
};