textile / python-textile

A Python port of Textile, A humane web text generator
Other
68 stars 23 forks source link

"caps" are not replaced correctly #18

Closed kevinmgrant closed 8 years ago

kevinmgrant commented 9 years ago

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.

hhsprings commented 8 years ago

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.

ikirudennis commented 8 years ago

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.

appli-intramuros commented 5 years ago

How can we disable the fact that caps are replaced by a span ?

ikirudennis commented 5 years ago

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.

appli-intramuros commented 4 years ago

@ikirudennis it works perfectly. Thanks !