CondeNast / atjson

atjson is a living content format for annotating content
https://atjson.condenast.io
Apache License 2.0
214 stars 13 forks source link

Experiment with converters as renderers #286

Open tim-evans opened 4 years ago

tim-evans commented 4 years ago

Conceptually, renderers are a more general case of converters, being essentially a function from a document to any type. With the idea from https://github.com/CondeNast/atjson/issues/285 of adding additional safeguards and guarantees around renderer implementations, writing converters as renderers could help ensure that the converter satisfies some useful properties such as handling all the possible annotations in the source document.

(Written by @colinarobinson ❤️)

tim-evans commented 4 years ago

This is an idea I had for this: https://gist.github.com/tim-evans/0893e956afc460cc53b9e0387d3e6ba3

I'm not sure how to extrapolate this code into a renderer, though...

colin-alexa commented 4 years ago

here's an approach at how the renderer version of this might look in a simple case: https://gist.github.com/colinarobinson/69027d2e48a056c3f145e67ad8587043