filmnut
filmnut

Reputation: 756

Trello API: Programatically Adding Line Breaks to Card Descriptions

When manually entering a Trello card's description, it's easy to introduce line breaks: just press ENTER. However, I need to introduce line breaks when setting a card's description via the Trello API. So far, \n and < br > don't get parsed. Any ideas?

Upvotes: 7

Views: 4465

Answers (7)

Antony
Antony

Reputation: 4364

(In PHP) If you use $url .= '?'.http_build_query($params); and pass in your list of parameters this way, PHP will URL encode your values and as long as your description is in " " (double quotes not single ' ') you can pass a \n which will correctly convert.

Upvotes: 0

Wesley
Wesley

Reputation: 1

Here '\x0A' works in python very well.

So..

PHP: PHP_EOL (= \n) .NET: Environment.NewLine JS / PYTHON: \x0A URl linebreak: %0A

Upvotes: 0

Bert H
Bert H

Reputation: 1147

You can try with whatever works best in your current language.

So far, known working line breaks are:

  • PHP: PHP_EOL (= \n)
  • .NET: Environment.NewLine
  • JS: \x0A
  • URl linebreak: %0A

Upvotes: 1

Faye
Faye

Reputation: 63

Struggled with this problem for ages. The php in WisdmLabs' answer works if it's passed as php to an element and then to js through getElementByID, but that's not possible if you need to set the variable clientside.

Finally found \x0A works in js.

Hope this saves someone from the hours of googling I endured!

Upvotes: 5

James
James

Reputation: 91

If you happen to find this and are looking to add a line break using the URL from the API, use %0A.

For example:

https://api.trello.com/1/cards?key=(key)&token=(token)&name=(card name)&desc=Line 1 %0A Line 2 %0A Line 3&idList=<id>

Upvotes: 9

Domain
Domain

Reputation: 11808

Hi I got the solution to add Line break in trello card description, if you are using php.
Try like this,

$card_desc =  $some_text . "\xA" . $some_more_text; 

Upvotes: 2

filmnut
filmnut

Reputation: 756

I figured it out. I'm coming from .NET, so I used concatenation around Environment.NewLine calls to introduce new lines. Trello respected these as line breaks.

Upvotes: 1

Related Questions