Convert bullet list to HTML unordered list.

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
loulesko
Posts: 124
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Convert bullet list to HTML unordered list.

Post by loulesko »

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: Select all

#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
Post Reply