Releases: posit-dev/py-htmltools
htmltools 0.6.1
Bug fixes
HTMLDocument.save_html()now explicitly usesencoding="utf-8"when writing files, fixingUnicodeEncodeErroron Windows when HTML contains non-ASCII characters (e.g., Unicode minus sign U+2212 from matplotlib SVG output). (#102)
Other changes
- Dropped support for Python 3.9 (EOL). Added support for Python 3.13 and 3.14. (#104)
htmltools 0.6.0
Breaking changes
-
HTMLno longer inherits fromstr. It now inherits fromcollections.UserString. This was done to avoid confusion betweenstrandHTMLobjects. (#86) -
TagListno longer inherits fromlist. It now inherits fromcollections.UserList. This was done to avoid confusion betweenlistandTagListobjects. (#97) -
TagandTagList's method.get_html_string()now both returnstrinstead ofHTML. (#86) -
Strings added to
HTMLobjects, now returnHTMLobjects. E.g.HTML_value + str_valueandstr_value + HTML_valueboth returnHTMLobjects. To maintain astrresult, callstr()on yourHTMLobjects before adding them to other strings values. (#86) -
Items added to
TagListobjects, now returnTagListobjects. E.g.TagList_value + arr_valueandarr_value + TagList_valueboth return newTagListobjects. To maintain alistresult, calllist()on yourTagListobjects before combining them to other list objects. (#97)
New features
-
Exported
ReprHtmlprotocol class. If an object has a_repr_html_method, then it is of instanceReprHtml. (#86) -
Exported
is_tag_node()andis_tag_child()functions that utilizetyping.TypeIsto narrowTagNodeandTagChildtype variables, respectively. (#86) -
Exported
consolidate_attrs(*args, **kwargs)function. This function will combine theTagAttrs(supplied in*args) withTagAttrValues(supplied in**kwargs) into a singleTagAttrsobject. In addition, it will also return all*argsthat are not dictionary as a list of unalteredTagChildobjects. (#86) -
The
Tagmethod.add_style(style=)added support forHTMLobjects in addition tostrvalues. (#86)
Bug fixes
- Fixed an issue with
HTMLTextDocument()returning extractedHTMLDependency()s in a non-determistic order. (#95)
htmltools 0.5.3
- HTML tags in docstrings are now escaped. (#90)
htmltools 0.5.2
- The
HTMLDependency.copy()method can now correctly copy folders in depenendencies that both include directories and haveall_files=True. (#87)
htmltools 0.5.1
-
Tagobjects can now be used as context managers, as inwith tags.div():. When used this way, then inside thewithblock,sys.displayhookis replaced with a function which adds items as children to theTag. This is meant to be used with Shiny Express, Quarto, or Jupyter. (#76) -
Added a function
wrap_displayhook_handler(). This alliows displayhooks to delegate their logic for handling various kinds of objects (likeTagobjects and objects with a_repr_html()) to this function. (#77)
htmltools 0.5.0
-
Objects with a
_repr_html_method can now appear as children ofTag/TagListobjects. (#74) -
Changed the type annotation of
_add_wsfrombooltoTagAttrValue. This makes it easier to write functions which callTagfunctions and pass along**kwargs. (#67) -
Changed the type annotation of
collapse_fromstrtostr | float | None. This makes it easier to write calls tocss()pass along**kwargs. (#68) -
Enhanced the type definition of
TagAttrsto includeTagAttrDict, the type of aTag'sattrsproperty. (#55) -
For
HTMLTextDocumentobjects, deduplicate HTML dependencies. (#72) -
Switched from
setup.cfgandsetup.pytopyproject.toml. (#73)
htmltools 0.4.1
- Fixed deserialization of JSON HTML dependencies when they contained newline characters. (#65)
htmltools 0.4.0
htmltools 0.3.0
htmltools 0.2.1
Bug fixes
- Fixed the stype signature of the
TagFunctionprotocol class.