📜 ⬆️ ⬇️

Habrahabr, Live Writer and Code Highlighting

Intro



For almost half a year I have been using Windows Live Writer as a tool for writing web-based articles. This is a great tool that works with a lot of blogengineers, and even with SharePoint. But the conversation is not about that, due to the fact that I am a developer, I often have to insert a code listing into written articles, and I want to draw your attention to this.

Pigments



Many representatives of the Python community are probably familiar with a wonderful project called Pygments:
')


Well, comrade Harry Pierson (@ DevHawk ) compiled this engine under IronPython and wrote a wrapper plugin for Windows Live Writer (download here do not rush). Well, however, what is obtained as a result of its processing is not highlighted in color by habrahabr, this is due to some features of the resource, but it is fixable.

I propose to do this work, for this we will need:



After we have downloaded the sources, it is worth finding a script called pygments_package \ devhawk_formatter.py and correcting it a bit:

# a style item is a tuple in the following form:
# colors are readily specified in hex: 'RRGGBB'
if style [ 'color' ]:
start + = '<span style = "color: # % s ">' % style [ 'color' ]
end = '</ span>' + end





replaced by

# a style item is a tuple in the following form:
# colors are readily specified in hex: 'RRGGBB'
if style [ 'color' ]:
start + = '<font color = "# % s ">' % style [ 'color' ]
end = '</ font>' + end



Next, rebuild the project using the build.bat script and run the installer - now what makes this project in color is displayed on the browser.

Source: https://habr.com/ru/post/72682/


All Articles