0

Does anyone know how to render the following tree preserving white spaces properly?

<html>
<head>
<meta charset="utf-8">
</head>
<body>
<span style="white-space: pre-wrap;">
└─--[TaskD-{'a': '0.28', 'b': '0.296', 'c': '0.364', 'e': '0.486'}]
    |---[TaskC-{'a': '0.28', 'b': '0.296', 'c': '0.364'}]
    |   └─--[TaskB-{'a': '0.28', 'b': '0.296'}]
    |       └─--[TaskA-{'a': '0.28'}]
    └─--[TaskE-{'c': '0.364', 'e': '0.486'}]
        |---[TaskF-{'c': '0.364'}]
        └─--[TaskG-{'c': '0.364'}]
</span>
</body>
</html>

Currently, it discards some of the w/spaces and breaks the nice tree:

enter image description here

tash
  • 711
  • 5
  • 13

1 Answers1

1

You need a monospace font, so no matter the character, the size it takes is the same for each characters

<span style="white-space: pre-wrap;font-family:monospace;">
└─--[TaskD-{'a': '0.28', 'b': '0.296', 'c': '0.364', 'e': '0.486'}]
    |---[TaskC-{'a': '0.28', 'b': '0.296', 'c': '0.364'}]
    |   └─--[TaskB-{'a': '0.28', 'b': '0.296'}]
    |       └─--[TaskA-{'a': '0.28'}]
    └─--[TaskE-{'c': '0.364', 'e': '0.486'}]
        |---[TaskF-{'c': '0.364'}]
        └─--[TaskG-{'c': '0.364'}]
</span>

Searching on the web, you'll find lots of monospace fonts, Choose the ones that fits your design best.

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129