0

I'm using jekyll which in turn uses kramdown to convert markdown into html and I can't get the following example to render correctly: I used \t to show a tab, \s to show a space

*\tHere is some code in a list:

\t```python
\tdef bar():
\t\treturn 4;
```

and it should render like

  • Here is some code in a list:
    def bar():
    \treturn 4;
    

however i end up with

  • Here is some code in a list:
    def bar():
    \s\s\s\sreturn 4;
    

The issue here for me is that I'd like to use the css attribute tab-size to configure the width of the tabs but this obviously doesn't work for spaces.

I'm assuming this is to do with kramdown's assumption that tabs are 4 spaces wide?

I've also tried to indent the heading of the list with various amounts of tabs as Embed a code block in a list item with proper indentation in kramdown suggests, but without any luck.

Is there some option to forbid kramdown replacing tabs with spaces? Or some other way to stop it from doing this?

Poohl
  • 1,932
  • 1
  • 9
  • 22
  • 1
    [The docs](https://kramdown.gettalong.org/syntax.html#usage-of-tabs) only say "1 tab is 4 spaces", but I wonder if you could get what you want by switching to the GFM (GitHub flavoured Markdown) parser? This is set in `_config.yml`, in `kramdown.input` (set to `GFM`). – Benjamin W. Jan 05 '23 at 19:29

1 Answers1

0

Not a perfect solution, but one that produces the desired output:

By indenting using spaces the tabs are preserved as I want.

so

*\sHere is some code in a list:

\s\s```python
\s\sdef bar():
\s\s\treturn 4;
\s\s```

produces the desired output for some reason. This might however not be stable, as https://kramdown.gettalong.org/syntax.html#usage-of-tabs explicitly states that "the results [of tabs after spaces] may be unexpected".

@Benjamin w. GFM behaves exactly the same from my testing.

Poohl
  • 1,932
  • 1
  • 9
  • 22