-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support rich formatting #7
Comments
So do you want to return an abstract syntax tree or something like that that represents the rich text? It will be left to the user to render the AST as he wants to. |
Essentially yes, that's the idea. The user is given a list of strings with rendering hints + global color/alignment info. Alternatively, the library could of returned a single string with escaped formatting codes, or even XML/JSON, but then users need to parse that to render it. Such an approach would look like: string NumberFormat.FormatRich(object value, CultureInfo, out Alignment alignment, out Color color) That's not too bad. The returned string mostly looks like a normal formatted value, except contains escape codes for the '_' and '*' space and repeat characters. At the moment I have no strong preference for either direction, both should work. |
I'd prefer not to have to parse a string again. It will severely impact
performance.
…On 1 Nov 2017 20:11, "andersnm" ***@***.***> wrote:
Essentially yes, that's the idea. The user is given a list of strings with
rendering hints + global color/alignment info.
Alternatively, the library could of returned a single string with escaped
formatting codes, or even XML/JSON, but then users need to parse that to
render it. Such an approach would look like:
string NumberFormat.FormatRich(object value, CultureInfo, out Alignment alignment, out Color color)
That's not too bad. The returned string mostly looks like a normal
formatted value, except contains escape codes for the '_' and '*' space and
repeat characters.
At the moment I have no strong preference for either direction, both
should work.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAI5vqhk8gsigwN08ZhBRwgRdiv5pFpVks5syLRmgaJpZM4QOHqS>
.
|
Specifically: global color and alignment, variable width space, repeat-to-fill characters
The basic goal is to return something allowing the caller to render the formatted value more precisely with an arbitrary rendering backend, like f.ex a 2D canvas, SVG, HTML, while remaining neutral to font size and cell width.
@igitur FYI, these are my thoughts but have no immediate plans to implement myself.
F.ex a new method
NumberFormat.FormatRich()
could return a class shape like:The Formatter class should probably operate on these classes internally instead of a StringBuilder, and rewrite the current Format() method to reduce the
FormatResult
to a string.And I don't necessarily think these are good class/enum/method names: finding good names is the hardest.
The text was updated successfully, but these errors were encountered: