Comments (4)
Couple of things going on here. Rich detects that it is not writing directly to a terminal and won't output control codes. Normally this is desirable, but you can force it to write control codes by adding force_terminal=True
to the Console constructor.
I've also noticed that less itself won't display color/style unless you add the -R
switch.
Hope that helps.
from rich.
@NightMachinary That's not a bad idea. It could work with python -m rich.markdown readme.md
from rich.
I've added a python -m rich.markdown
command. Hopefully this will do what you need.
If you need any changes I'd be happy to accept a PR. See the end of markdown.py
from rich.
I suggest adding this code snippet to the readme, lots of people will find it useful (there are tools like mdless
just for this, and I like rich
better.)
#!/usr/bin/env python3
import sys, os
from rich.console import Console
from rich.markdown import Markdown
console = Console(force_terminal=bool(os.environ.get("rich_force_terminal", True)))
with open(sys.argv[1]) as readme:
markdown = Markdown(readme.read(), code_theme="")
console.print(markdown)
I also use the following zsh snippet in addition to the above:
mdv() {
# mdview
local readme="$(fd -e md|head -1)"
md.py "${@:-$readme}" | less
}
from rich.
Related Issues (20)
- [BUG] Panel borders broken if using a styled console as renderable HOT 5
- [BUG] multibyte characters in Progressbar TextColumn mess up render HOT 11
- [BUG] Documentation and code disagree about the type of `log_time_format` HOT 1
- [REQUEST] Backspace and Carriage Return support HOT 1
- [BUG] rich/13.7.0: tests failure on debian unstable HOT 1
- [BUG] Text inside Live with vertical_overflow="visible" duplicating when above console.height instead of scrolling HOT 2
- [BUG] Addressing Dashboard Freeze and Cursor Flicker Issues in Real-Time Data Applications Using Rich HOT 11
- Using Traceback Handler has no effect HOT 1
- [BUG] Inconsistent traceback logging HOT 4
- [REQUEST] Shortening error messages of certain modules similarly to frame suppression in tracebacks HOT 2
- [BUG] Restarting progressbar tasks does not restart their running clocks HOT 2
- [BUG] Captured console output still results in newline being printed in Jupyter HOT 1
- [BUG] Some colors aren't printed in bold HOT 4
- [BUG] Rich tracebacks raise another exception when suppressing sys HOT 1
- [BUG] Markdown blockquotes cause crash on Windows HOT 1
- Is there a way to print the line number while console.log'ging a single line? HOT 3
- [BUG] table.add_section does not draw a line / appear to do anything HOT 1
- Support for stdlib logging StreamHandler with `Live(redirect_stderr=True)` HOT 1
- [BUG] Overriding `background_color` of `Syntax` doesn't include padding HOT 1
- Look in to using bisect module to replace home grown binary searches. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rich.