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-daml

v1.0.1

Published

Highlight.js syntax definition for the DAML language

Readme

highlightjs-daml

npm version CI License: MIT

A Highlight.js language plugin that adds rich syntax highlighting for DAML — the smart contract language developed by Digital Asset for building multi-party workflows on distributed ledgers.


Features

  • Full keyword coverage: template, choice, interface, signatory, observer, controller, with, where, do, and all standard Haskell-style keywords
  • Template, interface, and exception declarations with class name highlighting
  • Choice declarations highlighted as function titles
  • Module and import directives highlighted as meta
  • DAML/Haskell pragmas ({-# OPTIONS_GHC … #-})
  • Built-in types and functions: Party, ContractId, Text, Decimal, create, exercise, fetch, archive, and more
  • Literals: True, False, None, Some
  • Haskell-style line (--) and block ({- … -}) comments
  • Numeric literals with underscore separators (1_000_000)
  • Haskell-style character literals ('a', '\n')
  • Type names highlighted as type
  • Infix operators in backticks (`elem`)
  • Standard and Haskell-specific operators (->, <-, =>, ::, \, …)
  • Correct auto-detection: DAML templates reliably identified via highlightAuto

Installation

npm install highlightjs-daml

highlight.js ≥ 11 is a peer dependency — install it separately if you haven't already:

npm install highlight.js

Usage

CommonJS / Node.js

const hljs = require("highlight.js");
const daml = require("highlightjs-daml");

hljs.registerLanguage("daml", daml.default ?? daml);

const code = `
template Iou
  with
    issuer : Party
    owner  : Party
    amount : Decimal
  where
    signatory issuer
    observer owner

    choice Transfer : ContractId Iou
      with newOwner : Party
      controller owner
      do
        create this with owner = newOwner
`.trim();

const html = hljs.highlight(code, { language: "daml" }).value;
console.log(html);

ES Modules

import hljs from "highlight.js";
import daml from "highlightjs-daml";

hljs.registerLanguage("daml", daml);

const result = hljs.highlight(code, { language: "daml" });

Browser (CDN)

Load Highlight.js first, then load this plugin:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/styles/github-dark.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.10.0/highlight.min.js"></script>
<!-- highlightjs-daml -->
<script src="https://unpkg.com/highlightjs-daml/dist/index.js"></script>
<script>
  hljs.registerLanguage("daml", window.hljsDaml?.default ?? window.hljsDaml);
  hljs.highlightAll();
</script>

Then mark up your code blocks:

<pre><code class="language-daml">
template Asset
  with
    issuer : Party
    owner  : Party
    name   : Text
  where
    signatory issuer
    observer owner

    choice Give : ContractId Asset
      with newOwner : Party
      controller owner
      do create this with owner = newOwner
</code></pre>

Auto-detection

The plugin registers DAML with high-relevance rules on template/choice/signatory constructs so highlightAuto correctly identifies DAML source files:

const result = hljs.highlightAuto(unknownCode);
console.log(result.language); // "daml"

Supported syntax elements

| Element | Highlight class | |---------|----------------| | module, import | hljs-meta | | Pragmas {-# … #-} | hljs-meta | | Keywords (template, choice, signatory, …) | hljs-keyword | | Template / exception / data names | hljs-title class_ | | Choice names | hljs-title function_ | | Built-in types and functions | hljs-built_in | | Type names (uppercase identifiers) | hljs-type | | Literals (True, False, None, Some) | hljs-literal | | String literals | hljs-string | | Character literals | hljs-string | | Numeric literals | hljs-number | | Operators (->, <-, ::, =>, …) | hljs-operator | | Infix in backticks | hljs-operator | | Comments (--, {- … -}) | hljs-comment |


Example

module Finance where

import DA.List (sortOn)

template Iou
  with
    issuer : Party
    owner  : Party
    amount : Decimal
    currency : Text
  where
    signatory issuer
    observer owner

    ensure amount > 0.0

    choice Transfer : ContractId Iou
      with newOwner : Party
      controller owner
      do
        create this with owner = newOwner

    choice Settle : ()
      controller owner
      do
        archive self

interface Token where
  viewtype TokenView
  getOwner : Party
  getAmount : Decimal

Compatibility

| highlight.js | highlightjs-daml | |--------------|-----------------| | ≥ 11.0.0 | ✓ |


License

MIT © ABDK Consulting