Reply to topic  [ 1 post ] 
Convert bullet list to HTML unordered list. 
Author Message
User avatar

Joined: 2008-01-20 11:08:35
Posts: 89
Location: California
This set of find and replace regex expressions finds multiple bullet lists in a document an converts them to a UL list in HTML. It's part of a macro that I use to convert text to blog friendly HTML formatting for posting.
Code:
#Convert Bullet Lists to HTML List
Find and Replace '•\t.+', '<li>\0</li>', 'EaW'
Find and Replace '•\t', '', 'EaW'
Find and Replace '</li>(?=(?:.|\n)([^<]+)|\z|(?:.|\n)\z)', '</li></ul>', 'EaW'
Find and Replace '(?<!</li>\n)<li>', '<ul>\0', 'EaW'


It works by finding all the bullet list items and wrapping them in <li> tags. Then it removes the nisus bullets, then it finds the last </li> of each list and put a closing </ul> tag, then it finds the first <li> tag of each bullet list and puts a <ul> in front of it.

Update: fixed a small bug. The closing <ul> did not have a "/" - it's been fixed above.

Lou


2011-03-27 14:04:16
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software