Convert tabbed text to html unordered list?

前端 未结 4 635
难免孤独
难免孤独 2021-01-03 03:11

I\'m a beginner programmer so this question might sound trivial: I have some text files containg tab-delimited text like:

A
    B
    C
        D
        E
<         


        
4条回答
  •  失恋的感觉
    2021-01-03 04:14

    I think the algorithm goes like this:

    • keep track of the current indentation level (by counting the number of tabs per line)

    • if the indentation level increase: emit

      • current item
      • if the indentation level decreases: emit

      • current item

    • if the indentation level remains the same: emit

    • current item

    Putting this into code is left to the OP as exercise

提交回复
热议问题