问题
I'm trying to create Posts with botkit
using the Slack api, but I can't find any documentation on how to format a Post
file in Slack.
bot.api.files.upload({
content: "# Heading",
filename: "test.md",
filetype: "post",
channels: "random"
});
Markdown formatting doesn't work for this, is there any syntax to formatting Slack Posts?
Trying with HTML the response from the created file is like this:
<document><p><document><h1>H1<\/h1><p><\/p><h2>H2<\/h2><p><\/p><h3>H3<\/h3><p><\/p><p>Text <i>italic<\/i> <b>bold<\/b> <a href="<a href=\"http:\/\/www.slack.com%22%3Elink%3C\/a%3E\">http:\/\/www.slack.com">link<\/a><\/a> <u>underline<\/u><\/p><p><\/p><p><strike>strikethrough<\/strike><\/p><p><\/p><p><code>Code Block;<\/code><\/p><\/document><\/p><\/document>
so it's escaping html tags.
回答1:
Posts support markdown formatting.
E.g., try setting the following content:
# A Post Header
### Subheading
An image? 
[A link to google](https://www.google.com)
* A list item
* Another list item
`a code block`
You then post with filetype="post"
, and get the following:
I tested and slack appears to support most markdown features but not all. Make sure to test your formatting!
来源:https://stackoverflow.com/questions/38063489/formatting-posts-with-the-slack-api