Skip to content

Colorized shell output in Markdown #61

Closed

Description

@encukou

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

Activity

  1. self-assigned this
    on Mar 16, 2017
  2. hroncok commented on Mar 16, 2017

    @hroncok
    Member

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

  3. benabraham commented on Mar 16, 2017

    @benabraham
    Member

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

  4. hroncok commented on Mar 16, 2017

    @hroncok
    Member

    Here we use Pygments.

  5. encukou commented on Mar 16, 2017

    @encukou
    MemberAuthor

    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.

  6. benabraham commented on Mar 16, 2017

    @benabraham
    Member

    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.

  7. Sanqui commented on Mar 16, 2017

    @Sanqui
    Member

    I believe ansi2html can be used for this.

  8. hroncok commented on Mar 16, 2017

    @hroncok
    Member

    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)        
  9. encukou commented on Mar 20, 2017

    @encukou
    MemberAuthor

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

  10. added a commit that references this issue on Mar 21, 2017
  11. hroncok commented on Mar 21, 2017

    @hroncok
    Member

    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.

  12. added a commit that references this issue on Mar 21, 2017
  13. encukou commented on Mar 21, 2017

    @encukou
    MemberAuthor

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

  14. hroncok commented on Mar 21, 2017

    @hroncok
    Member

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

  15. added a commit that references this issue on Mar 21, 2017
  16. encukou commented on Apr 6, 2019

    @encukou
    MemberAuthor

    Still not ideal, but I don't think it makes sense to track this here – there'll always be something more inportant.

  17. added a commit that references this issue on Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions