2016-06-09 4 views
0

Ich tue dies:Warum gibt Github API meinen Markdown falsch aus?

curl -X POST -d @a.md https://api.github.com/markdown/raw --header "Content-Type:text/x-markdown" > a.html 

a.md

# Hello, world! 
### This is markdown! 
How are you doing? 

a.html

<h1> 
<a id="user-content-hello-world-this-is-markdownhow-are-you-doing" class="anchor" href="#hello-world-this-is-markdownhow-are-you-doing" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Hello, world!### This is markdown!How are you doing?</h1> 

a.html

Rendered

Hallo, Welt ##! # Das ist Markdown! Wie geht es dir? machen?

Ich habe sogar versucht, im Windows-Stil cr/lf Zugabe nicht helfen:

CR=$(printf '\r') 
sed "s/\$/$CR/" a.md > b.md 

Was mache ich falsch?

Die Dokumente für Github API für Markdown sind here.

Antwort

1

Paar Dinge ...

Zuerst Ihre a.md Datei wie folgt aussehen muss:

{ 
    "text" : "# Hello, world!\n 
    ### This is markdown!\n 
    How are you doing?", 
    "mode" : "markdown", 
    "context" : "none" 
} 

Zweitens Sie anrufen Abschlags roh, das wird nicht helfen, die folgende CURL Anfrage für mich gearbeitet:

curl --data @a.md https://api.github.com/markdown > a.html 

Die Ausgabe für mich von diesem Befehl mit dieser Datei ist:

<h1> 
<a id="user-content-hello-world" class="anchor" href="#hello-world" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Hello, world!</h1> 

<h3> 
<a id="user-content-this-is-markdown" class="anchor" href="#this-is-markdown" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>This is markdown!</h3> 

<p>How are you doing?</p> 

Hoffe, das hilft!

+0

Vielen Dank! Es funktionierte. Eine kleine Korrektur, "###", muss in Spalte 1 beginnen. –

+0

Also, wie kommt es, dass der Rohmodus nicht funktioniert hat? Ich muss es immer noch funktionieren lassen –

+0

'curl -X POST -H" Inhaltstyp: text/x-markdown "https://api.github.com/markdown/raw-data @ a.md> a.html 'wo a.md ist eine rohe MD-Datei. Wofür verwenden Sie das? Weil sogar dieser Befehl, der auf einer tatsächlichen README verwendet wird, ein ziemlich blecheres Rendering ist. –

Verwandte Themen