npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@noah-medra/htsl-codemirror

v0.1.0

Published

Extensions CodeMirror 6 pour HTSL : coloration, autocomplétion, linter.

Readme

@noah-medra/htsl-codemirror

Extensions CodeMirror 6 réutilisables pour le langage HTSL : coloration syntaxique, autocomplétion contextuelle et linter.

npm install @noah-medra/htsl-codemirror @noah-medra/htsl-core codemirror

@codemirror/*, @lezer/highlight et @noah-medra/htsl-core sont des peerDependencies.

Ajouter un éditeur HTSL en moins de 10 lignes

import { EditorView, basicSetup } from "codemirror";
import { keymap } from "@codemirror/view";
import { indentWithTab } from "@codemirror/commands";
import { autocompletion } from "@codemirror/autocomplete";
import { parse, registry } from "@noah-medra/htsl-core";
import { htslLanguage, htslCompletion, htslLinter } from "@noah-medra/htsl-codemirror";

new EditorView({
  parent: document.querySelector("#editor")!,
  doc: "{div.box:Bonjour {@mti: x^2}}",
  extensions: [
    basicSetup,
    htslLanguage(),                                              // coloration + indentation
    autocompletion({ override: [htslCompletion(registry)] }),    // snippets + commande slash
    htslLinter(parse),                                           // diagnostics
    keymap.of([indentWithTab]),                                  // Tab / Maj-Tab
  ],
});

Ces trois extensions alimentent les deux éditeurs du playground : l'éditeur principal et l'éditeur de bloc flottant ouvert depuis le rendu — même coloration, même autocomplétion, même indentation.

API

| Export | Rôle | |--------|------| | htslLanguage() | LanguageSupport : coloration via un StreamLanguage écrit à la main (accolades, balises, .classes, #id, [attributs] — noms/valeurs/chaînes distingués —, @objets/composants, directives {!define}/{!set}, variables {$x}, math $…$/$$…$$, commentaires, échappements). Le corps de {script:…}/{style:…} est coloré comme du JS/CSS (mots-clés, nombres, chaînes, commentaires, gabarits multi-lignes). Fournit aussi l'indentation (profondeur d'accolades : Entrée auto-indente, } se réindente) et le pliage de code (foldService : replie tout bloc {…}/{@…} multi-ligne ; accolades dans les chaînes/échappements ignorées). Côté éditeur, ajoutez indentWithTab au keymap, et codeFolding() + foldGutter() + foldKeymap pour la gouttière de pliage. | | htslCompletion(registry) | Source d'autocomplétion contextuelle branchée sur l'introspection : {@→objets/composants (insérés comme snippets à trous), /→commande slash en début de ligne (objets, balises HTML, composants), [→attributs typés, {$→variables, {!→directives. Les snippets viennent du champ snippet des métadonnées. | | htslLinter(parse) | Extension linter : diagnostics soulignés depuis les HTSLError du mode tolérant (ligne/colonne + message). |

Helpers : htslTokens(src) (tokenisation, pour tests/outils), htslDiagnostics(text, parse) (diagnostics bruts { line, col, message }).

Notes

  • htslCompletion accepte n'importe quel objet d'introspection compatible (list / describe / components / variables) — passez registry de @noah-medra/htsl-core, ou un registre étendu.
  • Commande slash : la source renvoie les entrées quand l'autocomplétion est ouverte sur un / en début de ligne. CodeMirror n'auto-active pas sur un non-mot ; l'hôte doit donc appeler startCompletion(view) quand l'utilisateur tape / seul en début de ligne (un updateListener suffit — voir playground/src/main.ts).
  • Le linter utilise le mode tolérant du parser : il ne lève jamais, et chaque problème de syntaxe devient un diagnostic localisé.
  • Tests : 29 (tokenisation, complétion, snippets, slash, indentation, linter).