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 🙏

© 2024 – Pkg Stats / Ryan Hefner

caml-mkdn

v0.0.2

Published

Colon Attribute Markup Lanugage -- a YAML-like markup syntax for (semantic) attributes in markdown.

Downloads

22

Readme

caml-mkdn

A WikiBonsai Project NPM package

CAML is a Colon Attribute Markup Language similar to YAML with some key differences:

  • Slims down the syntax by removing the need for separators (---).
  • Can be sprinkled throughout a markdown file (similar to markdown footnotes).
  • Focuses on single level sequence collections (e.g. does not support object values, just arrays).
  • Supports [[wikiref]] values.
  • Can be rendered as a wikipedia-style infobox alongside the rest of your markdown.
  • Supports markdown inside of strings.

🕸 Weave a semantic web in your 🎋 WikiBonsai digital garden.

TODO:

  • Attribute types may be intermingled, except for [[wikirefs]]; e.g. :key::string,1 will work but :key::string,[[wikiref]] will not.
  • Ordered list values.

Install

Install with npm:

npm install caml-mkdn

Use

import * as caml from 'caml-mkdn';

let text = `
:key::value
:another-key::val1,val2,val3
:yet-another-key::
- 1
- 2
- 3

And some content!
`;
let payload = caml.load(text);

console.log(payload.data);
// should produce:
// {
//    key: 'value',
//    another-key: ['val1', 'val2', 'val3'],
//    yet-another-key: [1, 2, 3],
//  }

console.log(payload.content);
// should produce:
// 'And some content!'

Note: To use commas (,) inside of singular caml string value, make sure to surround the value with single or double quotes ('', "") so that the comma is not used to create a list value. Commas inside of list string values is not (yet) supported.

API

dump(attrs: any, opts?: DumpOpts): string

Serializes object as a CAML document. Similar to js-yaml's dump().

Options

format: 'pretty' | 'pad' | 'none'

The format CAML attributes should be printed in. Choices are 'pretty', 'pad', and 'none':

  • 'none': Will just dump the text with no added whitespace.
    • ex:
    :this-is-a-really-long-key::value
    :short-key:: value
    :comma-list::1,2,3
    :mkdn-list::
    - 1
    - 2
    - 3
  • 'pad': Will pad with a single whitespace around text and special chars.
    • ex:
    : this-is-a-really-long-key :: value
    : short-key :: value
    : comma-list :: 1, 2, 3
    : mkdn-list ::
    - 1
    - 2
    - 3
  • 'pretty': Will pad as well as determine the longest key length and pad all other keys with the same amount of spaces to achieve a "pretty" print feel.
    • ex:
    : this-is-a-really-long-key :: value
    : short-key                 :: value
    : comma-list                :: 1, 2, 3
    : mkdn-list                 ::
                                   - 1
                                   - 2
                                   - 3
listFormat: 'comma' | 'mkdn'

Dump CAML attribute lists by comma-separation or mkdn-list-separation.

  • comma-separated:
    : comma-list :: 1, 2, 3
  • Mkdn-separation:
      : mkdn-list ::
      - 1
      - 2
      - 3
prefix: boolean;

Whether or not to use the colon : prefix when dumping CAML attributes.

  • With:
    : key :: value
  • Without:
    key :: value

load(content: string): CamlLoadPayload

Load a content string, parse CAML attributes, and store attributes in data and the rest of the content string in content. Similar to graymatter.

resolve(value: string): CamlValData

Take a CAML attribute value as a string, parse it, and return CamlValData, which looks like:

interface CamlValData {
  type: string;   // a string description of the value's type
  string: string; // a string representation of the value
  value: null     // the literal parsed value
  | boolean
  | number
  | bigint
  | Date
  | string;
}

scan(content: string): (CamlScanResKey | CamlScanResVal)[]

Scan a given content string and return an array of descriptions of all valid CAML attributes constructs.

Result formats:

// caml attribute key
interface ScanResCamlKey {
  key: [string, number];
}
// caml attribute value
interface ScanResCamlVal {
  type: string;
  val: [string, number];
}