This is an archived static version of the original discussion site.

Inline phylogeny from Newick description


Having just typed something like (a,(b,(c,d))); into a phylobabble post it occurs to me it would be cool if that was automagically converted into a little picture of the corresponding tree. I’ve Javascript code that makes trees from Newick descriptions and outputs SVG, but I’ve no idea how easy it is to incorporate something like that into the Discource platform.


This would, of course, be lovely.

I did this for pubmed, and you can make whatever you want happen by extending onebox.

I don’t know Ruby, and bungled my way through with a little help. Let me know if you have questions.


Seems like there are a couple of ways you could go here.

You could probably do a server-side thing with ruby/onebox. In that case you might want to look at Newick-ruby (take a quick peek at the bottom of the page there). Unfortunately, that seems to only output PDF though, so you would probably have to call out to inkscape for SVG conversion.

Since you already have the javascript renderer though, it might be easier to take a note from the discourse-mathjax plugin. The code there looks pretty straight forward, so you might have better luck this way.


EDIT: Just remembered that onebox does render out to mustache/js templates, so you might be able to use that together with your js code, but it’s not clear that would be so straightforward. I’m guessing the route of the mathjax plugin might be a more natural fit.