Skip to content
Advertisement

How to get the indented text from the Twitter API?

I’m using the followin cURL request to get all tweets from an account:

JavaScript

I’m now getting the following array:

JavaScript

My problem is that, when rendering the full_text of the tweet, the text does not follow the original indentation, since it renders like this. 1

How to display the original indentation of the tweet?

EDIT: I have the following HTML to display the text:

JavaScript

EDIT 2: according to @Pascal comment, I added <pre> tag in my <p>.

Here’s what is displayed:

enter image description here

But that’s not what I want, since I don’t want the user to have to scroll to see the text.

Advertisement

Answer

I found out how to do this. It’s ugly, but it works:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement