MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / attrJoin

Method attrJoin

markdown_it/token.py:106–119  ·  view source on GitHub ↗

Join value to existing attribute via space. Or create new attribute if not exists. Useful to operate with token classes.

(self, name: str, value: str)

Source from the content-addressed store, hash-verified

104 return self.attrs.get(name, None)
105
106 def attrJoin(self, name: str, value: str) -> None:
107 """Join value to existing attribute via space.
108 Or create new attribute if not exists.
109 Useful to operate with token classes.
110 """
111 if name in self.attrs:
112 current = self.attrs[name]
113 if not isinstance(current, str):
114 raise TypeError(
115 f"existing attr 'name' is not a str: {self.attrs[name]}"
116 )
117 self.attrs[name] = f"{current} {value}"
118 else:
119 self.attrs[name] = value
120
121 def copy(self, **changes: Any) -> Token:
122 """Return a shallow copy of the instance."""

Callers 3

fenceMethod · 0.95
test_tokenFunction · 0.95
list_blockFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_tokenFunction · 0.76