How do I insert a referenced block of text in markdown?

89 views Asked by At

I have a markdown table that uses <br> to get around the lack of support for rowspan. I can't use an HTML table.

The table works by using line breaks (sort of), but the cells are quite ugly in markdown because it's one very long line of cell entries and multiple <br> tags. Ideally, I want to just have a raw table like this:

| Column1 | Column2 | Column3 |
| :---: | :--- | :---: |
| Item1 | [line1A] | [line1B] |

...where [line1A] and [line1B] represent lines of text with multiple <br> line breaks that I can edit individually. This makes my table more readable in markdown and I can edit just the single lines as needed.

For example, [line1A]: foo1<br>foo2<br>foo3

The rendered result should look like this:

Column1 Column2 Column3
Item1 foo1
foo2
foo3
bar1
bar2
bar3

I want the referenced line of text to be in the same file as the table, but only visible in the table when rendered.

I've tried using <div> and [!INCLUDE] but I am not doing this right or it isn't working.

2

There are 2 answers

1
thefrench On

If I understand correctly what you want. You should write this :

| Column1 |   Column2 |   Column3 |
| :---: |   :---    |   :---:   |
| Item1   |   <ul><li>foo1</li><li>foo2</li><li>foo3</li></ul>   | [line1B] |
0
Greg Lindsay On

After trying several more things, I found it is only possible to use !INCLUDE to accomplish what I want, given my restrictions that I can't use HTML.

Unfortunately INCLUDE requires that you reference a separate file. Ideally, INCLUDE could allow (an unrendered) reference to a section in the same article, but this isn't currently possible on Github.

Creating a separate file with the cell contents is definitely an option, but my goal is to make things simpler here, and adding another file doesn't accomplish that.