nisus.com
https://www.nisus.com/forum/

Convert bullet list to HTML unordered list.
https://www.nisus.com/forum/viewtopic.php?f=17&t=4164
Page 1 of 1

Author:  loulesko [ 2011-03-27 14:04:16 ]
Post subject:  Convert bullet list to HTML unordered list.

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

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/