On Wed, Nov 6, 2013 at 6:50 AM, Brian Theado <[email protected]> wrote:
> > > No I'm not working on it right now. I hadn't thought of @html node body > text. For standalone html it should work to put the css in a style tag in > the html head section. Is that what you tried? > Yes. I probably made a simple mistake: the code doesn't work on the w3schools trial pages either. Here is the @button node that I have. It looks for a node whose headline is '@html display', pastes the html into it and selects it. Alt-0 will render it. BTW, it uses local files (file://) urls, and so should be faster. Ctrl-clicking brings up the expected icons, so that doesn't seem to be the problem. Do you see anything the matter with the css or html? Finally, the @button doesn't do a proper job of nesting. I'll get that right next. ====== <?xml version="1.0" encoding="utf-8"?> <!-- Created by Leo (http://leoeditor.com/leo_toc.html) --> <?xml-stylesheet ekr_test?> <leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" > <leo_header file_format="2"/> <vnodes> <v t="ekr.20131106061011.2581"><vh>@button display css</vh> <v t="ekr.20131106061011.2582"><vh>define css</vh></v> <v t="ekr.20131106061011.2583"><vh>escapeHtml</vh></v> <v t="ekr.20131106061011.2584"><vh>headlineToHtml</vh></v> </v> </vnodes> <tnodes> <t tx="ekr.20131106061011.2581"># Displays both the css and the html to the log pane. Supports all 16 icon boxes: @language python icons = g.os_path_finalize_join(g.app.loadDir,'..','Icons') assert g.os_path_exists(icons) @others tag = '@html display' p = g.findNodeAnywhere(c,tag) if p: result = [ '<html>', '<head>','<style>',basecss,boxcss,'</style>','</head>', '<body>','<ul class="leo-tree-example">', ] for p2 in p.self_and_subtree(): result.append(headlineToHtml(p2)) result.extend(['</ul>','</body>','</html>',]) p.b = '\n'.join(result) c.selectPosition(p) c.redraw() else: g.es('not found: %s' % tag) </t> <t tx="ekr.20131106061011.2582">basecss = r''' ul.leo-tree-example { background-color: #ffffec; } ul.leo-tree-example li { background-repeat: no-repeat; background-position: 0px 5px; padding-left: 27px; } li.selected { background-color: lightgrey; } li.plus { list-style-image: url('file://%s/plusnode.gif'); } li.minus { list-style-image: url('file://%sminusnode.gif'); } li.leaf { list-style-type: none; }''' boxcss = ''.join([r''' li.iconbox%02d { background-image: url('file://%s/box%02d.GIF'); }''' % (n,icons,n) for n in range(16) ]) </t> <t tx="ekr.20131106061011.2583">def escapeHtml(s): return s.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;') </t> <t tx="ekr.20131106061011.2584">def headlineToHtml(p): ''' Returns html representation (unordered list) of the visible portions of the subtree rooted at position p. CSS classes corresponding to the expansion state and icon box are included in each list item. Combined with the proper CSS, the result can be made to look similar to leo's tree pane. ''' classes = [] if p.isExpanded(): classes += ['minus'] elif p.hasChildren(): classes += ['plus'] else: classes += ['leaf'] classes += ['iconbox%02d' % p.computeIcon()] html = "<li class='%s'>\n" % " ".join(classes) html += escapeHtml(p.h) html += "\n</li>\n" if p.isExpanded() and p.hasChildren(): html += "<ul>\n" for child in p.children(): html += headlineToHtml(child) html += "\n</ul>\n" return html</t> </tnodes> </leo_file> ===== Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
