~ubuntu-branches/ubuntu/vivid/python-docutils/vivid

« back to all changes in this revision

Viewing changes to docutils/utils/smartquotes.py

  • Committer: Package Import Robot
  • Author(s): Michael Schutte, Michael Schutte, Dmitry Shachnev
  • Date: 2013-09-09 22:58:50 UTC
  • mfrom: (11.1.9 experimental)
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: package-import@ubuntu.com-20130909225850-61mgyuamzo0zb6pj
[ Michael Schutte ]
* Upload to unstable.
* Document in the patch header that #714313 is also taken care of by
  odt-writer-ascii-filenames.diff.

[ Dmitry Shachnev ]
* Updated rst2odt_prepstyles-elementtree.diff to make it not cause
  SyntaxErrors with Python 3.
* Fix autopkgtest failures:
  - Copy HISTORY.txt to the testing directory.
  - Disable test_html4css1_misc as it does not work with our location
    of html4css1.css.
* docutils.xml: fix codes of Chinese languages (thanks Jakub Wilk),
  and add Hungarian language.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
 
# -*- coding: utf8 -*-
 
2
# -*- coding: utf-8 -*-
3
3
 
4
 
# :Id: $Id: smartquotes.py 7544 2012-12-12 22:04:49Z milde $
 
4
# :Id: $Id: smartquotes.py 7668 2013-06-04 12:46:30Z milde $
5
5
# :Copyright: © 2010 Günter Milde,
6
6
#             original `SmartyPants`_: © 2003 John Gruber
7
7
#             smartypants.py:          © 2004, 2007 Chad Miller
382
382
    # For other languages see:
383
383
    # http://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks
384
384
    # http://de.wikipedia.org/wiki/Anf%C3%BChrungszeichen#Andere_Sprachen
385
 
    quotes = {'af':        u'“”‘’',
 
385
    quotes = {'af':           u'“”‘’',
386
386
              'af-x-altquot': u'„”‚’',
387
387
              'ca':           u'«»“”',
388
388
              'ca-x-altquot': u'“”‘’',
390
390
              'cs-x-altquot': u'»«›‹',
391
391
              'de':           u'„“‚‘',
392
392
              'de-x-altquot': u'»«›‹',
393
 
              'de-ch':        u'«»‹›',
 
393
              'de-CH':        u'«»‹›',
394
394
              'el':           u'«»“”',
395
395
              'en':           u'“”‘’',
396
396
              'en-UK':        u'‘’“”',
397
397
              'eo':           u'“”‘’',
398
398
              'es':           u'«»“”',
 
399
              'et':           u'„“‚‘', # no secondary quote listed in
 
400
              'et-x-altquot': u'»«›‹', # the sources above (wikipedia.org)
 
401
              'eu':           u'«»‹›',
399
402
              'es-x-altquot': u'“”‘’',
400
403
              'fi':           u'””’’',
401
404
              'fi-x-altquot': u'»»’’',
402
405
              'fr':           (u'« ',  u' »', u'‹ ', u' ›'), # with narrow no-break space
403
406
              'fr-x-altquot': u'«»‹›', # for use with manually set spaces
404
407
              # 'fr-x-altquot': (u'“ ',  u' ”', u'‘ ', u' ’'), # rarely used
405
 
              'fr-ch':        u'«»‹›',
 
408
              'fr-CH':        u'«»‹›',
 
409
              'gl':           u'«»“”',
406
410
              'he':           u'”“»«',
407
411
              'he-x-altquot': u'„”‚’',
408
412
              'it':           u'«»“”',
409
 
              'it-ch':        u'«»‹›',
 
413
              'it-CH':        u'«»‹›',
410
414
              'it-x-altquot': u'“”‘’',
411
415
              'ja':           u'「」『』',
412
416
              'lt':           u'„“‚‘',
415
419
              'pl':           u'„”«»',
416
420
              'pl-x-altquot': u'«»“”',
417
421
              'pt':           u'«»“”',
418
 
              'pt_br':        u'“”‘’',
 
422
              'pt-BR':        u'“”‘’',
419
423
              'ro':           u'„”«»',
420
424
              'ro-x-altquot': u'«»„”',
421
425
              'ru':           u'«»„“',
423
427
              'sk-x-altquot': u'»«›‹',
424
428
              'sv':           u'„“‚‘',
425
429
              'sv-x-altquot': u'»«›‹',
426
 
              'zh_cn':        u'“”‘’',
 
430
              'zh-CN':        u'“”‘’',
427
431
              'it':           u'«»“”',
428
 
              'zh_tw':        u'「」『』',
 
432
              'zh-TW':        u'「」『』',
429
433
             }
430
434
 
431
435
    def __init__(self, language='en'):
507
511
 
508
512
    for (ttype, text) in text_tokens:
509
513
 
510
 
        # skip HTML and/or XML tags (do not update last character)
511
 
        if ttype == 'tag':
 
514
        # skip HTML and/or XML tags as well as emtpy text tokens
 
515
        # without updating the last character
 
516
        if ttype == 'tag' or not text:
512
517
            yield text
513
518
            continue
514
519
 
515
520
        # skip literal text (math, literal, raw, ...)
516
521
        if ttype == 'literal':
517
 
            prev_token_last_char = text[-1]
 
522
            prev_token_last_char = text[-1:]
518
523
            yield text
519
524
            continue
520
525