core.bones.text
¶
Module Contents¶
Classes¶
Find tags and other markup and call handler functions. |
|
Find tags and other markup and call handler functions. |
|
Functions¶
|
Parses a file download-url (/file/download/xxxx?sig=yyyy) into it's components |
Attributes¶
- core.bones.text._defaultTags¶
- core.bones.text.parseDownloadUrl(urlStr: str) Tuple[str | None, bool | None, str | None] ¶
Parses a file download-url (/file/download/xxxx?sig=yyyy) into it’s components blobKey, derived (yes/no) and filename. Will return None for each component if the url could not be parsed.
- class core.bones.text.CollectBlobKeys¶
Bases:
html.parser.HTMLParser
Find tags and other markup and call handler functions.
- Usage:
p = HTMLParser() p.feed(data) … p.close()
Start tags are handled by calling self.handle_starttag() or self.handle_startendtag(); end tags by self.handle_endtag(). The data between tags is passed from the parser to the derived class by calling self.handle_data() with the data as argument (the data may be split up in arbitrary chunks). If convert_charrefs is True the character references are converted automatically to the corresponding Unicode character (and self.handle_data() is no longer split in chunks), otherwise they are passed by calling self.handle_entityref() or self.handle_charref() with the string containing respectively the named or numeric reference as the argument.
- handle_starttag(tag, attrs)¶
- class core.bones.text.HtmlSerializer(validHtml=None, srcSet=None)¶
Bases:
html.parser.HTMLParser
Find tags and other markup and call handler functions.
- Usage:
p = HTMLParser() p.feed(data) … p.close()
Start tags are handled by calling self.handle_starttag() or self.handle_startendtag(); end tags by self.handle_endtag(). The data between tags is passed from the parser to the derived class by calling self.handle_data() with the data as argument (the data may be split up in arbitrary chunks). If convert_charrefs is True the character references are converted automatically to the corresponding Unicode character (and self.handle_data() is no longer split in chunks), otherwise they are passed by calling self.handle_entityref() or self.handle_charref() with the string containing respectively the named or numeric reference as the argument.
- handle_data(data)¶
- handle_charref(name)¶
- handle_entityref(name)¶
- flushCache()¶
Flush pending tags into the result and push their corresponding end-tags onto the stack
- handle_starttag(tag, attrs)¶
Delete all tags except for legal ones
- handle_endtag(tag)¶
- cleanup()¶
Append missing closing tags
- sanitize(instr)¶
- class core.bones.text.TextBone(*, validHtml: None | Dict = __undefinedC__, maxLength: int = 200000, srcSet: Dict[str, List] | None = None, indexed: bool = False, **kwargs)¶
Bases:
viur.core.bones.base.BaseBone
- class __undefinedC__¶
- type = text¶
- singleValueSerialize(value, skel: SkeletonInstance, name: str, parentIndexed: bool)¶
- singleValueFromClient(value, skel, name, origData)¶
- getEmptyValue()¶
- isInvalid(value)¶
Returns None if the value would be valid for this bone, an error-message otherwise.
- getReferencedBlobs(skel: viur.core.skeleton.SkeletonInstance, name: str) Set[str] ¶
Parse our html for embedded img or hrefs pointing to files. These will be locked, so even if they are deleted from the file browser, we’ll still keep that blob alive so we don’t have broken links/images in this bone.
- refresh(skel, boneName) None ¶
Re-parse our text. This will cause our src-set to rebuild.
- getSearchTags(skel: viur.core.skeleton.SkeletonInstance, name: str) Set[str] ¶