I finally got round to working on IncludeMacro.
Attached proposal code for IncludeMacro supports:
- intertrac support (also requested in ticket:1196 )
- support of actual inclusion of remote html pages, with conversion of relative or server-local absolute links to full absolute links (fixes ticket:3979).
- the possibility to select part of the included html result by using a genshi transformer xpath expression
- if installed, BeautifulSoup? will be used to clean up messy included html. This is regularly the case for external html, but it also often happens that Trac macros/plugins break Trac's xhtml-validity.
This should also fix ticket:2474 (non-standard http port).
Regarding the 2nd point: The actual inclusion of remote sources is not possible in the original IncludeMacro, only html snippets can be used (unless render_unsafe_content is set to true).
My version therefore changes the HTMLSanitizer instantiation to
which allows inclusion of "full" external html. Without allowing html & body, no (x)html documents will ever be rendered if render_unsafe_content is off, only (x)html snippets. Does it hurt to allow body to be parsed? I don't think so, as already non xhtml-valid inclusion may render due to the parser not yielding events in document order. All offensive stuff inside body will be filtered out nonetheless.
I'm attaching this as a full source file as the changes to the original source are by now quite significant.
I'd love to see getting these capabilities into the official IncludeMacro. Let me know if I can help.