Base class for extensions to subclass.
| 463 | """ |
| 464 | |
| 465 | class Extension: |
| 466 | """ Base class for extensions to subclass. """ |
| 467 | def __init__(self, configs = {}): |
| 468 | """Create an instance of an Extention. |
| 469 | |
| 470 | Keyword arguments: |
| 471 | |
| 472 | * configs: A dict of configuration setting used by an Extension. |
| 473 | """ |
| 474 | self.config = configs |
| 475 | |
| 476 | def getConfig(self, key): |
| 477 | """ Return a setting for the given key or an empty string. """ |
| 478 | if key in self.config: |
| 479 | return self.config[key][0] |
| 480 | else: |
| 481 | return "" |
| 482 | |
| 483 | def getConfigInfo(self): |
| 484 | """ Return all config settings as a list of tuples. """ |
| 485 | return [(key, self.config[key][1]) for key in list(self.config.keys())] |
| 486 | |
| 487 | def setConfig(self, key, value): |
| 488 | """ Set a config setting for `key` with the given `value`. """ |
| 489 | self.config[key][0] = value |
| 490 | |
| 491 | def extendMarkdown(self, md, md_globals): |
| 492 | """ |
| 493 | Add the various proccesors and patterns to the Markdown Instance. |
| 494 | |
| 495 | This method must be overriden by every extension. |
| 496 | |
| 497 | Keyword arguments: |
| 498 | |
| 499 | * md: The Markdown instance. |
| 500 | |
| 501 | * md_globals: Global variables in the markdown module namespace. |
| 502 | |
| 503 | """ |
| 504 | raise NotImplementedError('Extension "%s.%s" must define an "extendMarkdown"' \ |
| 505 | 'method.' % (self.__class__.__module__, self.__class__.__name__)) |
| 506 | |
| 507 | |
| 508 | def load_extension(ext_name, configs = []): |
nothing calls this directly
no outgoing calls
no test coverage detected