vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Support setext headings (underlined with `===` or `---`) in Toggle heading

Open theherk opened this issue 3 years ago • 9 comments

What is the problem?

When using C-} to promote the line under cursor to H1 or H2 and C-{ to demote to H1 or H2, # and ## are used. This is not a problem. The problem is that there doesn't seem to be an option to use === and --- in lieu of these.

How can I reproduce it?

Enter "Some Text", then C-}. This will convert to "# Some Text".

Is there any error message in the console?

No.

Suggested Feature

use-fancy-headings

If this feature were enabled the workflow would follow:

enter "Some Text"

Some Text

C-}

Some Text
=========

modify to "Some Different Text"

Some Different Text
=========

C-}, now H2, and modification updates number of ='s or -'s

Some Different Text
-------------------

Is this even possible? If so, I'd be happy to work on it. If it exists already, I'm sorry for the entry.

theherk avatar Aug 26 '20 15:08 theherk

Thanks for the feedback.

It is possible. You can have a look at

https://github.com/yzhang-gh/vscode-markdown/blob/8ca0b084d1ede2263d13fb50d03049111358f8b5/src/formatting.ts#L52-L80

yzhang-gh avatar Aug 26 '20 15:08 yzhang-gh

If I understand correctly, this request is to add setext heading support to toggleHeadingUp() and toggleHeadingDown()?

Lemmingh avatar Aug 28 '20 18:08 Lemmingh

I think so

yzhang-gh avatar Aug 29 '20 00:08 yzhang-gh

Seem like this would also be nice as an autocompletion feature.

When typing a setex heading underline it should offer to complete based on the length of the heading above.

After typing a valid setex heading underline offer to complete to heading length by repeating what ever valid underline has been used be that (-)------- , (=)=====, (- )- - - - - - , (-- )-- -- -- , etc.

gavbarnett avatar Feb 08 '21 16:02 gavbarnett

Sounds better

yzhang-gh avatar Feb 09 '21 06:02 yzhang-gh

HI, was syntax highlighting for sextet headings ever implemented?

If not, is there a way to implement them

Thanks

tom-newhall avatar Dec 03 '23 21:12 tom-newhall

@tom-newhall The basic Markdown syntax highlighting is provided by VS Code itself. Please see

https://github.com/microsoft/vscode/blob/main/extensions/markdown-basics/syntaxes/markdown.tmLanguage.json

yzhang-gh avatar Dec 04 '23 14:12 yzhang-gh

Thanks so much for getting back to me. Sorry my question was not very detailed. Right now, the default behavior is that only the === and --- lines are highlighted for setext headings. I would ideally like both the text on the line before and the === / --- to be highlighted. Is this possible, i.e. with begin and end?

Also, if I wanted to modify the markdown.tmLanguage.json file that you pointed to earlier, where would I find that?

Thanks in advance

tom-newhall avatar Dec 11 '23 10:12 tom-newhall

You can see the regular expressions at https://github.com/microsoft/vscode/blob/55d7566112ae7de85a6ff75d85374aad95d1cea9/extensions/markdown-basics/syntaxes/markdown.tmLanguage.json#L2265-L2276

However, the tmlanguage isn't that easy to use. I suggest using an extension (e.g. Highlight) to do this.

yzhang-gh avatar Dec 11 '23 11:12 yzhang-gh