Search code examples
markdownword-wrapoctopress

markdown table with long lines


I am using markdown in order to create a table. My Description column contains very long texts and therefor it looks very bad on the markdown file when I wrap lines:

Argument            | Description |
--------            | ----------- |
appDir              | The top level directory that contains your app. If this
option is used then it assumed your scripts are in |a subdirectory under this path. This option is not required. If it is not specified, then baseUrl below is the anchor point for finding things. If this option is specified, then all the files from the app directory will be copied to the dir: output area, and baseUrl will assume to be a relative path under this directory.  
baseUrl             | By default, all modules are located relative to this path. If baseUrl is not explicitly set, then all modules are loaded relative to the directory that holds the build file. If appDir is set, then baseUrl should be specified as relative to the appDir.
dir                 | The directory path to save the output. If not specified, then the path will default to be a directory called "build" as a sibling to the build file. All relative paths are relative to the build file. 
modules             | List the modules that will be optimized. All their immediate and deep dependencies will be included in the module's file when the build is done. If that module or any of its dependencies includes i18n bundles, only the root bundles will be included unless the locale: section is set above. 

I want to wrap lines since it is more readable for me.
Is there a way to make the table more readable for the editor?


Solution

  • I believe @Naor is right: You must use HTML to create line breaks, though that is not demonstrated in the answer. And the full table code displayed is not strictly necessary: To achieve a line break you only need double space or <br /> tag. From the Markdown spec:

    Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br /> tag.

    When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

    Note that I had to add code wrappers to the text because the SO-flavored Markdown requires HTML break tags are escaped - so we know <br /> works.

    But, if you want to do something a bit more complex, like I am* you can set various properties with HTML like so:

    <table width="300">
      <tr>
        <td> This is some text </td>
        <td> This is some somewhat longer block of text </td>
        <td> This is some very long block of text repeated to make it even longer. This is some very long block of text repeated to make it even longer. This is some very long block of text repeated to make it even longer.  </td>
      </tr>
    </table>
    

    I tried adding style="width:75%" to the <td>s, to no affect.

    *I should note I came across this because I am having similar problems writing code within tables using GitHub-flavored Markdown, which is very painful. But I'm noting this because it should color the examples I give: Any thing I say 'works' or 'doesn't work' comes from that environment.

    EDIT: It might be further worth noting this is irrelevant if you have code blocks within your table. This isn't an issue with Markdown though: HTML <code></code> blocks cause the table to stretch.