Is there a way of indenting table in markdown

7.1k Views Asked by At

I'm using the showdown.js 1.7.3 for markdown

I want to be able to indent tables in a list, is there a way of doing this with showdown, if not does anyone know of any other markdown library where it is possible to indent tables in a listenter image description here

1

There are 1 best solutions below

0
On

It is possible to do it with showdown. Check the demo here

Here's also a snippet showing how to do it.

var conv = new showdown.Converter({tables: true});
var html = conv.makeHtml(document.getElementById('src').value);
document.getElementById('otp').value = html;
document.getElementById('otp2').innerHTML = html;
table {
    border-collapse: collapse;
}

table, th, td {
    border: 1px solid black;
}
th {
  background-color: lightgray;
}

th, td{
  padding: 5px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.8.3/showdown.js"></script>
<textarea id="src">
- foo

    | foo | bar | baz |
    |-----|-----|-----|
    | bla | bli | blu |

- baz
</textarea><br>
<textarea id="otp"></textarea><br>
<div id="otp2"></div>