d0c-s4vage / lookatme

An interactive, terminal-based markdown presenter
https://lookatme.readthedocs.io/en/latest/
MIT License
2.06k stars 59 forks source link

3.0 - Adds better HTML rendering #213

Closed d0c-s4vage closed 1 year ago

d0c-s4vage commented 1 year ago

This PR changes the default html rendering to use spans with padding set to a specific number of monospace character widths instead of   for all spaces. This makes the text of the html (especially code snippets) easier to copy+paste.

Examples

Markdown like this:

This is markdown

```
 code   block
```

was originally rendered into this:

<span style="color: #ffffff; background-color: #000000">Test</span>&nbsp;&nbsp;&nbsp; ...
<span style="color: #ffffff; background-color: #000000">&nbsp;&nbsp;&nbsp;&nbsp; ...
<span style="color: #f8f8f2; background-color: #272822">&nbsp;code&nbsp;&nbsp;block</span><span style="background-color: #272822">&nbsp;&nbsp; ...

but is now rendered into this:

</span><span style="color: #ffffff; background-color: #000000">Test</span><span style='padding-left: 76ch'></span>
</span><span style="color: #ffffff; background-color: #000000"><span style='padding-left: 80ch'></span></span>
</span><span style="color: #f8f8f2; background-color: #272822">&nbsp;code&nbsp;&nbsp;block</span><span style="background-color: #272822"><span style='padding-left: 68ch'></span></span>

Fixes #212