eldargab/easy-table

Set column width for Hyperlinks with Slack adapter

Closed this issue · 1 comments

Hi @eldargab ,

Let's say I have a text 'Click here' in a table cell. Now, if I want to link this to, say google.com, the actual text in the table cell be prefixed with hyperlink formatting as per slack's specification mentioned here.

So the code for table cell be something like,

t.cell('label', '<http://www.google.com|Click here>');

The hyperlink part works fine when sent to slack but the width of that column considers the actual text including the URL, <http://www.google.com|Click here>, as expected and hence is very long when the actual cell content is only 'Click here'. Is there a way I can set the column width to avoid this? Not sure if printer can be used here.

Thanks!

Hello,

yes, printer is definitely enough to handle this. For example

function link(s, len) {
  if (len != null) return s
  var last = s.split('|')[1]
  return last.slice(0, last.length - 1)
}

t.cell('label', '<http://www.google.com|Click here>', link)