filippocld223 last edited by
I'm new to editorial,but I have some experience with Pythonista...
I was trying to create a Syntax Highlighting workflow for highlighting python code in markdown files.
I set the variable selected text to text
entered this python script:
#coding: utf-8 from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import HtmlFormatter import workflow code = workflow.get_input() output=highlight(code, PythonLexer(), HtmlFormatter()) workflow.set_output(output)
and added html preview
but..what code do I have to enter in html preview?
omz last edited by
First you need to put the Input variable into the HTML (between the
<body>tags), so that you can see the output of the script.
Then you only have to add CSS styling rules for the different kinds of highlighted syntax (keywords, strings, numbers...) in order to actually get different colors. You can find a bunch of themes for use with pygments on GitHub.
Here's a complete sample workflow: