# Substring and html in the db

**URL:** <https://www.ruby-forum.com/t/substring-and-html-in-the-db/89675>\
**Category:** Rails\
**Created:** [March 29, 2006, 1:26am UTC](https://www.ruby-forum.com/t/substring-and-html-in-the-db/89675 "2006-03-29T01:26:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![typej](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f1d935/32.png) [@typej](https://www.ruby-forum.com/u/typej)\
**Post date:** [March 29, 2006, 1:26am UTC](https://www.ruby-forum.com/t/substring-and-html-in-the-db/89675/1 "2006-03-29T01:26:22Z")

</div>

Hey guys,

Ran into a snag today and was wondering if anyone can give me a hand. I  
have  
a blog type application that I’m developing. There is a page “list all  
entries” which looks like this:

Title1  
posted by Person1 about 2 hours ago  
test1 test1test1 test1test1 test1test1 test1test1 test1test1 test1test1  
test1… (click here for full post)

Title2  
posted by Person1 about 2 hours ago  
test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1  
test1 test1…(click here for full post)

I “preview” the news entries by displaying the first 200 characters of  
the  
body of each entry, with a …(click here for full post)  
The problem is when I introduce HTML code into the body. If for example,  
I  
am in the middle of a hyperlink \< a \> tag when cutting off at the 200th  
character, the HTML breaks the whole page.

Options: write some type of UBB thing, not allowing html and instead  
stuff  
like [link] and [img]

My question is, has anyone tackled this? DRY is the name of the game =)  
Thank you very much,  
Jin
