1 | <?php |
||
12 | class Parser extends ParserBase |
||
13 | { |
||
14 | /** |
||
15 | * @var bool Whether currrent test contains a double quote character |
||
16 | */ |
||
17 | protected $hasDoubleQuote; |
||
18 | |||
19 | /** |
||
20 | * @var bool Whether currrent test contains a single quote character |
||
21 | */ |
||
22 | protected $hasSingleQuote; |
||
23 | |||
24 | /** |
||
25 | * @var string Text being parsed |
||
26 | */ |
||
27 | protected $text; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 75 | public function parse($text, array $matches) |
|
64 | |||
65 | /** |
||
66 | * Add a fancy replacement tag |
||
67 | * |
||
68 | * @param integer $tagPos Position of the tag in the text |
||
69 | * @param integer $tagLen Length of text consumed by the tag |
||
70 | * @param string $chr Replacement character |
||
71 | * @param integer $prio Tag's priority |
||
72 | * @return \s9e\TextFormatter\Parser\Tag |
||
73 | */ |
||
74 | 69 | protected function addTag($tagPos, $tagLen, $chr, $prio = 0) |
|
81 | |||
82 | /** |
||
83 | * Parse dashes and ellipses |
||
84 | * |
||
85 | * Does en dash –, em dash — and ellipsis … |
||
86 | * |
||
87 | * @return void |
||
88 | */ |
||
89 | 74 | protected function parseDashesAndEllipses() |
|
108 | |||
109 | /** |
||
110 | * Parse pairs of double quotes |
||
111 | * |
||
112 | * Does quote pairs “” -- must be done separately to handle nesting |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | 73 | protected function parseDoubleQuotePairs() |
|
127 | |||
128 | /** |
||
129 | * Parse guillemets-style quotation marks |
||
130 | * |
||
131 | * @return void |
||
132 | */ |
||
133 | 74 | protected function parseGuillemets() |
|
150 | |||
151 | /** |
||
152 | * Parse the not equal sign |
||
153 | * |
||
154 | * @return void |
||
155 | */ |
||
156 | 74 | protected function parseNotEqualSign() |
|
170 | |||
171 | /** |
||
172 | * Parse pairs of quotes |
||
173 | * |
||
174 | * @param string $regexp Regexp used to identify quote pairs |
||
175 | * @param string $leftQuote Fancy replacement for left quote |
||
176 | * @param string $rightQuote Fancy replacement for right quote |
||
177 | * @return void |
||
178 | */ |
||
179 | 37 | protected function parseQuotePairs($regexp, $leftQuote, $rightQuote) |
|
192 | |||
193 | /** |
||
194 | * Parse pairs of single quotes |
||
195 | * |
||
196 | * Does quote pairs ‘’ must be done separately to handle nesting |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | 73 | protected function parseSingleQuotePairs() |
|
211 | |||
212 | /** |
||
213 | * Parse single quotes in general |
||
214 | * |
||
215 | * Does apostrophes ’ after a letter or at the beginning of a word or a couple of digits |
||
216 | * |
||
217 | * @return void |
||
218 | */ |
||
219 | 73 | protected function parseSingleQuotes() |
|
234 | |||
235 | /** |
||
236 | * Parse symbols found after digits |
||
237 | * |
||
238 | * Does symbols found after a digit: |
||
239 | * - apostrophe ’ if it's followed by an "s" as in 80's |
||
240 | * - prime ′ and double prime ″ |
||
241 | * - multiply sign × if it's followed by an optional space and another digit |
||
242 | * |
||
243 | * @return void |
||
244 | */ |
||
245 | 74 | protected function parseSymbolsAfterDigits() |
|
282 | |||
283 | /** |
||
284 | * Parse symbols found in parentheses such as (c) |
||
285 | * |
||
286 | * Does symbols ©, ® and ™ |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | 74 | protected function parseSymbolsInParentheses() |
|
309 | } |