sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
814 stars 40 forks source link

Markdown fenced code blocks with language selection does not inherit syntax settings #5748

Open koitsu opened 2 years ago

koitsu commented 2 years ago

Description of the bug

Within Markdown files, use of fenced code blocks with a language selection does not inherit any language/syntax-specific adjustments.

For example, say you have file called test.md (which is using Markdown -> Markdown as its syntax highlighter). Within that file, you have the following content:

```bash
program --long-flag
```

The syntax highlighting used within the "bash" fenced code block visually appear to be the same as what is under the Bash syntax highlighter in Sublime Text. I assume that's the case? (Maybe this is a bad assumption.)

Now if you adjust Settings -> Syntax Specific for Bash (i.e. Bash.sublime-settings), and set its content to:

{
    "font_options": ["no_italic"]
}

You will continue to see italic fonts used within the "bash" fenced code block (look at --long-flag). However, within an actual file that's using the Bash syntax highlighter directly, italic fonts do not appear.

Part of me thinks this is a configuration mistake on my part, or a setting I'm overlooking, but if so, I'm not sure what to Google/search to fix it.

Steps to reproduce

Explained in the Description.

Expected behavior

Explained in the Description.

Actual behavior

Explained in the Description.

Sublime Text build number

4143

Operating system & version

Windows 7 SP1 x64

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

koitsu commented 2 years ago

I suspect https://github.com/sublimehq/sublime_text/issues/5004 is related, but I'm not completely sure.

deathaxe commented 2 years ago

Sublime Text provides global settings objects for each view which accumulate settings from various files in a defined loading order - one of them being syntax specific settings.

It doesn't however manage different settings for parts of a code as all/most scenarios of including foreign syntaxes have been meant to extend a syntax in some way.

This limitation indeed effects all compound syntaxes which consist of various base syntaxes. Not only Markdown, but also ASP, JSP, PHP as well as all the templating syntaxes such as Vue, Liquid, Astro, ... .

Not only highlighting such as italics but also basic bahaviors such as auto-completions or word_separators may be effected, which may need to be handled differently (_e.g.: fenced CSS code blocks don't respect CSS specific word_separators_).

Maybe sublime-settings should be applied by scope such as settings from tmPreferences at some point.

koitsu commented 2 years ago

@deathaxe Thanks for the info! Sounds like this, for the moment, is "by design" then. A bummer, but understandable.