text nodes, wiki_formatting, printers, images and equations

0 views
Skip to first unread message

James Casbon

unread,
Jan 17, 2010, 3:56:26 PM1/17/10
to codenod...@googlegroups.com
Hi,

I've been thinking about the way the text nodes are handled.
Currently, you can choose the type of a node with the mouse and the
whole cell will change. My own preference is for some kind of wysiwym
formatting (preferabaly markdown) for text cells along with a client
side rendering of the text. What I would really like is something
like this - http://wmd-editor.com/examples/splitscreen - but instead
of separate panes, the text nodes would show the rendered text (right
hand pane in the example), until you clicked into them when they would
show an editor (as in the left hand pane).

This raises a number of questions:

1. Is there any plan to handle equations in text nodes? I saw Alex's
email about jsmath fonts, but I am not clear if that has been decided
as the way to go. I think this is an interesting page relating to
this - http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html .

2. Do you plan to stick with nodes of different text types? This
seems to be the hardest way to go in that the database has to know all
the different text types rather than just store a blob of text that is
handle by the client (or printers).

3. What is the status with the printers? The latex printer is
interesting here because there are already routes from markdown to
latex: http://johnmacfarlane.net/pandoc/ . Another issue here is that
the backend payloads discussed before need to know how to be printed
by any given printer.

Unfortunately, I doubt very much we can find a javascript
implementation that would convert a markdown + asciimath without some
work. Would it be possible to hack this
http://attacklab.net/showdown/ to include asciimath?

James

Alex Clemesha

unread,
Jan 18, 2010, 9:58:32 PM1/18/10
to codenod...@googlegroups.com
On Sun, Jan 17, 2010 at 12:56 PM, James Casbon <cas...@gmail.com> wrote:
> Hi,
>
> I've been thinking about the way the text nodes are handled.
> Currently, you can choose the type of a node with the mouse and the
> whole cell will change.  My own preference is for some kind of wysiwym
> formatting (preferabaly markdown) for text cells along with a client
> side rendering of the text.  What I would really like is something
> like this - http://wmd-editor.com/examples/splitscreen - but instead
> of separate panes, the text nodes would show the rendered text (right
> hand pane in the example), until you clicked into them when they would
> show an editor (as in the left hand pane).

This would be very useful, and just the minimum of this type of functionality
would be better that we have now (aka none).


>
> This raises a number of questions:
>
> 1. Is there any plan to handle equations in text nodes?  I saw Alex's
> email about jsmath fonts, but I am not clear if that has been decided
> as the way to go.

I like jsmath and I really think it would be great it we could support it.
It works very well for Sage from everything I've heard. (I seem to
remember that there is even a newer project by the same jsmath people,
it was announced on the Sage mailing list... I can't remember exactly
what it was though).

 I think this is an interesting page relating to
> this - http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html .
>
> 2. Do you plan to stick with nodes of different text types?  This
> seems to be the hardest way to go in that the database has to know all
> the different text types rather than just store a blob of text that is
> handle by the client (or printers).

The database doesn't really know of any specific types. The "Cell"
model has 3 fields:

style = models.TextField()
type = models.CharField(max_length=100)
props = models.TextField()

and between all those you can pretty much have any sort of Cell type imaginable.
I feel this is pretty good for now, unless an there's an easy
fix/improvement on the whole thing.


>
> 3. What is the status with the printers?  The latex printer is
> interesting here because there are already routes from markdown to
> latex: http://johnmacfarlane.net/pandoc/ .  Another issue here is that
> the backend payloads discussed before need to know how to be printed
> by any given printer.

The "printers" (probably should be renamed "Save as" or some such - at
least up front) need
a little TLC to get back in action - even the minimum would do.
Pandoc does look very nice, I wonder if it would be "easy" to add that
functionality
in - seems like it might be a pretty big win.


-Alex


>
> Unfortunately, I doubt very much we can find a javascript
> implementation that would convert a markdown + asciimath without some
> work.  Would it be possible to hack this
> http://attacklab.net/showdown/ to include asciimath?
>
> James
>

> --
> http://groups.google.com/group/codenode-devel?hl=en
> http://codenode.org
>

--
Alex Clemesha
clemesha.org

James Casbon

unread,
Jan 19, 2010, 10:06:42 AM1/19/10
to codenod...@googlegroups.com
2010/1/19 Alex Clemesha <clem...@gmail.com>:

> On Sun, Jan 17, 2010 at 12:56 PM, James Casbon <cas...@gmail.com> wrote:
>> Hi,
>>
>> I've been thinking about the way the text nodes are handled.
>> Currently, you can choose the type of a node with the mouse and the
>> whole cell will change.  My own preference is for some kind of wysiwym
>> formatting (preferabaly markdown) for text cells along with a client
>> side rendering of the text.  What I would really like is something
>> like this - http://wmd-editor.com/examples/splitscreen - but instead
>> of separate panes, the text nodes would show the rendered text (right
>> hand pane in the example), until you clicked into them when they would
>> show an editor (as in the left hand pane).
>
> This would be very useful, and just the minimum of this type of functionality
> would be better that we have now (aka none).

I thought of a cool way of testing this: I can write a pandoc engine
that will render markdown :)

Of course, I need a way of returning html to the browser but that
should be easy enough.

Pandoc already supports inline latex :
http://johnmacfarlane.net/pandoc/README.html#math

James

James Casbon

unread,
Jan 19, 2010, 5:20:02 PM1/19/10
to codenod...@googlegroups.com
2010/1/19 James Casbon <cas...@gmail.com>:

>
> Of course, I need a way of returning html to the browser but that
> should be easy enough.
>


Ok, have this working, but I need some help with the javascript. At
the moment, the output cell's content is html but I need to know how
to 'eval' this html and attach it to the DOM tree.

Anyone here know how I can achieve this?

I can see this where it is set as the content:

Notebook.Cell.prototype.content = function(newcontent) {
if (!newcontent) {
...
} else {
...
if (this.celltype == 'output') {
switch (this.cellstyle) {
case 'outputtext':
var contentsplit = newcontent.split('\n');
var spancontent = $.map(contentsplit, function(n, i) {
return $.SPAN(null, n);
});
this.contentNode().childNodes[0].value = newcontent;
//$(this.contentNode().childNodes[0]).append(spancontent);
break;


But:

1. contentsplit and spancontent are not used?
2. how can I attach an actual html element and not just text?

thanks,
James

Reply all
Reply to author
Forward
0 new messages