You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.4 KiB

  1. .. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
  2. :target: https://www.gnu.org/licenses/agpl
  3. :alt: License: AGPL-3
  4. ====================
  5. Text from HTML field
  6. ====================
  7. This module provides some technical features that allow to extract text from
  8. any chunk of HTML, without HTML tags or attributes. You can chose either:
  9. * To truncate the result by amount of words or characters.
  10. * To append an ellipsis (or any character(s)) at the end of the result.
  11. It can be used to easily generate excerpts.
  12. Usage
  13. =====
  14. This module just adds a technical utility, but nothing for the end user.
  15. If you are a developer and need this utility for your module, see these
  16. examples and read the docs inside the code.
  17. Python example::
  18. @api.multi
  19. def some_method(self):
  20. # Get truncated text from an HTML field. It will 40 words and 100
  21. # characters at most, and will have "..." appended at the end if it
  22. # gets truncated.
  23. truncated_text = self.env["ir.fields.converter"].text_from_html(
  24. self.html_field, 40, 100, "...")
  25. QWeb example::
  26. <t t-esc="env['ir.fields.converter'].text_from_html(doc.html_field)"/>
  27. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  28. :alt: Try me on Runbot
  29. :target: https://runbot.odoo-community.org/runbot/149/11.0
  30. Known issues / Roadmap
  31. ======================
  32. * An option could be added to try to respect the basic HTML tags inside the
  33. excerpt (``<b>``, ``<i>``, ``<p>``, etc.).
  34. Bug Tracker
  35. ===========
  36. Bugs are tracked on `GitHub Issues
  37. <https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
  38. check there if your issue has already been reported. If you spotted it first,
  39. help us smashing it by providing a detailed and welcomed feedback.
  40. Credits
  41. =======
  42. Contributors
  43. ------------
  44. * Jairo Llopis <yajo.sk8@gmail.com>
  45. * Vicent Cubells <vicent.cubells@tecnativa.com>
  46. * Dennis Sluijk <d.sluijk@onestein.nl>
  47. Do not contact contributors directly about support or help with technical issues.
  48. Maintainer
  49. ----------
  50. .. image:: https://odoo-community.org/logo.png
  51. :alt: Odoo Community Association
  52. :target: https://odoo-community.org
  53. This module is maintained by the OCA.
  54. OCA, or the Odoo Community Association, is a nonprofit organization whose
  55. mission is to support the collaborative development of Odoo features and
  56. promote its widespread use.
  57. To contribute to this module, please visit https://odoo-community.org.