الـ API لا يقبل جداول MarkDown

نحن نستخدم الحل المستضاف.

وصف المشكلة: استخدام واجهة برمجة التطبيقات (API) لإنشاء المنشورات. لقد عمل هذا بشكل مثالي خلال الأشهر الأربعة الماضية (آخر مرة كانت يوم الاثنين 11/3/19) حتى اليوم. قمت بإنشاء بعض الاختبارات البسيطة جدًا لتضييق نطاق المشكلة:

البيانات المرسلة عبر واجهة برمجة التطبيقات (API):

Col1 Col2
Col1data Col2data

صورة النتيجة:

لاحظ الفاصل المميز بين الرأس الأول والبيانات. تم تغييره بطريقة ما من ثلاثة شرطات إلى خط كامل. لم يتم تغيير الفاصل الثاني. أعتقد أن هذه هي المشكلة. لأن فاصل العمود الأول لم يعد يتكون من ثلاثة شرطات، فإنه لا يفسره كجدول من تنسيق Markdown بعد الآن. أنا فقط لا أعرف ما الذي يسبب تغيير الشرطات الثلاثة إلى هذه الأحرف (الخط).

يمكنني (إلى حد ما) تكرار هذا “تغيير الشرطات إلى خط” عند النشر يدويًا أيضًا. إذا قمت بإدخال هذا (لاحظ أن فاصل العمود الثاني يتكون من ثلاثة شرطات)… حسنًا، إنه كذلك حتى يتم نشره…
|Col1|Col2|
|___|—|
|Col1data|Col2data|

سيظهر المنشور فعليًا الفاصل الثاني الآن كخط كامل. نظرًا لأنني مستخدم جديد في هذا الموقع، فإنه يقول إنه لا يمكنني نشر أكثر من صورتين (هه؟)، لذا لا يمكنني إظهار الصورة الدقيقة، ولكن إليك رابط اختبار: https://try.discourse.org/t/test-table-cause-seeing-problem/1335

أعتقد أن أيًا كان ما يسبب تغيير الشرطات إلى حرف الخط، هو نفسه ما يؤثر على تغيير الشرطات الثلاثة في واجهة برمجة التطبيقات (API) أيضًا. لكن هذا كله مجرد تخمين.

هل يمكن لأحد المساعدة في توضيح هذا؟ 1) لماذا يحدث هذا؟ 2) هل تغير شيء ما مؤخرًا قد يكون سبب هذا؟

Try disabling the setting enable markdown typographer

إعجاب واحد (1)

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 إعجابات