-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Implement text renderer. #208
Conversation
This patch enables a very concrete use case for signac and I would be interested in some feedback on whether there is any interest in merging this particular functionality into the package before I finalize this. |
return f'`{text}`' | ||
|
||
def strong(self, text): | ||
return '**' + text + '**' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since signac intends to use this in a terminal context, it might be a nice touch to use terminal bolding. I've used this in other applications with several terminals / multiple platforms, so I think it works reliably.
return '**' + text + '**' | |
return '\033[1m' + text + '\033[0m' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe TerminalRenderer
is a better name than TextRenderer
? Not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recognize that I didn't fully commit to either text or terminal rendering both in the code and the branch name. 😄
I'm happy to fix that before moving forward.
I'm not quite sure if it is ok to include this into mistune; how about making your own renderer a python project, because it is using bs4. In mistune, I'd like to keep it dependency free. |
@lepture @csadorf I see a couple paths forward, feel free to chime in if you have other ideas:
|
@lepture The dependency on bs4 is a stop-gap solution to implement the prototype. The patch is currently a rough prototype which I would clean up before requesting the actual merge. Despite the dependency, anything else that we we would need to change before you could accept the contribution? |
Is there a standard for this It is ok to include it in mistune if it is dependency free since terminal is a common use case. |
@lepture I think we can write our own function to replace bs4 used in the prototype. The tabulate package is also used here, for this one, would it be ok to just copy the tabulate.py into this package? |
@vyasr this PR should be ready to go. |
@zhou-pj can you mark this as ready for review? |
+1 for the As an aside, I discovered this after I started work on my own |
@waylan The use case is very specifically to have a canonical formatting that specifically handles proper formatting of tables, etc. The only difference between the ansi and the text renderer is that the former uses control characters for bold formatting etc., and the latter does not. I think it would be fine to remove the text rendered if this poses a roadblock, however it is probably fair to say that neither the pure text and the ansi renderer follow a specific standard, they just produce a formatted version of the marked up input. With respect to the limitations, you are absolutely correct, that this implementation is incomplete. I created this draft PR with the help of @zhou-pj and @vyasr to get some feedback on the approach and to gauge whether there is general interest to merge this into the code base. I unfortunately did not have any time to prioritize this lately, which is why in the end we decided to vendor a forked version of the package that works for our purposes. However, I am happy to provide assistance in moving this forward. |
It appears there is no interest in this. |
For rendering of markdown documents in text format.
The concrete use case is the ability to render templated markdown documents directly within a terminal environment.