From: Waylan L. <wa...@gm...> - 2008-09-05 21:29:18
|
On Fri, Sep 5, 2008 at 4:52 PM, Blake Winton <bw...@la...> wrote: > Waylan Limberg wrote: >> The problem is that CamelCase words that correctly appear in other >> parts of the markup are mistakenly being identified as wikilinks. >> >> In the past this was not a problem because any markup in the labels >> was ignored. Now that that bug is squished, I need a way to tell >> markdown to not run the WikiLink pattern against the label. There are >> currently two mechanisms to do that. One it to set each label as an >> AtomicString. However, then we would again be back were we were with >> nested markup being ignored in labels. > > Ooh, ooh! SemiAtomicString? ;) > >> The other solution is to reorder the InlinePatterns. > > I think that having patterns be order dependant isn't a great idea, in > general. > > Could the WikiLink pattern be made more context-sensitive somehow, > so that it wouldn't match if there it was inside a "Label"? > >> Interestingly, it >> occurred to me that if InlinePattern was passed the parent element, we >> could test ``parent_elem.tag != 'a'``, but even then, if that >> CamelCase word is nested in strong or em tags, that test would fail. >> Besides, I can't think of any other use for doing that. > > Well, if you could walk up your parents, you could check all of them for > an 'a' (and check whether you were an attribute). It seems like it > might be worth defining a couple of custom walkers, to handle cases > where we want to expand stuff, but only if it occurs in > non-link/non-attribute places. > This was my initial thought as well. I guess I left out the fact that ElementTree doesn't track parents of an Element - only children. Grrr. Although, the project website does offer some sample code [1] that can be used to walk the entire tree from root and generate a list of all parents of an element. Seemed like an awful lot of extra work just to check a parent - I'm sure we'd take a performance (and memory?) hit with it. [1]: http://effbot.org/zone/element.htm#accessing-parents -- ---- Waylan Limberg wa...@gm... |