On Jun 25, 11:33 am, chris.d...@gmail.com wrote:
> So there's no block to handle. So the first part of purpleater is to
> create blocks.

I've made some adjustments that improve the situation for me.
Basically what it does is look inside any current block resulting from
the first split to see if there are any <br> and if so, it splits
again and does some jiggery pokery. This works out okay with my typing
style (I don't use linefeeds within paragraphs and I generally have
two linefeeds between what I consider blocks.

This won't work for everyone because a fair few people do use
linefeeds inside paragraphs as well as not wanting double \n between
blocks.

This is the new version of the block creation:

        var wholething = $('#text-html.section');
        var el = jQuery("<div/>");
        var chunks = $('#text-html.section').html().split('<br><br>');
        $.map(chunks, function(chunk, i) {
            if (!chunk.match(/^<(?:h|ul|ol|dl|block)/)) {
                chunk = $("<p/>").html(chunk).appendTo(el);
            } else {
                if (chunk.indexOf('<br>') > 0) {
                    var innerChunks = chunk.split('<br>');
                    el.append(innerChunks.shift());
                    $.map(innerChunks, function(inner, i) {
                        inner = $("<p/>").html(inner).appendTo(el);
                    });
                } else {
                    el.append(chunk);
                }
            }
        });
        wholething.empty();
        el.children().appendTo(wholething);

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to tiddlywikidev@googlegroups.com.
To unsubscribe from this group, send email to 
tiddlywikidev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

Reply via email to