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

highlightjs-sfmc

v0.1.1

Published

Highlight.js grammars for Salesforce Marketing Cloud languages (AMPscript and SSJS)

Readme

SFMC Languages for Highlight.js

npm version License: MIT

Syntax highlighting for Salesforce Marketing Cloud languages using Highlight.js.

Includes grammars for:

  • AMPscript — Marketing Cloud's proprietary scripting language
  • SSJS (Server-Side JavaScript) — JavaScript runtime with SFMC-specific globals and APIs

Usage

Node.js / Bundler

npm install highlightjs-sfmc highlight.js
import hljs from 'highlight.js';
import hljsAmpscript from 'highlightjs-sfmc/ampscript';
import hljsSsjs from 'highlightjs-sfmc/ssjs';

hljs.registerLanguage('ampscript', hljsAmpscript);
hljs.registerLanguage('ssjs', hljsSsjs);

hljs.highlightAll();

CDN / Static Website

<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/highlightjs-sfmc/dist/ampscript.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/highlightjs-sfmc/dist/ssjs.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/default.min.css" />

<script>
  hljs.highlightAll();
</script>

Then mark your code blocks with the appropriate language:

<pre><code class="language-ampscript">
%%[
SET @name = "World"
Output(Concat("Hello, ", @name))
]%%
</code></pre>

<pre><code class="language-ssjs">
Platform.Load("core", "1");
var rows = DataExtension.Init("MyDE").Rows.Lookup(["Key"], ["value"]);
Write(Stringify(rows));
</code></pre>

What Gets Highlighted

AMPscript

| Element | Examples | Scope | |---|---|---| | Block delimiters | %%[ ]%% | meta | | Inline delimiters | %%= =%% | meta | | Keywords | VAR SET IF THEN ELSE ENDIF FOR NEXT | keyword | | Built-in functions | Lookup ContentBlockByKey Output Concat | built_in | | User variables | @firstName | variable | | System variables | @@ExecCtx | variable.language | | Personalization | %%Name%% | variable.language | | Strings | "hello" 'world' | string | | Numbers | 42 3.14 | number | | Comments | /* block comment */ | comment | | Operators | == != AND OR NOT | keyword / operator |

SSJS

Extends JavaScript highlighting with SFMC-specific additions:

| Element | Examples | Scope | |---|---|---| | SFMC globals | Platform DataExtension WSProxy HTTP | built_in | | SFMC functions | Write Stringify ContentBlockByKey | built_in | | Platform API | Platform.Function.* Platform.Response.* | built_in | | Script.Util | Script.Util.WSProxy Script.Util.HttpRequest | built_in | | Core methods | .Init() .Retrieve() .Add() | title.function.invoke |

All standard JavaScript syntax (variables, control flow, strings, etc.) is highlighted by the built-in JavaScript grammar.

Testing with Highlight.js Core

To test this plugin against the Highlight.js test suite, clone the highlight.js repo and link this package into its extra/ directory. Run the commands from the parent folder that contains both highlight.js (the clone) and highlightjs-sfmc.

Bash / macOS / Linux (symbolic link):

git clone --depth 1 https://github.com/highlightjs/highlight.js.git
cd highlight.js
mkdir -p extra
ln -s ../highlightjs-sfmc extra/highlightjs-sfmc
node ./tools/build.js -t node
npm test

Windows PowerShell (directory junction; usually works without elevated rights):

git clone --depth 1 https://github.com/highlightjs/highlight.js.git
Set-Location highlight.js
New-Item -ItemType Directory -Force -Path extra | Out-Null
New-Item -ItemType Junction -Path "extra\highlightjs-sfmc" -Target (Resolve-Path "..\highlightjs-sfmc")
node .\tools\build.js -t node
npm test

If Resolve-Path fails, adjust -Target to the absolute path of your highlightjs-sfmc checkout. You can use a symbolic link instead (New-Item -ItemType SymbolicLink) if your Windows version and policy allow it (often requires an elevated shell or Developer Mode).

License

MIT