Comments (2)
Just as a note: I think this would need to be implemented in IOCapture. Or, at least, IOCapture is relevant too, since we do do some ANSI code handling there.
This works thanks to a specialised
prinstyled(::AnnotatedIOBuffer, ::AnnotatedString)
method, but won't work for manually outputted ANSI escape codes.
So.. I haven't followed StyledStrings closely enough to have a super informed opinion here. But, this feels like a major downside -- our current approach seems strictly better, since it handles StyledStrings and other outputs. ANSI codes not being able to see the non-standard styling is a fair point.. but neither will the user using the REPL.. at least in most terminal emulators..?
I think I need some more information here as to what StyleStrings actually does on a low level, and maybe a sketch of what an implementation would look like here, and how it differs from what we have now, to make a call here.
All that said, I do think that, if StyledStrings is the future, which it appears to be, then it does feel right that we should natively support it in Documenter.
from documenter.jl.
Hi Morten,
I think it might be best if I actually address your comments in reverse order.
All that said, I do think that, if StyledStrings is the future, which it appears to be, then it does feel right that we should natively support it in Documenter.
I think it's too early to say what "the" future looks like, but I'm hoping that StyledStrings will be adopted fairly broadly for the benefits it brings to handling styled content in many forms. It's about to be used in the Markdown stdlib, and I believe that Julius is interested in using it with Makie's styled text for example.
This is a bit funny since it's sort-of-terminal but not entirely. The design of StyledStrings is such that it covers terminal capabilities, but also supports other aspects that are only possible in non-terminal contexts (namely font selection and text sizing). I'm not entirely sure how this should work out, but I suspect it would be useful to be able to show StyledStrings content in docs.
I think I need some more information here as to what StyleStrings actually does on a low level, and maybe a sketch of what an implementation would look like here, and how it differs from what we have now, to make a call here.
Simply put, what StyledStrings does is take the new AnnotatedString
type from Base (in 1.11+), which allows you to add labelled metadata to regions of a string, and introduces a "styling information" struct (called Face
, think "typeface") to put in a metadata slot labelled :faces
.
There's a bit more to make it work, make it user-customisable, etc. but that is the core of it.
ANSI codes not being able to see the non-standard styling is a fair point.. but neither will the user using the REPL.. at least in most terminal emulators..?
Well, it does makes drawing attention to those capabilities in @repl
docs a bit harder 😛
So.. I haven't followed StyledStrings closely enough to have a super informed opinion here. But, this feels like a major downside -- our current approach seems strictly better, since it handles StyledStrings and other outputs.
Yea, while I would love to see everybody using StyledStrings not manually outputting ANSI codes, that definitely isn't the reality today, so I wouldn't suggest abandoning the SGR-parsing functionality, but I think it would be nice to also be able to work with some of the more advanced capabilities that StyledStrings offers.
I'm not sure what the best path forward is, but that's why I've opened this issue — so we can discuss it.
from documenter.jl.
Related Issues (20)
- Switching versions resets to the default page HOT 3
- LoadError: `makedocs` encountered an error [:missing_docs] -- terminating build before rendering. HOT 7
- Links to collapsed pages end up off-screen
- Documenter might not be expanding the example blocks in docstrings HOT 2
- Handling of ANSI foreground/background inversion is incorrect HOT 3
- ERROR: LoadError: PCRE compilation error: regular expression is too large HOT 9
- Cross reference between modules HOT 3
- Use mathml as an alternative `mathengine` HOT 3
- Anchors for admonitions
- How to create custom badges HOT 2
- Cannot find level-three cross-references HOT 6
- Got a `If you are seeing this warning/error after upgrading Documenter and this used to work`
- Doctest fix versus exceptions
- Allow setting a global `DocTestSetup` block for all `.md` files in one place
- Make search_index a JSON file
- Alternative admonition syntax?
- Support for external parsers like CommonMark HOT 2
- Profiling docs build times HOT 3
- Not Matching Versions for Subpackage Version Tags HOT 1
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 documenter.jl.