New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorized shell output in Markdown #61

Open
encukou opened this Issue Mar 16, 2017 · 11 comments

Comments

Projects
None yet
4 participants
@encukou
Member

encukou commented Mar 16, 2017

The PyLadies materials for Git use HTML for colorized shell output. Is there a better way? How to do this in Markdown?

@encukou encukou self-assigned this Mar 16, 2017

@hroncok

This comment has been minimized.

Member

hroncok commented Mar 16, 2017

Keep the color escape codes and write a plugin for the Markdown parser that converts them to HTML style/class?

@benabraham

This comment has been minimized.

Member

benabraham commented Mar 16, 2017

I use https://highlightjs.org/ on client. Many syntaxes, many color themes.

@hroncok

This comment has been minimized.

Member

hroncok commented Mar 16, 2017

Here we use Pygments.

@encukou

This comment has been minimized.

Member

encukou commented Mar 16, 2017

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.

@benabraham

This comment has been minimized.

Member

benabraham commented Mar 16, 2017

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.

@Sanqui

This comment has been minimized.

Member

Sanqui commented Mar 16, 2017

I believe ansi2html can be used for this.

@hroncok

This comment has been minimized.

Member

hroncok commented Mar 16, 2017

if not lang or lang == 'plain':

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)        

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 16, 2017

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 16, 2017

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 16, 2017

encukou added a commit to encukou/naucse.python.cz that referenced this issue Mar 20, 2017

@encukou encukou closed this in c6edab4 Mar 20, 2017

@encukou

This comment has been minimized.

Member

encukou commented Mar 20, 2017

Reopening this – it still should be possible to do it in a more elegant way.

@encukou encukou reopened this Mar 20, 2017

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 21, 2017

Use ANSI color codes for a diff
TODO: Have "patch" pygments lexer

Related: pyvec#61
@hroncok

This comment has been minimized.

Member

hroncok commented Mar 21, 2017

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.

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 21, 2017

Use ANSI color codes for a diff
TODO: Have "patch" pygments lexer

Related: pyvec#61
@encukou

This comment has been minimized.

Member

encukou commented Mar 21, 2017

Mám za to že v Pygments se jen jinak jmenuje – diff

@hroncok

This comment has been minimized.

Member

hroncok commented Mar 21, 2017

Když jsme to použil, vypadalo to jako plaintext. Možná něco dělám špatně.

hroncok added a commit to hroncok/naucse.python.cz that referenced this issue Mar 21, 2017

Use ANSI color codes for a diff
TODO: Have "patch" pygments lexer

Related: pyvec#61

encukou added a commit to encukou/naucse.python.cz that referenced this issue Mar 21, 2017

encukou added a commit that referenced this issue Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment