Is there a way to effectively transform a string that resembles the following format:
'* [-]Tree Item1',
'** [-]Tree Item1-1',
'*** Tree Item1-1-1',
'*** Tree Item1-1-2',
'*** Tree Item1-1-3',
'** Tree Item1-2',
'*** Tree Item1-2-1',
'** Tree Item1-3',
'* Tree Item2',
'** [-]Tree Item2-1',
'*** Tree Item2-1-1',
'**** Tree Item2-1-1-1',
'* Tree Item3'
into an HTML unordered list structured like this:
<ul>
<li>
Tree Item1
<ul>
<li>Tree Item1-1</li>
...
<ul>
</li>
<li>
Tree Item2
<ul>
<li>Tree Item2-1</li>
...
<ul>
</li>
...
</ul>
If you have suggestions or solutions, they would be greatly appreciated.
PS: Markdown libraries are not an option for my specific needs. I am looking for an algorithm that can accomplish this task.