Skip to content
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

Markdown in @description() decorators #512

Open
Bzero opened this issue Jul 28, 2024 · 3 comments
Open

Markdown in @description() decorators #512

Bzero opened this issue Jul 28, 2024 · 3 comments

Comments

@Bzero
Copy link
Contributor

Bzero commented Jul 28, 2024

#469 added the option to use (some) markdown in @description() decorators which I think is very neat for the online documentation and helps to make it more readable, however it also makes the description a bit inconvenient to read in the cli using the info command.

Possibly we could directly use Unicode characters instead of LaTeX commands in formulas (e.g. $Γ(x)$ instead of $\Gamma(x)$) and use colors to highlight code and math blocks to make descriptions more easily readable in the cli.

@sharkdp
Copy link
Owner

sharkdp commented Jul 28, 2024

I only thought about improving the online documentation but forgot about info for a second there, sorry about that.

I know that there are some markdown viewers for the terminal. Maybe the easiest way forward would be to use one of these (as a library)? For example, they might be able to show markdown links using ANSI hyperlinks? The problem is that they would need to support Latex formulas as well, but maybe there are some?

Possibly we could directly use Unicode characters instead of LaTeX commands in formulas (e.g. $Γ(x)$ instead of $\Gamma(x)$)

If nothing else, we should definitely do that... if it will still be recognized by mdbook and its mathjax support.

and use colors to highlight code and math blocks to make descriptions more easily readable in the cli

If we don't get this from an external library, we could certainly attempt to do that. But I'm yet not sure if I want a custom markdown parser just for that(?).

@Bzero
Copy link
Contributor Author

Bzero commented Jul 28, 2024

Maybe the easiest way forward would be to use one of these (as a library)?

Yes, if there is a library that can display markdown including math blocks in the terminal this would certainly be the easiest and probably also best way. I had a brief look around but could unfortunately not find a terminal markdown viewer library that can display LaTeX formulas in a satisfactory way.

But I'm yet not sure if I want a custom markdown parser just for that(?).

No, I wouldn't suggest that either, however I think math and code blocks are the most important markdown features for the use case in numbat and detecting those should not be too hard.

@sharkdp
Copy link
Owner

sharkdp commented Aug 4, 2024

Another option would be to have two fields (@doc and @info or similar). But the duplication would be a real shame. On the other hand, we would only have to do that for the functions with formulas in the descriptions. For the others, one of them could fall back to the other.

The LaTeX we're using so far is extremely basic. Maybe we can indeed write a small parser ourselves? And turns things like \sqrt{…} into sqrt; \frac{…}{…} => (…)/(…). And for symbols like \pi and \Gamma, we could check if it's possible to use unicode characters.

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

No branches or pull requests

2 participants