zhaouv / vscode-markdown-everywhere

Embed and highlight and preview markdown in any language which support line-comment or block-comment for vscode.
https://marketplace.visualstudio.com/items?itemName=zhaouv.vscode-markdown-everywhere
Apache License 2.0
10 stars 4 forks source link

Syntax highlight issues with percent encoded triple quoted doc strings #24

Closed dbrattli closed 4 days ago

dbrattli commented 4 months ago

Thanks for the great plugin. I have some issues when using it with the [Jupytext Percent format] (https://jupytext.readthedocs.io/en/latest/formats-scripts.html) inside Python source files. The problem is when there is a # %% [markdown] in front of a multiline triple quoted markdown cell:

Skjermbilde 2024-07-17 kl  11 25 59

As you can see the markdown is not highlighted correctly. Many Python keywords seem to be highlighted etc. If I remove the # %% [markdown] in front of the triple quoted markdown string (or put a line in between), then things are formatted correctly again:

Skjermbilde 2024-07-17 kl  11 24 19

Below is the same code block as text:

# %% [markdown]
"""
# Basic Type Annotations

For basic type annotations, we will cover annotating variables for basic
container types and simple functions.

In this post we will be using the function [reveal_type]
(https://docs.python.org/3/library/typing.html#typing.reveal_type) to
ask the static type checker to reveal the inferred type of its argument.

Most type checkers support reveal_type() even if the name is not
imported from typing. However, to avoid runtime errors it should be
imported from the typing module. At runtime, this function prints the
runtime type of its argument and returns the argument unchanged.
"""

Hope there is an easy fix for this. Thanks.

zhaouv commented 4 months ago
image

a known issue, the """ is regarded as comment, because it is the first line following the LRSM rule. still haven't figured out the mechanism

zhaouv commented 4 days ago

fixed

dbrattli commented 4 days ago

This is great news. Thanks for fixing 🥰 FYI: @Anitsirc22