🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

highlightjs-sfmc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

highlightjs-sfmc

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

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

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

ElementExamplesScope
Block delimiters%%[ ]%%meta
Inline delimiters%%= =%%meta
KeywordsVAR SET IF THEN ELSE ENDIF FOR NEXTkeyword
Built-in functionsLookup ContentBlockByKey Output Concatbuilt_in
User variables@firstNamevariable
System variables@@ExecCtxvariable.language
Personalization%%Name%%variable.language
Strings"hello" 'world'string
Numbers42 3.14number
Comments/* block comment */comment
Operators== != AND OR NOTkeyword / operator

SSJS

Extends JavaScript highlighting with SFMC-specific additions:

ElementExamplesScope
SFMC globalsPlatform DataExtension WSProxy HTTPbuilt_in
SFMC functionsWrite Stringify ContentBlockByKeybuilt_in
Platform APIPlatform.Function.* Platform.Response.*built_in
Script.UtilScript.Util.WSProxy Script.Util.HttpRequestbuilt_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

Keywords

AMPscript

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts