问题
I am trying to match a mock-up of a Slack API message that has a greater-than (>) character in a link at the start of an attachment text line. The mock-up also uses italics and bold in the attachment text, so I have text
in the mrkdown_in
array. Unfortunately, this causes Slack to interpret >
or >
as a blockquote character when it occurs at the start of a line. Does anyone know how to work around this?
I could use small greater-than (﹥) or full-width greater-than (>), but it seems silly that I can't figure out how use the standard greater-than (>).
Here is a Slack sandbox message JSON that reproduces the problem I am having: https://api.slack.com/docs/messages/builder?msg=%7B%22attachments%22...
Here is my JSON message from the above URL:
{
"attachments": [
{
"text": "_First line (needs to be italic)_\n<http://google.com|> There should be a \">\" at the start of this line>",
"mrkdwn_in": [ "text" ]
}
],
"text": "How do I display a greater-than character at the start of the link below?"
}
Here is how Slack renders my message, with some annotation from me in red: annotated image
回答1:
A partial solution is to enter a vertical tab (\u000b
) before the greater-than-symbol. This apparently has the effect of escaping the greater-than symbol.
However, this does not work inside the link, so you have to move the vertical tab and the greater-than-symbol outside of it.
Example:
"text": "_First line (needs to be italic)_\n\u000b><http://google.com|There should be a \">\" at the start of this line>"
Full example here: Message Builder
Other "invisible" characters will work too. The question author found that \u200a
(hair space) worked best for him.
I found the original solution for this problem on another Stack Exchange community: link
来源:https://stackoverflow.com/questions/46331295/how-to-display-a-greater-than-symbol-at-the-start-of-a-slack-attachment-line-wit