reference-entry-content.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. .. _reference.entry.content:
  2. :py:attr:`entries[i].content`
  3. =============================
  4. A list of dictionaries with details about the full content of the entry.
  5. Atom feeds may contain multiple content elements. Clients should render as
  6. many of them as possible, based on the type and the client's abilities.
  7. .. _reference.entry.content.value:
  8. :py:attr:`entries[i].content[j].value`
  9. --------------------------------------
  10. The value of this piece of content.
  11. If this contains :abbr:`HTML (HyperText Markup Language)` or
  12. :abbr:`XHTML (Extensible HyperText Markup Language)`, it is
  13. :ref:`sanitized <advanced.sanitization>` by default.
  14. If this contains :abbr:`HTML (HyperText Markup Language)` or
  15. :abbr:`XHTML (Extensible HyperText Markup Language)`, certain (X)HTML elements
  16. within this value may contain relative :abbr:`URI (Uniform Resource Identifier)`\s.
  17. If so, they are :ref:`resolved according to a set of rules <advanced.base>`.
  18. .. _reference.entry.content.type:
  19. :py:attr:`entries[i].content[j].type`
  20. -------------------------------------
  21. The content type of this piece of content.
  22. Most likely values for `type`:
  23. * :mimetype:`text/plain`
  24. * :mimetype:`text/html`
  25. * :mimetype:`application/xhtml+xml`
  26. For Atom feeds, the content type is taken from the type attribute, which
  27. defaults to :mimetype:`text/plain` if not specified. For
  28. :abbr:`RSS (Rich Site Summary)` feeds, the content type is auto-determined by
  29. inspecting the content, and defaults to :mimetype:`text/html`. Note that this
  30. may cause silent data loss if the value contains plain text with angle
  31. brackets. There is nothing I can do about this problem; it is a limitation of
  32. :abbr:`RSS (Rich Site Summary)`.
  33. Future enhancement: some versions of :abbr:`RSS (Rich Site Summary)` clearly
  34. specify that certain values default to :mimetype:`text/plain`, and
  35. :program:`Universal Feed Parser` should respect this, but it doesn't yet.
  36. .. _reference.entry.content.language:
  37. :py:attr:`entries[i].content[j].language`
  38. -----------------------------------------
  39. The language of this piece of content.
  40. :py:attr:`~entries[i].content[j].language` is supposed to be a language code,
  41. as specified by :rfc:`3066`, but publishers have been known to publish random
  42. values like "English" or "German". :program:`Universal Feed Parser` does not
  43. do any parsing or normalization of language codes.
  44. :py:attr:`~entries[i].content[j].language` may come from the element's xml:lang
  45. attribute, or it may inherit from a parent element's xml:lang, or the
  46. :mailheader:`Content-Language` :abbr:`HTTP (Hypertext Transfer Protocol)`
  47. header. If the feed does not specify a language,
  48. :py:attr:`~entries[i].content[j].language` will be ``None``, the
  49. :program:`Python` null value.
  50. .. _reference.entry.content.base:
  51. :py:attr:`entries[i].content[j].base`
  52. -------------------------------------
  53. The original base :abbr:`URI (Uniform Resource Identifier)` for links within
  54. this piece of content.
  55. :py:attr:`~entries[i].content[j].base` is only useful in rare situations and
  56. can usually be ignored. It is the original base
  57. :abbr:`URI (Uniform Resource Identifier)` for this value, as specified by the
  58. element's xml:base attribute, or a parent element's xml:base, or the
  59. appropriate :abbr:`HTTP (Hypertext Transfer Protocol)` header, or the
  60. :abbr:`URI (Uniform Resource Identifier)` of the feed. (See
  61. :ref:`advanced.base` for more details.) By the time you see it,
  62. :program:`Universal Feed Parser` has already resolved relative links in all
  63. values where it makes sense to do so. *Clients should never need to manually
  64. resolve relative links.*
  65. .. rubric:: Comes from
  66. * /atom03:feed/atom03:entry/atom03:content
  67. * /atom10:feed/atom10:entry/atom10:content
  68. * /rdf:RDF/rdf:item/content:encoded
  69. * /rss/channel/item/body
  70. * /rss/channel/item/content:encoded
  71. * /rss/channel/item/fullitem
  72. * /rss/channel/item/xhtml:body