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.5 KiB

  1. .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
  2. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  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/8.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. <https://github.com/OCA/
  41. server-tools/issues/new?body=module:%20
  42. html_text%0Aversion:%20
  43. 8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  44. Credits
  45. =======
  46. Contributors
  47. ------------
  48. * Jairo Llopis <yajo.sk8@gmail.com>
  49. Maintainer
  50. ----------
  51. .. image:: https://odoo-community.org/logo.png
  52. :alt: Odoo Community Association
  53. :target: https://odoo-community.org
  54. This module is maintained by the OCA.
  55. OCA, or the Odoo Community Association, is a nonprofit organization whose
  56. mission is to support the collaborative development of Odoo features and
  57. promote its widespread use.
  58. To contribute to this module, please visit https://odoo-community.org.