Adds a marker as a new run. Code can run through the self.runs to mark a run with additional information. A marker is a tiny piece of string in transparent color, that can its positions traced back in a rendered BabelString instance. >>> from pagebot.contexts import
(self, markerId, arg)
| 530 | |
| 531 | |
| 532 | def addMarker(self, markerId, arg): |
| 533 | """Adds a marker as a new run. Code can run through the self.runs to |
| 534 | mark a run with additional information. A marker is a tiny piece of |
| 535 | string in transparent color, that can its positions traced back in a |
| 536 | rendered BabelString instance. |
| 537 | |
| 538 | >>> from pagebot.contexts import getContext |
| 539 | >>> context = getContext() |
| 540 | >>> style = dict(font='PageBot-Regular', fontSize=20) |
| 541 | >>> bs = context.newString('ABCD', style) |
| 542 | >>> bs.addMarker('M1', 'abcd') |
| 543 | >>> bs.getMarkerRuns('M1') |
| 544 | [<BabelRun "[[M1::abcd...">] |
| 545 | >>> bs.addMarker('M2', 'abcd') |
| 546 | >>> bs.addMarker('M2', 'efgh') |
| 547 | >>> bs.getMarkerRuns('M2') |
| 548 | [<BabelRun "[[M2::abcd...">, <BabelRun "[[M2::efgh...">] |
| 549 | >>> bs.getMarkerRuns('M1') |
| 550 | [<BabelRun "[[M1::abcd...">] |
| 551 | """ |
| 552 | # Transparant white extremely small string added in the output. |
| 553 | style = dict(fontSize=pt(0.0000001), textFill=color(1, 1, 1, 0)) |
| 554 | self.runs.append(BabelRun('[[%s::%s]]' % (markerId, arg), style)) |
| 555 | |
| 556 | def getMarkerRuns(self, markerId): |
| 557 | """Answers the list of filtered runs that contain the marker. In |