zedapp / zed

Rethinking code editing.
http://zedapp.org
MIT License
2.22k stars 162 forks source link

preview post processing #284

Open maninalift opened 10 years ago

maninalift commented 10 years ago

As I'm messing with the workings of preview I have a question for anyone who wants to give their input:

If some mode (e.g. coffeescript) provides a preview option that outputs something (e.g. javascript) that is best passed through some other filter (e.g. syntax highlighting), how should that be handled.

Should it:

  1. Let preview handle it preview(my_javascript, {type:"javascript"}), or
  2. Handle it itself and just pass html to preview preview(markItUp(my_javascript))

(code is illustrative, not syntactically correct).

zefhemel commented 10 years ago

Interesting question. My first intuition was "just pass HTML", but there are good arguments for the other approach too. Actually maybe I prefer letting the preview module handle the formatting base on some meta data (e.g. "This is JavaScript"). The question is: how do you make this extensible?— Zef

Sent from my iPhone

On Sat, Apr 12, 2014 at 2:53 PM, maninalift notifications@github.com wrote:

As I'm messing with the workings of preview I have a question for anyone who wants to give their input: If some mode (e.g. coffeescript) provides a preview option that outputs something (e.g. javascript) that is best passed through some other filter (e.g. syntax highlighting), how should that be handled. Should it:

  1. Let preview handle it preview(my_javascript, {type:"javascript"}), or
  2. Handle it itself and just pass html to preview preview(markItUp(my_javascript)) (code is illustrative, not syntactically correct).

    Reply to this email directly or view it on GitHub: https://github.com/zedapp/zed/issues/284

maninalift commented 10 years ago

Extensibility

Create another handler type, say "visualiser" which takes text any JSON object (the preview might be for a table of values or a tree-structure).

If no visualiser is found for the given preview type the data could just be stringified, have angle brackets replaced and stuck between pre-tags.

zefhemel commented 10 years ago

Yeah that sounds good, but that can be added later. Let's for now just use the preview.js module handle formatting.