diff --git a/README.rst b/README.rst index c273c48..5559e1a 100644 --- a/README.rst +++ b/README.rst @@ -535,19 +535,22 @@ If the fine-tuning options discussed above are not sufficient, you may even over .. code-block:: python from inscriptis.html_engine import Inscriptis - from functools import partial - - inscriptis = Inscriptis(html_tree, config) - - inscriptis.start_tag_handler_dict['a'] = partial(my_handle_start_a, inscriptis) - inscriptis.end_tag_handler_dict['a'] = partial(my_handle_end_a, inscriptis) + from inscriptis import ParserConfig + + my_mapping = CustomHtmlTagHandlerMapping( + start_tag_mapping={'a': my_handle_start_a}, + end_tag_mapping={'a': my_handle_end_a} + ) + inscriptis = Inscriptis(html_tree, + ParserConfig(custom_html_tag_handler_mapping=my_mapping)) text = inscriptis.get_text() In the example the standard HTML handlers for the ``a`` tag are overwritten with custom versions (i.e., ``my_handle_start_a`` and ``my_handle_end_a``). -You may define custom handlers for any tag, regardless of whether it already exists in ``start_tag_handler_dict`` or ``end_tag_handler_dict``. +You may define custom handlers for any tag, regardless of whether it already exists in the standard mapping. -Please refer to `custom-html-handling.py `_ for a working example. +Please refer to `custom-html-handling.py `_ for a working example. +The standard HTML tag handlers can be found in the `inscriptis.model.tag` package. Optimizing memory consumption -----------------------------