View Single Post
Old 03-09-2012, 07:54 AM   #9
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,669
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Last time I checked though Smartypants didn't change three dots in a row, e.g. '...'.
Of course it's fully configurable and you can tell it not to convert three consecutive periods to an epllipse if you want, but its default behavior to do so. The two regex patterns it looks for in it's EducateEllipses function is:
\.\.\. and \. \. \.

Spoiler:
Code:
def educateEllipses(str):
	"""
	Parameter:  String.
	Returns:    The string, with each instance of "..." translated to
	            an ellipsis HTML entity.

	Example input:  Huh...?
	Example output: Huh…?
	"""

	str = re.sub(r"""\.\.\.""", r"""& #8230;""", str)
	str = re.sub(r"""\. \. \.""", r"""& #8230;""", str)
	return str
Spaces after the "&" added by me so the html entity didn't get eaten by the forum software .


Quote:
edit - it's possible you're agreeing with me, but we got mixed up on where the smartypants vs smarten_punctuation code is.
That appears to be the case

To be perfectly honest... those last lines of calibre code you linked to have always confused me. SmartyPants already converted '...' and '. . .' to the ellipse html entity... so I'm not sure why it's being done again before doing the substitute_entity call. And the first -- replacement is being done to preserve any html comments, but it seems as if the final "--" substitution would undo all that.

EDIT: never mind that last part about the -- replacement. That appears to be catching any '--' that has a space on either side of it, which would exclude the html comments... but I'm still convinced it's not going to find any occurrances of ' -- ' after the SmartyPants default call.

Last edited by DiapDealer; 03-09-2012 at 08:34 AM.
DiapDealer is offline   Reply With Quote