2013-04-11 11 views
8

Sto usando markdown per creare una tabella. Il mio Descrizione colonna contiene testi molto lunghi e per questo sembra molto male sul file Markdown quando ho avvolgere le linee:tabella di ribasso con linee lunghe

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. 

voglio per avvolgere le linee dal momento che è più leggibile per me.
C'è un modo per rendere la tabella più leggibile per l'editor?

risposta

2

Credo @Naor ha ragione: è necessario utilizzare HTML per creare interruzioni di riga, anche se questo non è dimostrato nella risposta. E il codice completo della tabella visualizzato non è strettamente necessario: per ottenere un'interruzione di riga è necessario solo un doppio spazio o il tag <br />. From the Markdown spec:

Markdown supporta i paragrafi di testo "hard-wrapped". Questo differisce in modo significativo dalla maggior parte degli altri formattatori da testo a HTML (compresa l'opzione "Converti interruzioni di riga" del tipo di Movable Type) che traduce ogni carattere di interruzione di riga in un paragrafo in un tag <br />.

Quando si desidera inserire un tag di interruzione <br /> utilizzando Markdown, si termina una riga con due o più spazi, quindi digitare return.

Si noti che ho dovuto aggiungere wrapper di codice per il testo, perché il Markdown SO-aromatizzato richiede tag di interruzione HTML sono fuggiti - quindi sappiamo <br /> opere.

Ma, se si vuole fare qualcosa di un po 'più complessa, come lo sono io * è possibile impostare varie proprietà con il codice HTML in questo modo:

<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> 

Ho provato ad aggiungere style="width:75%" ai <td> s, per non influenzare .

* Devo notare che mi sono imbattuto in questo perché ho problemi simili scrivere codice all'interno delle tabelle usando Markdown GitHub, che è molto doloroso. Ma lo sto notando perché dovrebbe colorare gli esempi che ho dato: ogni cosa che dico "funziona" o "non funziona" viene da quell'ambiente.

MODIFICA: Potrebbe essere anche la pena notare che questo è irrilevante se si dispone di blocchi code all'interno della tabella. Questo però non è un problema con Markdown: i blocchi HTML <code></code> fanno sì che la tabella si allunghi.

2

Purtroppo è necessario usare l'HTML per questo

<table> 
<tr> 
<th>Argument</th> 
<th>Description</th> 
</tr> 
<tr> 
<td>appDir</td> 
<td>The top level directory that contains your app. If this option is used then 
it assumed your scripts are in</td> 
</tr> 
<tr> 
<td>baseUrl</td> 
<td>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.</td> 
</tr> 
<tr> 
<td>dir</td> 
<td>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.</td> 
</tr> 
<tr> 
<td>modules</td> 
<td>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.</td> 
</tr> 
</table> 
+0

Cerco di evitare questo .. Qual è il punto utilizzando html .. Non è un carattere che contrassegna la prossima linea è continuare la linea corrente? – Naor

1

Ciao mi stavo chiedendo la stessa cosa. Avevo bisogno di questo per un file di documentazione e questo è il modo in cui ho a che fare con questo:

| key | description      | 
| --- | ---        | 
| foo | bla bla blabla bla blabla bla bla | 
|  | bla bla blabla bla bla bla bla bla | 
| bar | something else bla     | 

Sono d'accordo con Sam nella domanda di cui sopra che Markdown supponiamo di essere "Hard-wrapped" lingua e non per questo è barare (immagino che non sia un Markdown valido).Ma per esempio in diversi Github progetti README.md file che ho visto la gente avvolgendo voci di elenco come questo:

* foo 
* bla bla bla bla bla bla bla bla bla bla 
    bla bla bla bla bla bla bla bla bla 

Anche il mio college ha sottolineato che http://www.tablesgenerator.com/markdown_tables stava avvolgendo tavolo modo simile (grazie Tom)

Quindi quello che penso è ok per usare il mio esempio se stai facendo qualcosa che non sarà analizzato (come la documentazione di Github) ma non dovresti andare a capo se stai facendo un parser Markdown su HTML o tabella di test di Cucumber.

Ma potrei sbagliarmi

+0

questa variante tabella genererà un 'tr' separato per la seconda linea "bla bla"(almeno per Jekyll/GH-pagine e https://dillinger.io/) ' bla bla blabla bla bla bla bla bla bla ' – thybzi

+0

Credo che Octopress abbia lo stesso comportamento di parsing – thybzi

2

C'è un'altra opzione. Poiché la filosofia è che Markdown dovrebbe essere leggero, non un linguaggio di markup e destinato al consumo umano naturale (in contrasto con i formati in stile SGML/HTML), credo sia giusto e naturale ricorrere all'arte ASCII per casi speciali .

Per questo particolare compito, l'arte del personaggio è naturale. Quindi, fai rientrare il tuo tavolo con quattro spazi, formattalo per renderlo leggibile e Markdown lo tratterà solo come testo pre-formattato, ed entrambe le parti possono smettere di combattersi a vicenda.

Ad esempio:

| Sequence | Result              | 
|-------------|---------------------------------------------------------------| 
| `a?c`  | Matches `abc`, `axc`, and `aac`. Does not match `ac`, `abbc`, | 
|    | or `a/c`.              | 
|-------------|---------------------------------------------------------------| 
| `a*c`  | Matches "ac", "abc" and "azzzzzzzc". Does not match "a/c". | 
|-------------|---------------------------------------------------------------| 
| `foo...bar` | Matches "foobar", "fooxbar", and "fooz/blaz/rebar". Does not | 
|    | match "fo/obar", "fobar" or "food/bark".      | 
|-------------|---------------------------------------------------------------| 
| `....obj` | Matches all files anywhere in the current hierarchy that end | 
|    | in ".obj". Note that the first three periods are interpreted | 
|    | as "...", and the fourth one is interpreted as a literal "." | 
|    | character.             | 
|-------------|---------------------------------------------------------------| 

... e fatto.

+0

** Avviso per lettori veloci! ** Non usare questo se si ha bisogno di ottenere una tabella' HTML' vale a dire. Questo è quello di generare una sorta di tabella di arte ASCII. Usando fuori blocco quattro spazi indentati (o '' '-wrapped block in GFM), otterrai un' tr' separato per ogni riga (e un 'tbody 'separato dopo ogni riga di trattino) – thybzi

Problemi correlati