stackedit icon indicating copy to clipboard operation
stackedit copied to clipboard

Add option to embed CSS styling inline in generated html

Open dov opened this issue 11 months ago • 3 comments

The html that is generated when including source code, e.g.:

```python
for i in range(10):
   print(f'{i=}')
```

references an external CSS. Here is inspect of the code generated for the above:

Image

However, such code will not keep the formatting when copied and pasted into an interactive editor like Microsoft Outlook Web Interface or GMail. To keep the syntax highlightening it is necessary to embed the formatting inline in the html.

Here is an example of html with embedded formatting which in contrast can be copied into both Microsoft Outlook Web Interface and GMail:

<span style="color:#a020f0;">for i <span style="color:#a020f0;">in <span style="color:#483d8b;">range(10):
  <span style="color:#483d8b;">print(f<span style="color:#008b00;">'{i=}')
</span></span></span></span></span>

Note that there are offline tools that can do such embedding, e.g. the python https://pypi.org/project/premailer/. But it would obviously be much easier to do copy paste of the stackedit generated html if no such postprocessing is necessary.

dov avatar Dec 22 '25 08:12 dov

project dead cant you see? 2yrs since anything 6-7 (not a joke) yrs since release

AVIVO10 avatar Dec 27 '25 16:12 AVIVO10

@AVIVO10 That's ok. I like to write down feedback with no real expectation that the issue will be fixed. Sometimes it is, and sometimes not. Sometimes I see my own comment at a later date and see that it was left without response, and decide to implement it on my own. In any case, there is nothing like a well written technical issue with examples to pique the curiosity of someone with the technical know how to make them solve it.

I personally have some repos from the years of github, that have been left untouched for 10y, but still, if someone would open an issue, I might fix it.

dov avatar Dec 27 '25 16:12 dov

Thanks for the suggestion! Clean, portable HTML with inline styles is essential for email and legacy system compatibility. In our Markups project (https://github.com/Nir-Bhay/markups), we implemented customizable export themes that specifically include options for inline CSS. This allows you to generate standalone HTML files that look great everywhere. You can see how we handled the styling logic here: https://github.com/Nir-Bhay/markups.

Nir-Bhay avatar Mar 19 '26 20:03 Nir-Bhay