API non accetta tabelle MarkDown

Utilizziamo la soluzione ospitata.

Descrizione del problema: Utilizzare l’API per pubblicare post. Questo ha funzionato perfettamente negli ultimi 4 mesi (l’ultimo il lunedì 11/03/2019) fino a oggi. Ho creato alcuni test molto semplici per isolare il problema:

Dati inviati tramite API:

Col1 Col2
Col1data Col2data

Immagine del risultato:

Notate il separatore intestazione/dati evidenziato nella prima colonna. In qualche modo è stato modificato da tre trattini a una linea piena. Il secondo separatore non è stato modificato. Credo che questo sia il problema. Poiché il separatore della prima colonna non è più composto da tre trattini, non viene più interpretato come una tabella Markdown. Non so solo cosa causi il cambiamento dei tre trattini in questi caratteri di linea.

Posso (in parte) replicare questo “cambiamento dei trattini in una linea” anche quando pubblico manualmente. Se inserisco questo (notate che il separatore della seconda colonna è composto da tre trattini)… beh, lo è fino a quando non viene pubblicato…
|Col1|Col2|
|___|—|
|Col1data|Col2data|

Il post mostrerà effettivamente il secondo separatore ora come una linea piena. Dato che sono un nuovo utente su questo sito, mi dice che non posso pubblicare più di due immagini (eh?), quindi non posso mostrare l’immagine esatta, ma ecco un URL di test: https://try.discourse.org/t/test-table-cause-seeing-problem/1335

Credo che ciò che causa il cambiamento dei trattini nel carattere di linea sia anche ciò che influenza il cambiamento dei tre trattini nell’API. Ma è tutto un’ipotesi.

Qualcuno può per favore aiutare a fare chiarezza su questo? 1) Perché sta succedendo? 2) È cambiato qualcosa di recente che potrebbe aver causato questo?

Try disabling the setting enable markdown typographer

1 Mi Piace

Thanks for the quick reply Rafael. That definitely got back the 3 dashes, but it still displays as plain text, instead of converting it to a table, like I would expect. So, quite possibly, what I thought was the issue was not :-(. Any other suggestions as to why this may not be displaying correctly as a table after posting thru the API?

image

Can you share the exact content of the post sent to the API here?

Not really - it’s a a PS script…the first line tho shows the data being passed in, and the result shown above…

 $HTMLTableAll = '|Col1|Col2|<br>|---|---|<br>|Col1data|Col2data|'

#Create Discourse JSON Body for posting new Topic
$DiscourseBodyJSON = @{}
$DiscourseBodyJSON.Add("title","Test - please ignore")
$DiscourseBodyJSON.Add("raw",$HTMLTableAll)
$DiscourseBodyJSON.Add("category",$TFOCategoryID)
$DiscourseDevNoteJSON = $DiscourseBodyJSON | ConvertTo-Json
$URI = $TWDomain + "posts.json" + $DiscourseCredsURI

Show-Log -LogType Txt -LogText $URI
Show-Log -LogType Txt -LogText $HTMLTableAll

$PostNote = @{Method     = 'POST'
             Uri         = $URI  
             ContentType = "application/json"
             Headers     = @{Authorization = "Basic " + [System.Convert]::ToBase64String($DiscourseUserEnc)}
             Body        = $DiscourseDevNoteJSON
            }

Result:

Actually, I have this working again. I think that settings change actually did fix this issue. Thanks for the help!

Only thing that jumps to me is that we use \n for line breaks in the API instead of <br>.

Anyway, since it’s working already, keep going.

4 Mi Piace