Skip to main content

detect_embedded_regions_in_tree

Function detect_embedded_regions_in_tree 

Source
pub fn detect_embedded_regions_in_tree(
    network: &LinkNetwork,
    document: LinkId,
    text: &str,
    language: &str,
    policy: RegionDetectionPolicy,
) -> Vec<EmbeddedRegion>
Expand description

Embedded regions a host document delimits, in source order.

The whole buffer of a txt document is one region, and for HTML and Markdown hosts the regions are those their grammar CST (the host’s Syntax links below document) delimits. Mirrors detectEmbeddedRegionsInTree in js/src/regions.js; document is the host’s Document link in network.

  • HTML: the raw_text of a script_element in the language its type attribute names (JavaScript when absent), the raw_text of a style_element as CSS, and the attribute_value of every style attribute as CSS.
  • Markdown: the code_fence_content of a fenced_code_block in the language policy selects from its info-string language and content, every html_block as HTML, and every inline html_tag as HTML, spanning from an opening tag to the matching closing tag among its siblings.