aeeble aeeble

Login

ToHTML — Give a Python example readable syntax colors

A short code example in a tutorial is easier to scan when readers can pick out the keywords. ToHTML turns a snippet into highlighted output you can use on a page. Start with a small example you can share.

Generate a preview with the language selected

Paste a two-line Python function that squares a number and choose Python in Type. Pick a Style such as Eclipse and submit the form. Look at the preview and check that the return keyword, indentation and line breaks show up as expected. If the automatic language choice looks wrong, select the language yourself. The supported language list gives you examples to compare.

Match the HTML to your publishing editor

Choose inline-styled HTML for an editor that permits styling on individual elements. The class-based option is useful when your site can load the matching CSS. Test the result in a draft before publishing. An editor that strips styles, or a theme that changes the background, can make the same snippet look different. Keep the original code handy so readers can still copy it. Send examples you are allowed to share and consult the site’s privacy note for its handling of optional language-detection feedback.

Images
Ratings
Related Lists