comparison curlers.py @ 10:397c178c5b98

Make it array-based.
author David Barts <n5jrn@me.com>
date Fri, 27 Dec 2019 11:26:00 -0800
parents 9df9ff8cecde
children b2dab0667ec2
comparison
equal deleted inserted replaced
9:84adbbb69a9d 10:397c178c5b98
4 # Classes for curling both HTML and plain text. 4 # Classes for curling both HTML and plain text.
5 5
6 # I m p o r t s 6 # I m p o r t s
7 7
8 import os, sys 8 import os, sys
9 from workspace import Workspace 9 from runes import Workspace
10 10
11 # V a r i a b l e s 11 # V a r i a b l e s
12 12
13 # Quote types 13 # Quote types, as rune values
14 LSQUO = "\u2018" 14 LSQUO = 0x2018
15 APOS = RSQUO = "\u2019" 15 APOS = RSQUO = 0x2019
16 LDQUO = "\u201C" 16 LDQUO = 0x201c
17 RDQUO = "\u201D" 17 RDQUO = 0x201d
18 18
19 # Words that start with an apostrophe. Cribbed from Wordpress. 19 # Words that start with an apostrophe. Cribbed from Wordpress.
20 _ASTART = [ "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", 20 _ASTART = [ "'tain't", "'twere", "'twas", "'tis", "'twill", "'til",
21 "'bout", "'nuff", "'round", "'cause" , "'em" ] 21 "'bout", "'nuff", "'round", "'cause" , "'em" ]
22 22
42 ws[i] = '"' 42 ws[i] = '"'
43 elif ch in set([LSQUO, RSQUO]): 43 elif ch in set([LSQUO, RSQUO]):
44 ws[i] = "'" 44 ws[i] = "'"
45 45
46 def _is_cockney(pos, ws): 46 def _is_cockney(pos, ws):
47 pos = self._pos
48 ws = self.workspace
49 for i in _ASTART: 47 for i in _ASTART:
50 li = len(i) 48 li = len(i)
51 if ws[pos:pos+li].lower() == i and not ws[pos+li].isalpha(): 49 if ws[pos:pos+li].lower() == i and not ws[pos+li].isalpha():
52 return True 50 return True
53 51