MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / register

Method register

markdown/util.py:362–386  ·  view source on GitHub ↗

Add an item to the registry with the given name and priority. Arguments: item: The item being registered. name: A string used to reference the item. priority: An integer or float used to sort against all items. If an item is registered w

(self, item: _T, name: str, priority: float)

Source from the content-addressed store, hash-verified

360 raise ValueError('No item named "{}" exists.'.format(name))
361
362 def register(self, item: _T, name: str, priority: float) -> None:
363 """
364 Add an item to the registry with the given name and priority.
365
366 Arguments:
367 item: The item being registered.
368 name: A string used to reference the item.
369 priority: An integer or float used to sort against all items.
370
371 If an item is registered with a "name" which already exists, the
372 existing item is replaced with the new item. Treat carefully as the
373 old item is lost with no way to recover it. The new item will be
374 sorted according to its priority and will **not** retain the position
375 of the old item.
376
377 Items assigned a higher number are given a higher priority. In other
378 words, items assigned a higher number are sorted to be before those
379 assigned a lower number.
380 """
381 if name in self:
382 # Remove existing item of same name first
383 self.deregister(name)
384 self._is_sorted = False
385 self._data[name] = item
386 self._priority.append(_PriorityItem(name, priority))
387
388 def deregister(self, name: str, strict: bool = True) -> None:
389 """

Callers 15

build_preprocessorsFunction · 0.95
__getitem__Method · 0.95
build_inlinepatternsFunction · 0.95
build_postprocessorsFunction · 0.95
build_treeprocessorsFunction · 0.95
testCreateRegistryMethod · 0.95
testSortRegistryMethod · 0.95
testIsSortedMethod · 0.95
testDeregisterMethod · 0.95
testRegistryContainsMethod · 0.95
testRegistryIterMethod · 0.95

Calls 2

deregisterMethod · 0.95
_PriorityItemClass · 0.85

Tested by 15

testCreateRegistryMethod · 0.76
testSortRegistryMethod · 0.76
testIsSortedMethod · 0.76
testDeregisterMethod · 0.76
testRegistryContainsMethod · 0.76
testRegistryIterMethod · 0.76
testRegistryDelItemMethod · 0.76
testRegistrySliceMethod · 0.76
testGetIndexForNameMethod · 0.76