Closed encukou closed 5 years ago
Keep the color escape codes and write a plugin for the Markdown parser that converts them to HTML style/class?
I use https://highlightjs.org/ on client. Many syntaxes, many color themes.
Here we use Pygments.
Pygments also has many syntaxes and color schemes for syntax highliting. This is not about syntax highlighting, though.
Als, no JS please. All this could end up printed in a book.
I get it now. Sorry for OT. @hroncok's idea is probably the best. It will be mostly copy&paste when created. A question is if it will be easy enough to edit such source.
Seems easy!
from ansi2html import Ansi2HTMLConverter
ansi_convertor = Ansi2HTMLConverter(inline=True)
...
if lang == 'ansi':
converted = ansi_convertor.convert(code, full=False) # already escapes HTML (do we need to use some Markup() equivalent in mistune?)
return '<div class="codehilite"><pre><code>{}</code></pre></div>'.format(converted)
Reopening this – it still should be possible to do it in a more elegant way.
GitHub umí tohle:
```patch
diff --git a/setup.py b/setup.py
index 3a69792..6b453ab 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ setup(
keywords='holiday,dates',
license='Public Domain',
url='https://gist.github.com/oskar456/e91ef3ff77476b0dbc4ac19875d0555e',
- py_modules=['isholiday'],
+ packages=['isholiday'],
classifiers=[
'Intended Audience :: Developers',
'License :: Public Domain',
Nevyřešilo by to všechny případy, ale pro diffy/commity by to vypadalo dobře i na githubu i na webu, kdybychom měli pro pygments takový lexer.
Když jsme to použil, vypadalo to jako plaintext. Možná něco dělám špatně.
Still not ideal, but I don't think it makes sense to track this here – there'll always be something more inportant.
The PyLadies materials for Git use HTML for colorized shell output. Is there a better way? How to do this in Markdown?