"caps" are not replaced correctly
kevinmgrant opened this issue · 5 comments
The last version I used was PyTextile 2.1.4, which did not try to replace caps. Now in version 2.2.2, unexpected HTML conversions occur for text that contains capital letters.
For example, the text "CFString
" in a textile file becomes "<span class="caps">CFS</span>tring
" in HTML, and "TCP/IP
" becomes "<span class="caps">TCP</span>/IP
".
My preference is to have a way to disable this substitution entirely because it is not necessary. Still, the regular expressions could be improved by scanning text beyond an all-caps range; for instance, require all-caps ranges to be immediately followed by spaces or punctuation, and certainly not lowercase letters.
It seems redcloth has the same problem for the latter case (TCP/IP
). I also believe this case must be render as <span class="caps">TCP/IP</span>
(and of cource CFString
must not be recognized as caps). But neither redcloth spec nor textile-spec don't explain these behaviours well.
Yeah, I see this as more of a problem for the spec than it is a problem with this project's implementation. I'd rather keep this consistent with the official version even if it is obviously wrong here.
How can we disable the fact that caps are replaced by a span ?
That's pretty easy to accomplish (if not immediately obvious):
no_span = textile.Textile()
no_span.glyph_replace[-1] = r'\1{0}:glyph:\2\3'.format(no_span.uid)
no_span.parse('text TEXT text')
That ought to output '\t<p>text TEXT text</p>'
. I hope that helps.
@ikirudennis it works perfectly. Thanks !