Metadata-Version: 2.4
Name: sphinxcontrib-pseudocode2
Version: 1.1.0
Summary: Sphinx extension to render LaTeX-like pseudocode via pseudocode.js (Sphinx 7.1+/8.x compatible, MathJax 3 friendly, AMD-safe)
Project-URL: Homepage, https://github.com/DeepPSP/sphinxcontrib-pseudocode2
Project-URL: Issues, https://github.com/DeepPSP/sphinxcontrib-pseudocode2/issues
Author-email: WEN Hao <wenh06@gmail.com>
License: | sphinxcontrib-pseudocode is a Sphinx extension for pseudocode.js
        | Copyright (c) 2021 by Zeyuan Hu
          Copyright (c) 2025, WEN Hao
        | All rights reserved.
        
        sphinxcontrib-pseudocode is based on sphinxcontrib-mermaid.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are
        met:
        
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
        "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
        A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
        OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
        SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
        LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        | sphinxcontrib-mermaid is a Sphinx extension for Mermaid Diagrams
        | Copyright (c) 2016 by Martín Gaitán
        | All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are
        met:
        
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
        "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
        A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
        OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
        SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
        LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE.rst
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Classifier: Framework :: Sphinx
Classifier: Framework :: Sphinx :: Extension
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Documentation
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Requires-Dist: docutils>=0.17
Requires-Dist: jinja2>=3.0
Requires-Dist: sphinx>=7.1
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: furo; extra == 'dev'
Requires-Dist: pydata-sphinx-theme; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest-xdist; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: sphinx; extra == 'dev'
Requires-Dist: sphinx-copybutton; extra == 'dev'
Requires-Dist: sphinx-tabs; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-xdist; extra == 'test'
Requires-Dist: pytest>=7; extra == 'test'
Requires-Dist: sphinx; extra == 'test'
Description-Content-Type: text/markdown

# sphinxcontrib-pseudocode2

[![pytest](https://github.com/DeepPSP/sphinxcontrib-pseudocode2/actions/workflows/run-pytest.yml/badge.svg)](https://github.com/DeepPSP/sphinxcontrib-pseudocode2/actions/workflows/run-pytest.yml)
[![codecov](https://codecov.io/gh/DeepPSP/sphinxcontrib-pseudocode2/branch/master/graph/badge.svg?token=4IQD228F7L)](https://codecov.io/gh/DeepPSP/sphinxcontrib-pseudocode2)
[![PyPI](https://img.shields.io/pypi/v/sphinxcontrib-pseudocode2?style=flat-square)](https://pypi.org/project/sphinxcontrib-pseudocode2/)
[![RTD Status](https://readthedocs.org/projects/sphinxcontrib-pseudocode2/badge/?version=latest)](https://pcode2.readthedocs.io/en/latest/?badge=latest)
[![gh-page status](https://github.com/DeepPSP/sphinxcontrib-pseudocode2/actions/workflows/docs-publish.yml/badge.svg?branch=doc)](https://github.com/DeepPSP/sphinxcontrib-pseudocode2/actions/workflows/docs-publish.yml)
<!-- [![downloads](https://img.shields.io/pypi/dm/sphinxcontrib-pseudocode2?style=flat-square)](https://pypistats.org/packages/sphinxcontrib-pseudocode2) -->
[![PyPI Downloads](https://static.pepy.tech/badge/sphinxcontrib-pseudocode2/month)](https://pepy.tech/projects/sphinxcontrib-pseudocode2)
[![license](https://img.shields.io/github/license/DeepPSP/sphinxcontrib-pseudocode2?style=flat-square)](LICENSE.rst)
![GitHub Release Date - Published_At](https://img.shields.io/github/release-date/DeepPSP/sphinxcontrib-pseudocode2)
![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/DeepPSP/sphinxcontrib-pseudocode2/latest)

This is a fork of the original [sphinxcontrib-pseudocode project](https://github.com/xxks-kkk/sphinxcontrib-pseudocode/),
updated to support Sphinx 7.1+ and 8.x, and modern [pseudocode.js](https://github.com/SaswatPadhi/pseudocode.js).

## Installation

```bash
pip install sphinxcontrib-pseudocode2
```

## Quick Start

Enable the extension in your Sphinx `conf.py`:

```python
extensions = [
    ...,
    "sphinxcontrib.pseudocode2",
]

# -------------------------- Optional Configuration --------------------------
# 1. Specify math engine (default: "mathjax3", alternative: "katex")
pseudocode2_math_engine = "mathjax3"

# 2. Global pseudocode.js configuration (pseudocode2_options)
#    All parameters are directly passed to pseudocode.renderClass()
#    Covers all pseudocode.js native options (unified project-wide style)
pseudocode2_options = {
    "lineNumber": True,           # Global default: enable line numbering
    "lineNumberPunc": " | ",      # Punctuation after line numbers (e.g., "1 | ")
    "commentDelimiter": "#",      # Global default comment delimiter
    "noEnd": False,               # Global default: show "END" for control blocks
    "titlePrefix": "PseudoCode",  # Global default title prefix (replace "Algorithm")
    "scopeLines": True,           # Global default: enable scope line highlighting
}
```

Write LaTeX-like pseudocode in an `.. pcode::` directive:

```text
.. pcode::
   :linenos:

   \begin{algorithm}
   \caption{Quicksort}
   \begin{algorithmic}
   \PROCEDURE{Quicksort}{$A, p, r$}
     \IF{$p < r$}
       \STATE $q = $ \CALL{Partition}{$A, p, r$}
       \STATE \CALL{Quicksort}{$A, p, q - 1$}
       \STATE \CALL{Quicksort}{$A, q + 1, r$}
     \ENDIF
   \ENDPROCEDURE
   \end{algorithmic}
   \end{algorithm}
```

## Configuration Options

Pseudocode rendering is extended with practical options (all compatible with pseudocode.js native capabilities):

- ``linenos``: Enable line numbering
- ``no-linenos``: Disable line numbering
- ``indent``: Set indentation (seems working only for ``em``, no other units) for code blocks, default: ``1.2em``
- ``comment-delimiter``: Customize comment delimiters, default: ``//``
- ``line-number-punc``: Set line number punctuation, default: ``:``
- ``no-end``: Omit the ``END`` keyword for control blocks
- ``title-prefix``: Customize the algorithm title prefix (e.g., ``PseudoCode`` instead of default ``Algorithm``)
- ``caption-count``: Reset the caption counter to this number
- ``scopelines``: Highlight scope lines (those with control block starters like IF, FOR, WHILE, etc.)
- ``no-scopelines``: Disable scope line highlighting

### Global Configuration via ``pseudocode2_options``

Pseudocode rendering styles can be unified across the entire project using a single global configuration (supports all pseudocode.js native parameters, see [pseudocode.js](https://github.com/SaswatPadhi/pseudocode.js)). See also the example in the [Quick Start section](#quick-start).

**Priority Rule**:
Configuration priority (higher priority overrides lower): Directive option (e.g., :linenos: in .rst) > pseudocode2_options (global in conf.py) > pseudocode.js default
