Skip to main content

Markdown-like admonitions from the comfort of your favorite terminal, all thanks to `rich`!

Project description

rich-admonitions

Markdown-like admonitions from the comfort of your terminal, all thanks to rich!

Note

Credit where it's due! The structure of this project was set up with the ever-helpful PyScaffold. And thanks to the Textualize developers for their help with debugging and developing this class!

Overview

I think Julia's REPL admonitions are so neat.

julia> using Markdown

julia> md"""
       !!! note
           Check out this helpful note!
       """
   Note
  
    Check out this helpful note!

Thanks to rich, it's not difficult to replicate this format with a Python class!

>>> from admonitions import Admonition

>>> Admonition.note("Check out this helpful note!")
 Note  

  Check out this helpful note!   

Installation & Usage

This package is installable through the public PyPi index.

python -m pip install rich-admonitions

And it's use-able through the name admonitions!

import admonitions

Any type that is renderable by rich can go in the Admonition constructor!

>>> from rich.markdown import Markdown

>>> message = """
... # Mic Test
... 
... Testing, testing! Is this thing on?
... """

>>> Admonition(Markdown(message))

 Notice  

  ╔══════════════════════════════════════════════════════════════════════╗   
                                 Mic Test                                  
  ╚══════════════════════════════════════════════════════════════════════╝   
                                                                             
  Testing, testing! Is this thing on?                                        

And there a few out-of-the-box class methods to get you started. 😊

>>> Admonition.note(
...     Admonition.tip(
...         Admonition.warning(
...             Admonition.danger(
...                 "Hold your breath! 🤿"
...             )
...         )
...     )
... )

 Note  

   Tip                                                                      
                                                                            
     Warning                                                               
                                                                           
       Danger                                                             
                                                                          
        Hold your breath! 🤿                                            
                                                                           
                                                                            
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rich-admonitions-0.1.0.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

rich_admonitions-0.1.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page