somehow-script

1.1.0 • Public • Published
somehow-script

this is a work-in-progress markup format for creating metadata in text.

It is inspired by a good number of similar projects:

Usage

npm i somehow-script

const smh = require('./src')

let text = `in the town where I was born
there lived a man, who sailed the seas.

the simplest tag is a word that begins with a period:
.film

square-brackets allow adding key-value data to the tag
.film[name: Interview with a Vampire]

somehow-script automatically parses dates+times
.film[release=July 1992]

can add multiple properties at once
.film[release=July 1992, budget=12m]

automatically parses lists
.film[actors=Brad Pitt, Tom Cruise]
`
console.log(smh(text))
/*
{
  data: [
    { name: 'film', props: {}, text: '.film', offset: 124, len: 5 },
    {
      name: 'film',
      props: { name: 'Interview with a Vampire' },
      text: '.film[name: Interview with a Vampire]',
      offset: 186,
      len: 37
    },
    ...
  ]
}
*/

// remove all annotations
console.log(smh.strip(text))
// wrap annotations in generic span tags
console.log(smh.html(text))

Goals

  • create folk-style triplets (without being too-semantic-web)
  • rarely collide with natural text (few false positives)
    • avoid collisions with markdown.
    • avoid collisions with hashtags/atmentions/email/emoticons
  • easy creation on mobile keyboards
  • allow chaining
  • support parsing of natural-language dates (via spacetime)
  • parsing of natural-language numbers (via compromise-tokenize, compromise-numbers)
  • wysiwyg via code/prose-mirror

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i somehow-script

Weekly Downloads

3

Version

1.1.0

License

none

Unpacked Size

883 kB

Total Files

22

Last publish

Collaborators

  • spencermountain