Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Syntax Highlighting
-
Hello,
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? -
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:
http://www.editorial-workflows.com/workflow/5249622561783808/DObDwB-OfUI