somehow-script
v1.1.0
Published
<div align="center"> <div>somehow-script</div> <img src="https://cloud.githubusercontent.com/assets/399657/23590290/ede73772-01aa-11e7-8915-181ef21027bc.png" /> <div><a href="https://spencermounta.in/somehow-script/">demo</a></div> <a href="https:
Downloads
7
Readme
this is a work-in-progress markup format for creating metadata in text.
It is inspired by a good number of similar projects:
- pugjs - period-based control-chars
- margin - flexible use of
[ ]
chars - archieml - interchangable
=
and:
- TOML - typing of booleans+dates
- literate coffeescript - encourage freehand text
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