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

Method register

markdown/util.py:365–389  ·  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

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

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