cradeq/commonmark-strikethrough-sub-sup-extension

Adds support for strikethrough, subscript and superscript in Markdown (using `<del>`, `<sub>` and `<sup>` HTML tags).

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:commonmark-extension

pkg:composer/cradeq/commonmark-strikethrough-sub-sup-extension

v1.0.0 2026-02-10 20:24 UTC

This package is auto-updated.

Last update: 2026-02-11 17:43:36 UTC


README

This package adds support for subscript and superscript in Markdown (using <sub> and <sup> HTML tags). This package also duplicates the logic used in the League Strikethrough Extension (which generates <del> tags).

There is no official spec that supports both subscript and strikethrough. As they both typically use the tilde character (~), we follow the extended syntax of Markdown Guide. That means that strikethrough with only one tilde is necessarily NOT supported. Subscript and strikethrough can be nested, similar to how emphasis works (~Subscript ~~Subscript and striked~~~).

Added markdown features

Name Markdown Result
Superscript ^Text^ <sup>Text</sup>
Subscript ~Text~ <sub>Text</sub>
Strikethrough ~~Text~~ <del>Text</del>

Install

This project can be installed via composer:

composer require cradeq/commonmark-strikethrough-sub-sup-extension

Usage

use Cradeq\CommonMark\StrikethroughSubExtension;
use Cradeq\CommonMark\SupExtension;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;

$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension);
$environment->addExtension(new StrikethroughSubExtension);
$environment->addExtension(new SupExtension);