From 30f2576509167727ea3ff356ad2635e9df9505ce Mon Sep 17 00:00:00 2001 From: Saswat Padhi Date: Sun, 28 May 2023 18:43:16 +0000 Subject: [PATCH] allow per-element option overriding --- README.md | 21 +++++++++++++++++++-- docs/katex-samples.html | 4 ++-- docs/mathjax-v2-samples.html | 4 ++-- docs/mathjax-v3-samples.html | 4 ++-- docs/pseudocode.js | 2 +- pseudocode.js | 5 ++++- static/body.html.part | 4 ++-- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9f850b7..4250f16 100644 --- a/README.md +++ b/README.md @@ -241,8 +241,10 @@ To display the caption of an algorithm, use `algorithm` environment as a 'float' ``` ### Options -`pseudocode.renderElement` can accept an option as the last argument, -such as + +#### Global Options + +`pseudocode.renderElement` can accept an option object as the last argument, such as ```js pseudocode.renderElement(document.getElementById("quicksort"), @@ -274,6 +276,21 @@ var DEFAULT_OPTIONS = { }; ``` +#### Per-Element Options + +The above-mentioned global options may be overridden on a per-element basis +using [HTML `data-*` attributes](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset) +on the `
` DOM element.
+
+The following example demonstrates how to enable line numbers and change title prefix:
+
+```html
+
+   ...
+
+``` + ## Build and Test pseudocode.js is written in JavaScript and built with [Node.js](https://nodejs.org). So, make sure you have Node.js installed before building pseudocode.js. diff --git a/docs/katex-samples.html b/docs/katex-samples.html index 53bf9a7..c0f0288 100644 --- a/docs/katex-samples.html +++ b/docs/katex-samples.html @@ -17,7 +17,7 @@ -