Interface IForeignCodeExtractor

Foreign code extractor makes it possible to analyze code of language X embedded in code (or notebook) of language Y.

The typical examples are:

  • (X=CSS< Y=HTML), or
  • (X=JavaScript, Y=HTML),

while in the data analysis realm, examples include:

  • (X=R, Y=IPython),
  • (X=LATEX Y=IPython),
  • (X=SQL, Y=IPython)

This extension does not aim to provide comprehensive abilities for foreign code extraction, but it does intend to provide stable interface for other extensions to build on it.

A simple, regular expression based, configurable foreign extractor is implemented to provide a good reference and a good initial experience for the users.

interface IForeignCodeExtractor {
    cellType: string[];
    fileExtension: string;
    language: string;
    standalone: boolean;
    extractForeignCode(code: string): IExtractedCode[];
    hasForeignCode(code: string, cellType: string): boolean;
}

Implemented by

Properties

cellType: string[]

The supported cell types.

fileExtension: string

Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.

language: string

The foreign language.

standalone: boolean

Does the extractor produce code which should be appended to the previously established virtual document (False) of the same language, or does it produce standalone snippets which require separate connections (True)?

Methods

  • Test if there is any foreign code in provided code snippet.

    Parameters

    • code: string
    • cellType: string

    Returns boolean