vscode-markdown
vscode-markdown copied to clipboard
Support setext headings (underlined with `===` or `---`) in Toggle heading
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.
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
If I understand correctly, this request is to add setext heading support to toggleHeadingUp()
and toggleHeadingDown()
?
I think so
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.
Sounds better
HI, was syntax highlighting for sextet headings ever implemented?
If not, is there a way to implement them
Thanks
@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
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
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.