Slack是否支持Markdown表? [英] Does Slack support Markdown tables?

查看:149
本文介绍了Slack是否支持Markdown表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用其postMessage API将Markdown表发送到Slack,但是我在Slack中获得了原始内容,而不是呈现的表. Slack是否支持Markdown表?红外线还有其他方法可以在Slack中显示表格数据吗?我知道Slack不支持HTML.

I want to send a Markdown table to Slack with its postMessage API, but I got raw content in Slack instead of a rendered table. Does Slack support Markdown tables? Ir is there any other way to present tabular data in Slack? I know Slack doesn't support HTML.

我尝试过chat.postMessagefiles.upload,也使用固定的列长来格式化文本,但是看起来有点难看,所以我想出一种方法来使它看起来更好.

I tried chat.postMessage and files.upload, also formatting text with fixed column length but it looks kind of ugly, so I am figuring out a way to make it look better.

这是我的HTTP请求代码,内容类型为JSON:

Here is my HTTP request code, content-type is JSON:

url : https://slack.com/api/chat.postMessage
body :
{
    "channel": "RKAID4I",
    "text": " | Tables  | Are   | Cool  |
|---------- |:-------------:    |------:    |
| col 1 is  | left-aligned  | $1600     |
| col 2 is  | centered  | $12   |
| col 3 is  | right-aligned     | $1    |"

}

我期望表格像格式一样,但是实际输出与我发送的完全一样.是因为我的Markdown消息错误还是Slack根本不支持Markdown表?

I was expect table like format, but the actual output is exactly as what I sent. Is it because my Markdown message is wrong or Slack simply doesn't support Markdown tables?

推荐答案

事实上,Slack完全不支持消息中的Markdown¹ .它使用自己类似的格式,称为mrkdwn 与Markdown有一些明显的区别:

In fact, Slack doesn't support Markdown in messages¹ at all. It uses its own similar-at-a-glance format called mrkdwn which has some notable differences with Markdown:

  • 在Markdown中,*_都用于强调
  • 在Markdown中,**__都用于粗体
  • mrkdwn中,*用于粗体,而_用于强调
  • Markdown 没有删除线语法(尽管某些实现已添加删除线,例如在使用~~ 的GFM,但mrkdwn使用~进行删除
  • 链接语法非常不同
  • mrkdwn不支持标题
  • 可能更多
  • In Markdown, both * and _ are used for emphasis
  • In Markdown, both ** and __ are used for bold
  • In mrkdwn * is used for bold and _ is used for emphasis
  • Markdown has no syntax for strikethrough (though some implementations have added it, e.g. in GFM which uses ~~) but mrkdwn uses ~ for strikethrough
  • Link syntax is very different
  • mrkdwn doesn't support headings
  • Probably more

不要期望任意Markdown²在Slack消息中起作用.

Don't expect arbitrary Markdown² to work in Slack messages.

¹Slack确实支持帖子中的Markdown,可以使用 files.upload API端点filetype设置为post.

¹Slack does support Markdown in posts which can be created using the files.upload API endpoint setting filetype to post.

²请注意,常规Markdown也不支持表格.像删除线一样,一些实现也添加了这些.

²Note that tables aren't supported in regular Markdown either. Like strikethrough, some implementations have added these.

这篇关于Slack是否支持Markdown表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆