ChatGPT解决这个技术问题 Extra ChatGPT

How do I add a newline in a markdown table?

I have the following cells in a markdown table:

something something that's rather long and goes on for a very long time something else

I'd like to be able to insert a break in the middle line, so the middle column isn't so large. How can I do that in Markdown? Do I need to use HTML tables instead?

When using <br> be careful that you don't leave any space in the front(indentation). I've had the same problem but when I removed the tab space it worked.

m
mikemaccana

Use an HTML line break (<br />) to force a line break within a table cell:

| something | something that's rather long and <br />goes on for a very long time | something else |
|-----------|---------------------------------------------------------------|----------------|

Rendered:

something something that's rather long and goes on for a very long time something else


The <BR> syntax works only when you convert to HTML - at least in pandoc.
The <br> syntax also works on GitLab, which uses Redcarpet Ruby library for Markdown processing (reference)
To whomever edited this answer on 14 November 2020: You have introduced a syntax error by adding a backslash to the tag. Backslashes don't close tags in HTML. I can't edit the answer myself because of the minimum character limit.
m
mb21

When you're exporting to HTML, using <br> works. However, if you're using pandoc to export to LaTeX/PDF as well, you should use grid tables:

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+

Sublime Text has a nice package for this: packagecontrol.io/packages/Table%20Editor It is no longer maintained, but everything is still fine with it!
Why didn't they invent this from the very beginning into markdown?!
I'm using Markdown Preview Extended in VSCode to generate PDF with LaTeX via Pandoc. I put \newline (a LaTeX command) inside the table, which passes through because there is an option to allow raw tex. However, this text appears in the preview browser.
J
James Graham

Use <br/> . For example:

Change log, upgrade version

Dependency | Old version | New version |
---------- | ----------- | -----------
Spring Boot | `1.3.5.RELEASE` | `1.4.3.RELEASE`
Gradle | `2.13` | `3.2.1`
Gradle plugin <br/>`com.gorylenko.gradle-git-properties` | `1.4.16` | `1.4.17`
`org.webjars:requirejs` | `2.2.0` | `2.3.2`
`org.webjars.npm:stompjs` | `2.3.3` | `2.3.3`
`org.webjars.bower:sockjs-client` | `1.1.0` | `1.1.1`

URL: https://github.com/donhuvy/lsb/wiki


E
ElChiniNet

Just for those that are trying to do this on Jira. Just add \\ at the end of each line and a new line will be created:

|Something|Something else \\ that's rather long|Something else|

Will render this:

https://i.stack.imgur.com/c5PXL.png

Source: Text breaks on Jira


Nice answer. Also here's a hug for having to use JIRA: 🤗
Unfortunately it does not work in other markdown viewers I use (e.g. Bitbucket.org or Markdown viewer Chrome browser extension by Simov)