Closed mrjjwright closed 11 years ago
Great question! I had not even realized that CoffeeScript had its own variant of JSON. I had thought about this from a higher point when building this (i.e. Should I support any formatter (e.g. YAML, XML)?). The conclusion I came to at the time was it would introduce more complications than I had time for.
Side note: This repo is inspired by the formatting used in toto which itself is YAML.
Anyway, to answer your question -- if you were to fork/branch, it would be very easy (you just have to make sure CoffeeScript throws an error if it sees invalid JSON).
If we wanted to support for any formatter, we should probably start a new repo (for naming/semantics sake). It would be a constructor function Demuxer
with an addParser
property. Of course, this is my flavor of things (see spritesmith).
// Usage
var demuxer = new Demuxer({parser: 'coffee-json'});
demuxer.demux('coffee + content');
// data-content-demux
var parsers = {};
// options = {parser, delimiter}
function Demuxer(options) {}
Demuxer.prototype = {'demux': 'Separates data and content'};
funciton addParser(name, fn) { parsers[name] = fn; }
Demuxer.addParser = addParser;
addParser('json', JSON.parse);
// Tentative parsers
addParser('coffee-json', function () {});
addParser('yaml', function () {});
addParser('xml', function () {});
addParser('text', function () {});
// There could also be sugar logic inside of demuxer which acts as a string -> JSON + content demuxer.
Closing issue due to inactivity. I will conclude that a cson-content-demux
as a separate project would be the best idea as it leads to a clutter-free test suite for each markup flavor.
How hard would it be for me to attempt adding coffee-script support? I want my clients to be able to edit their products in a markdown file and for the properties I would love to use straight JSON but don't want all the bracket cruft.