Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make nested markdown bullet lists have different bullet styles in vscode

I want to have vscode render lists in markdown with bullet points instead of the asterisk (*) character, so that the top level would use •, the next one would use ◦, etc.

My first approach was to create a ligature font with FontForge that replaced * with ◦, space plus * with ◦, two spaces plus * with ▪, and so on, but using ligatures has the obvious issue that it's not context-sensitive, so all asterisks would be replaced, not just the ones leading a line.

Looking at the vscode text decoration API, it seems limited to just changing the font style and color, and not the font family. Is there some way to visually replace the characters in vscode? They should still be saved as asterisks in the source code to be valid markdown.

like image 331
slikts Avatar asked Aug 28 '18 16:08

slikts


People also ask

How to make nested bulletpoints in Markdown?

– What Is Mark Down How To Make Nested Bulletpoints In Markdown? Nested lists have four spaces at the bottom and at the top to fit each list into another. You can nest other elements too, like paragraphs or blockquote quotes. List items you have ordered can be mixed with lists you have not ordered.

How to put other Markdown blocks in a list?

To put other Markdown blocks in a list; just indent four spaces for each nesting level I think this is as close as you can get; Markdown doesn't support the "1.1.1" type list you wanted _1. List item__ __1.1 List item _2. List item The important thing is the double space after the first item. But so far, I got difficulties with the third level.

How to indention nTag a Markdown list?

Are There Any Ways To Indention Ntag A Markdown List? Using indentation (or four spaces if you’re aniluvian) creates nested lists. From the default list level onwards, markdown processors ensure each list level contains the same bullet character.

How do I display text as a bulleted list?

Display text as a bulleted list. Bulleted lists use an asterisk ( * ), plus sign ( + ), or hyphen ( -) to delimit each item. There is at least one space between the delimiter and the item. The delimiter has no effect on the marker shown in the rendered text. Using a different delimiter starts a new list.


1 Answers

As of VS Code 1.27, your best bet is to write an extension that adds decorators on the * characters to do this. Take a look at the decorator example extension to get started

I do not think the current vscode API allows you to overwrite the * text itself, but you can try emulate this by making the * character transparent and adding your custom bullet point after it:

const level1DecorationType = vscode.window.createTextEditorDecorationType({
    color: 'transparent',
    after: {
        contentText: "◦"
    }
});

Then your extension just has to apply this style to the bullet points in the document.

Unofficially, you can also use this decorator hack to replace the * character entirely:

const level1DecorationType = vscode.window.createTextEditorDecorationType({
    color: 'transparent',
    textDecoration: `none; display: inline-block; width: 0;`,
    after: {
        contentText: "◦"
    }
});

However that is not guaranteed to work properly or continue working in the future.

Consider opening a feature request to get better decorators support for this

like image 86
Matt Bierner Avatar answered Oct 07 '22 16:10

Matt Bierner