From: Yuri T. <yu...@cs...> - 2008-01-01 01:30:54
|
On Dec 31, 2007 10:49 AM, Waylan Limberg <wa...@gm...> wrote: > Well, the proper way would be to write your own pre-processor that > strips out all the mako markup and adds it to the htmlstash. That is, > after all, how html is currently ignored (in HtmlBlockPreprocessor - > line 486). > > With only a quick look, my guess is that the problem stems from the > fact that python-markdown has a very limited understanding of xml. > Therefore, the `%`s are throwing it off. In fact, if you try your > given test case without the `%` it works fine: First, for the record, <%foo /> doesn't count as XML. Second, yes, the _right_ way to do this is to write a custom preprocessor. However, my intension was to support this, so I suppose this is a bug. Let me explain how it is _supposed_ to work: When the script encounters an HTML tag in the beginning of the block, it classifies the tag into three types: 1. Tags that open an HTML block, such as <table> or <pre>. In this case, there will be no markdown processing until the block is closed with the same tag. There will also be no "<p>..</p>" around this chunk of html. 2. Tags like <div> or <?php>. In this case we don't look for the closing tag, but we also avoid putting <p>...</p> around the block. 3. Inline tags. We don't look for where the tag closes and we put <p>...</p> around the block. #2 is supposed to include "div", as well as any tags starting with "%", "?". The rationale is that for something like <?php> or <%foo> we don't really know what that tag means and we don't want to make any assumption as to whether it needs to be closed _or_ whether it needs <p> around it. If you want "<p>" around your <%foo/>, you can put it manually, after all, but you won't be able to remove it easily if we add it. So, "%foo" and "foo" are supposed to be treated differently. "<foo>**bar**" should become "<p><foo><b>bar</b><p>" while "<%foo>**bar**" is supposed to become as "<%foo><b>bar</b>" It obviously doesn't work that way. I think that the bug is either _get_right_tag() or _equal_tag(). The quick fix is to change line 499 to if left_tag in ['div'] or left_tag[0] in ["?", "@", "%"]: # handle PHP, etc. Though, at some point, the whole HTML_Block_Preprocessor logic needs to be rethought. It seems more convoluted than it needs to be. I hope this helps. - yuri -- http://sputnik.freewisdom.org/ |