Markdown syntax highlighting inside Python docstrings.
The extension recognizes actual line-leading Python docstring statements while leaving assigned and embedded triple-quoted strings alone.
- Headings, emphasis, links, lists, blockquotes, inline code, tables, and the other syntax supported by VS Code's built-in Markdown grammar.
- Fenced code blocks with an explicit language, such as
python,javascript,typescript,json,yaml,sql,shell,rust, and the other languages recognized by VS Code Markdown. - Parser-backed Python detection for unlabelled fenced and indented code blocks.
- Syntactically valid Python—including formulas that are valid Python expressions—uses Python highlighting; rejected blocks use the theme's normal editor foreground.
- Unformatted prose retains the active theme's Python docstring/string color.
- Triple-quoted and single-line docstrings, raw docstrings, module docstrings, and conventionally indented nested definitions.
- Install dependencies with
npm install. - Build and test with
npm run build && npm test. - Create a VSIX with
npm run package. - In VS Code, run Extensions: Install from VSIX... and select the generated file.
For development, run npm run build, open this directory in VS Code, and press F5. Rebuild after changing the extension runtime or grammar generator.
- Install the locked dependencies with
npm ci. - Run the checks with
npm test. - Build the release VSIX with
npm run package. The pre-publish script rebuilds the grammar, extension bundle, and parser assets before packaging. - Open Visual Studio Marketplace publisher management and select the publisher account.
- Choose New Extension → Visual Studio Code, then upload the generated
docstring-highlighter-python-<version>.vsixfile.
Before packaging a later release, update both manifest versions without creating a Git tag automatically:
npm version patch --no-git-tag-version- Markdown is enabled only for strings that begin a Python statement. An assigned value such as
template = """..."""remains an ordinary string. - Conventional four-space indentation and tabs are handled exactly through 12 nesting levels. Unusual indentation uses a best-effort baseline inferred from the first non-empty content line.
- An unlabelled fenced or indented block is parsed as a complete Python snippet. A syntax-error-free parse receives Python highlighting; otherwise the block uses the normal editor foreground without language highlighting. Explicit fence labels continue to select their corresponding installed grammar directly.
Use Developer: Inspect Editor Tokens and Scopes to inspect a token. Extension-specific scopes start with meta.docstring.docstring-highlighter-python; detected Python code uses meta.embedded.block.python.docstring-highlighter-python, while plain code uses meta.embedded.block.plaintext.docstring-highlighter-python.