Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithms numbering #27

Closed
dppalomar opened this issue Dec 8, 2021 · 1 comment
Closed

Algorithms numbering #27

dppalomar opened this issue Dec 8, 2021 · 1 comment

Comments

@dppalomar
Copy link

Thanks for writing pseudocode.js. It looks quite amazing.

By default, pseudocode.js does an automatic numbering starting at 1. I am personally trying to use it in a book, so I need a numbering with the chapters, like Algorithm 2.1 or Algorithm A.1.

I wonder if it would be possible to somehow specify the desired chapter prefix (in the example above it would be prefix "2" or "A").

In the worst case, I wonder if it would be possible to fully specify the number by hand rather than automatic. In the example above, I would specify "2.1" or "A.1".

Thanks!

@SaswatPadhi
Copy link
Owner

SaswatPadhi commented May 28, 2023

Hello @dppalomar,

Sorry about the delay in getting back to you on this issue. I had been away from this project for a while, because of work and family priorities.

I had a chance to think about this today, and a quick solution I could come up with was to allow the options (in particular the titlePrefix) to be overridden on a per-element basis, as opposed to it being fixed globally (for all elements).

I pushed a change to implement this idea (see 30f2576 for the change and examples), so now it should be possible to do something like:

<pre class="pseudocode" data-title-prefix="Algorithm A.">
   ...
</pre>
...
<pre class="pseudocode" data-title-prefix="Algorithm B.">
   ...
</pre>
...
<pre class="pseudocode" data-title-prefix="Algorithm C.">
   ...
</pre>
...
<script>
    pseudocode.renderClass("pseudocode");
</script>

Specifying the override on each <pre> is repetitive, and I am open to other ideas.

But I am resolving this issue since now there is a way (although a repetitive one) to achieve the desired goal. Thanks again for raising this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants