table 单元格中的多行文本使用 bootstrap

Multiline text in a table cell using bootstrap

我想使用 bootstrap 将一长段字符串显示到 table 单元格中。它包含一些换行符 \r\n。我尝试按照 this Whosebug post 的建议使用 style="white-space:pre",但这打破了 bootstrap 文本换行。我也尝试将 \r\n 更改为 <br> 但它不起作用。 <br> 显示为文本。

这就是我的 table 的样子..

<table id="table1" class="table table-bordered">
    <tbody>
        <tr>
            <th class="col-md-2" scope="row">Description</th>
            <td id="description">Very long test with \r\n so I want to show this in multiline and also want to wrap the text using bootstrap.</td>
        </tr>
    </tbody>
</table>

将分页符更改为 HTML 分页符(br 标记)在 jsfiddle 中工作正常。请参阅下面我的 link。确保在生成 HTML 时生成的是实际的 < 和 > 符号,而不是 HTML 代码。

https://jsfiddle.net/joedonahue/zpj94p0b/

<table id="table1" class="table table-bordered">
    <tbody>
        <tr>
            <th class="col-md-2" scope="row">Description</th>
            <td id="description">Very long test with <br/> so I want to show this in multiline and also want to wrap the text using bootstrap.</td>
        </tr>
    </tbody>
</table>