lib.metadata.extract

Title, Subtitle, and Metadata extraction of reStructuredText.

django_docutils.lib.metadata.extract.extract_title(document)[source]

Return the title of the document.

Parameters:

document (docutils.nodes.document) – Document to return title for.

Returns:

Title of document or None if not found.

Return type:

str or None

django_docutils.lib.metadata.extract.extract_metadata(document)[source]

Return the dict containing document metadata.

Parameters:

document (docutils.nodes.document) – Document extract metadata from.

Returns:

docinfo data from document

Return type:

dict

django_docutils.lib.metadata.extract.extract_subtitle(document)[source]

Return the subtitle of the document.

Return type:

Optional[str]

django_docutils.lib.metadata.extract.extract_abstract(doctree, length=100)[source]

Pull first n words from a docutils document.

We use this to create snippets for Twitter Cards, FB, etc.

Parameters:
  • doctree (docutils.nodes.document) – Document to extract abstract from.

  • length (int) – Word count to cut content off at.

Returns:

truncated content, html tags removed

Return type:

str