ows/commonmark-sup-sub-extensions
Add superscript and subscript support to your CommonMark markdown with this lightweight PHP extension. It registers ^text^ and text style syntax so you can render scientific notation, footnotes, and chemical formulas cleanly in Laravel or any CommonMark-powered app.
Architecture fit. The package is a narrowly scoped league/commonmark extension that adds superscript/subscript inline parsing and rendering. Architecturally it slots into the same parser Laravel already depends on (league/commonmark powers Str::markdown() and Markdown mail templates), so there is no new runtime, service, or datastore. Fit is good if the application has a genuine scientific/technical notation requirement (footnote markers, exponents, chemical formulas, version annotations). Fit is poor if adopted opportunistically: CommonMark has no sup/sub syntax, so this introduces a non-standard dialect that will not render on GitHub, in most editors, or in downstream consumers.
Integration feasibility. Mechanically simple: composer require, instantiate the extension, register it on a Environment/converter. The friction is Laravel-side, not package-side. Str::markdown() builds a GithubFlavoredMarkdownConverter internally and does not expose extension registration, and Laravel's Markdown mail renderer likewise owns its converter. Integration therefore requires replacing or wrapping the framework's default pipeline (custom singleton, Blade directive, or a Str::macro) rather than a config flag. That is a contained change but touches a shared rendering path, so it should be scoped to specific content types, not applied globally.
Technical risk.
~ overlaps GFM strikethrough (~~text~~) and ^ appears in shell snippets and code. Inline parser precedence determines whether existing content silently changes meaning. Escaping behavior must be tested explicitly.<sup>/<sub>; confirm the extension respects html_input/allow_unsafe_links and does not open an escaping gap in the surrounding sanitization layer.Key questions.
league/commonmark versions are supported, and is there CI against v2?Stack fit. Composer-native, no PHP extensions or system dependencies. The only decision point is where the converter lives: a dedicated MarkdownRenderer service bound as a singleton, injected into the resources/controllers that need notation support, with the framework default left untouched for mail and general-purpose markdown.
Migration path. Do not swap the global markdown pipeline. Instead:
league/commonmark version in a scratch branch.Environment, register the extension, and expose it behind one service class.^ and ~, and document it for authors.Compatibility. Verify against the exact Laravel and commonmark versions in composer.lock before anything else. Because the framework's Str::markdown() and mail renderer are not extension-aware, plan for a thin adapter and accept that behavior will differ between "rich content" fields and everything else. If the package targets an older commonmark major, fork-and-patch is a realistic outcome — budget for it.
Sequencing. Legal/license review → version compatibility spike → adapter implementation → corpus diff → sanitization verification → internal docs/authoring guidance → feature-flag rollout to a single low-risk surface → expand. Do not gate a release on this; it is a content-capability enhancement, not a dependency.
Build-vs-buy note. Given the tiny feature surface and the GPL/no-provenance profile, an in-house SupExtension/SubExtension (inline parser + renderer, roughly a day of work for someone fluent in CommonMark's delimiter model) is a credible alternative that removes both the license and the supply-chain question entirely. Recommend pricing that option before committing.
Maintenance. Low ongoing effort if it works, but the maintenance burden is effectively ours: single-purpose community package, minimal adoption, unverified maintainer activity. Expect to own patches for commonmark major bumps. No vendor support channel exists.
Support. Failures will surface as "markdown looks wrong" reports from content authors, not as exceptions, which makes triage slow and diffuse. Requires a documented syntax guide and a clear statement of which fields support the notation. Add a rendering test fixture so regressions are caught in CI rather than by users.
Scaling. Negligible. Parsing is per-render and cheap; the correct pattern is to cache rendered HTML keyed by a content hash so the extension is not invoked on every request. No impact on queue, DB, or infra footprint.
Failure modes.
~~struck~~ becoming subscript). Mitigate with the corpus diff and explicit escaping rules.Ramp-up. Developer ramp-up is minimal — anyone who has touched CommonMark extensions can wire this in an afternoon, and authors need only a one-page syntax reference. The real ramp-up cost is organizational: legal review of GPL-3.0, plus editorial discipline to keep the non-standard dialect from leaking into content that gets syndicated or exported. If the content is ever rendered outside this application, the notation degrades to literal caret and tilde characters, which is a product-visible defect rather than a technical one.
How can I help you explore Laravel packages today?