# ‹› `` `markdown.extensions.md_in_html`

Parse Markdown syntax within raw HTML. Based on the implementation in PHP Markdown Extra.

See the documentation for details.

Classes:

- `HTMLExtractorExtra` –

  Override `HTMLExtractor` and create `etree` `Elements` for any elements which should have content parsed as

- `HtmlBlockPreprocessor` –

  Remove html blocks from the text and store them for later retrieval.

- `MarkdownInHtmlProcessor` –

  Process Markdown Inside HTML Blocks which have been stored in the `HtmlStash`.

- `MarkdownInHTMLPostprocessor` –
- `MarkdownInHtmlExtension` –

  Add Markdown parsing in HTML to Markdown class.

## ‹› `` `markdown.extensions.md_in_html.HTMLExtractorExtra(md: Markdown, *args, **kwargs)`

Bases: `HTMLExtractor`

Override `HTMLExtractor` and create `etree` `Elements` for any elements which should have content parsed as Markdown.

Methods:

- `reset` –

  Reset this instance. Loses all unprocessed data.

- `close` –

  Handle any buffered data.

- `get_element` –

  Return element from `treebuilder` and reset `treebuilder` for later use.

- `get_state` –

  Return state from tag and `markdown` attribute. One of ‘block’, ‘span’, or ‘off’.

### ‹› `` `markdown.extensions.md_in_html.HTMLExtractorExtra.reset()`

Reset this instance. Loses all unprocessed data.

### ‹› `` `markdown.extensions.md_in_html.HTMLExtractorExtra.close()`

Handle any buffered data.

### ‹› `` `markdown.extensions.md_in_html.HTMLExtractorExtra.get_element() -> etree.Element`

Return element from `treebuilder` and reset `treebuilder` for later use.

### ‹› `` `markdown.extensions.md_in_html.HTMLExtractorExtra.get_state(tag, attrs: Mapping[str, str]) -> Literal['block', 'span', 'off', None]`

Return state from tag and `markdown` attribute. One of ‘block’, ‘span’, or ‘off’.

## ‹› `` `markdown.extensions.md_in_html.HtmlBlockPreprocessor(md: Markdown | None = None)`

Bases: `Preprocessor`

Remove html blocks from the text and store them for later retrieval.

## ‹› `` `markdown.extensions.md_in_html.MarkdownInHtmlProcessor(parser: BlockParser)`

Bases: `BlockProcessor`

Process Markdown Inside HTML Blocks which have been stored in the `HtmlStash`.

Methods:

- `parse_element_content` –

  Recursively parse the text content of an `etree` Element as Markdown.

### ‹› `` `markdown.extensions.md_in_html.MarkdownInHtmlProcessor.parse_element_content(element: etree.Element) -> None`

Recursively parse the text content of an `etree` Element as Markdown.

Any block level elements generated from the Markdown will be inserted as children of the element in place of the text content. All `markdown` attributes are removed. For any elements in which Markdown parsing has been disabled, the text content of it and its children are wrapped in an `AtomicString`.

## ‹› `` `markdown.extensions.md_in_html.MarkdownInHTMLPostprocessor(md: Markdown | None = None)`

Bases: `RawHtmlPostprocessor`

Methods:

- `stash_to_string` –

  Override default to handle any `etree` elements still in the stash.

### ‹› `` `markdown.extensions.md_in_html.MarkdownInHTMLPostprocessor.stash_to_string(text: str | etree.Element) -> str`

Override default to handle any `etree` elements still in the stash.

## ‹› `` `markdown.extensions.md_in_html.MarkdownInHtmlExtension(**kwargs)`

Bases: `Extension`

Add Markdown parsing in HTML to Markdown class.

Methods:

- `extendMarkdown` –

  Register extension instances.

### ‹› `` `markdown.extensions.md_in_html.MarkdownInHtmlExtension.extendMarkdown(md)`

Register extension instances.