Skip to main content

Posts

Showing posts with the label easy_install

Create your own syntax highlighter/code beautifier with python and pygments

Now a days I have seen that there are lots and lots of people who want to share their code to this world and help people who are in need of that code(or for your personal satisfaction 😜 ). Even though sharing code is easy just by using a <pre> tag or a <code> tag , but sometimes many people including me feel comfortable when the code is neatly highlighted.  I will show you a comparison between a ne atly highlighted code a nd un-highlighted code. Not highlighted code Highlighted Code Okay don't worry if you don't have a code highlighter, you can create your own code beautifier / syntax highlighter and present your code in a neat and tidy format. To do this you just need to know basics of python and I will teach you the rest in this post. Okay let's get started.  To do syntax highlighting with python we will use a library called pygments . We are using this library because: It supports more than 300 languages/markups . It can output th...