Slack是否支持Markdown表?

编程入门 行业动态 更新时间:2024-10-22 13:49:51
本文介绍了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.postMessage和files.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 : slack/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表?

本文发布于:2023-10-16 05:40:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496660.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Slack   Markdown

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!