0

I've implemented the solution explained in this post How to get tweet's HTML with LinqToTwitter? but when I display my tweets the HTML links appear like this

<a class="inline" href="http://twitter.com/cgitosh" target="_blank">@cgitosh</a> And how are you?

instead of just showing @cgitosh And how are you? with @cgitosh linking to the twitter account.

What I'm I not doing right?

Razor code snipet:

@{var tweet = TwitterExtensions.Text2Html(item.Text);}
<div>@tweet</div>

So I basically pass the tweet text to the Text2HTML function which is explained in the link provided above which returns the tweet with links to the variable tweet which I then output in my view

Community
  • 1
  • 1
cgitosh
  • 313
  • 3
  • 12

2 Answers2

1

Try like this:

<div>@Html.Raw(tweet)</div>

The Html.Raw method will not HTML encode the output which is what Razor does by default.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

Try:

@{var tweet = TwitterExtensions.Text2Html(item.Text);}
<div>@(new HtmlString(tweet))</div>

...and unless you're using tweet elsewhere, you could just do

<div>@(new HtmlString(TwitterExtensions.Text2Html(item.Text)))</div>

Razor by default HTML encodes strings, so you have to explicitly tell it to render it as markup. (See here.) Hope this helps!

antinescience
  • 2,339
  • 23
  • 31