Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Jenny Swift
Jenny Swift
21,999 Points

converting lots of text to html efficiently

Hi, Can anyone please recommend an efficient method of converting text to HTML? In other words, if I have a lot of text that I copy and paste into a text editor, it's quite tedious to go through every paragraph to wrap it with a <p></p> tag, and I thought there must be a better way of doing that. And then there's also converting punctuation into HTML punctuation, so it would be great if there was an easy way of selecting all instances of a punctuation mark and converting them all at once.

3 Answers

Jenny Swift
Jenny Swift
21,999 Points

Thanks, that looks fantastic!

If you are using SublimeText, you can highlight a particular string of text while holding the ctrl key and then you can replace all instances in one go. There are a number of other shortcuts available for SublimeText, so I recommend checking out their video and list of shortcuts and see if any would help in your process?

Jenny Swift
Jenny Swift
21,999 Points

Thank you. It sounds like that would work fine for converting punctuation, but do you think it would work for wrapping all the paragraphs in p tags, because that's different to replacing all instances of a selection?

When you highlight a section of text, you can use regular expression replacement instead of just highlighted string replacement. For example, if you were to replace,

"\n"

as a regularly expression with

</p>\n

then you could replace all the 'ends of lines' with closing p tags. Likewise you might decide that instead of just a closing p tag, you could replace it with a closing p, new line and opening p tag. Combinations of regular expression replacements and text highlighting can make some tedious tags a little more bearable. Sublime supports both types and has more guides on shortcuts for text manipulation.