From: Eric A. <er...@er...> - 2019-09-30 21:05:29
|
On 09/30/19 13:32 PM, Eric Abrahamsen wrote: > Hi all, > > I run a Django site about Chinese literature, and so have some special > processors in the Markdown instance we use to process all blog posts and > longer text fields. We're using markdown 3.1.1. Two of these processors > are fighting with each other. > > One of them detects runs of Chinese characters in text, and wraps them > in <span class="char"> tags so they can be targeted for various things. > > The other provides very limited wiki-style links to other objects in our > database. For instance, if you want to create a link to an author's > page, you'd write [a:Ernest Hemingway]. The processor looks that up in > the database and adds an anchor tag with the appropriate href. > > If I try to add a link to a Chinese author with eg [a:余华], both > processors fire, and we get weird behavior. > > What I'd like to see is: > > <a href="/authors/yu-hua/"><span class="char">余华</span></a> > > Instead, what I get depends on which processor is registered with higher > priority (all the relevant code is pasted below). If the span-char > processor is registered first, then the link processor receives the > "klzzwxh:0000" placeholder instead of the author name, and thus can't > look up the link. If the link processor is registered first, then the > span-char processor is run twice, and the author name is wrapped in two > sets of span tags. And of course I immediately found the answer after posting: to have the span-char processor return the Chinese characters wrapped in AtomicString, so they never get processed again. Sorry for the noise. Eric |