slack
slack copied to clipboard
Unescape to get plain text
Is there any methods to achieve this as in https://github.com/slack-ruby/slack-ruby-client
We basically get the plain text from html
`Slack::Messages::Formatting.unescape('Hello & <world>'))
=> 'Hello & '
Slack::Messages::Formatting.unescape('Hey <@U024BE7LH|bob>, did you see my file?'))
=> 'Hey @bob, did you see my file?'
Slack::Messages::Formatting.unescape('Hey <@U02BEFY4U>'))
=> 'Hey @U02BEFY4U'
Slack::Messages::Formatting.unescape('This message contains a URL http://foo.com/'))
=> 'This message contains a URL http://foo.com/'
Slack::Messages::Formatting.unescape('So does this one: http://www.foo.com|www.foo.com'))
=> 'So does this one: www.foo.com'
Slack::Messages::Formatting.unescape('mailto:[email protected]|Bob'))
=> 'Bob'
Slack::Messages::Formatting.unescape('Hello <@U123|bob>, say hi to <!everyone> in <#C1234|general>'))
=> 'Hello @bob, say hi to @everyone in #general'
Slack::Messages::Formatting.unescape('Hello <@U123|bob> > file.txt'))
=> 'Hello @bob > file.txt'
Slack::Messages::Formatting.unescape('“hello”'))
=> '"hello"'
Slack::Messages::Formatting.unescape('‘hello’'))
=> "'hello'"`
despite some of those transforms being incorrect.... no currently not. though I do have a version lying around to get someone started if they wanted to do the work.
@james-lawrence I'd be happy to give this a go, I guess :)
if you want code to get started, here is a custom lexer/parser I've written, its obviously very customized to my use case but the lexer is self contained and the parser should be easy to change for your uses: parsing-slack.zip
been using it for a year or so, so its fairly well tested. at a minimum the tests will be useful =)