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

Is inline colouring possible? #154

Open
ghost opened this issue Oct 20, 2024 · 3 comments
Open

Is inline colouring possible? #154

ghost opened this issue Oct 20, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 20, 2024

Lets say I wanted to emphasis or colourize mid part of the sentence.

[default black]This is an example[now red]of inline colouring[now black]within the same sentence in a PDF document.

I'm asking since you're supposed to position manually just like how it is with postscript (and in turn, PDF) creation, I feel it would be a pain to manually place multiple strings on the same line.

@AndreRenaud
Copy link
Owner

Hey. Yes, that would be a good feature. The absolute positioning makes that pretty tricky at the moment, so it would be better to be done automatically under the hood. It would require some kind of markdown-like parser, which might be a bit involved. Is there a simple syntax that already exists that might suit (to cover things like underline, strike through, colour etc...)?

Right now there isn't a trivial answer - you'd have to break it up yourself externally and then build each element separately with absolute positioning. Possible, but awkward.

@SamWindell
Copy link

SamWindell commented Jan 4, 2025

I can't think of any markup-like format that would perfect fit this library's needs. A custom format might be a reasonable choice though. Something as simple as pairs of square brackets. Content in the first square brackets dictate what the style is, and content in the second is the text. This would make writing a parser easy. So:

[bold][This text is bold]
[italic][This text is italic]
[24][This text is font size 24]
[blue][This text is blue]
[#ff0000][This text is red]
[https://example.com][This text is a link]
[bold red 32][This text is large bold red]

@AndreRenaud
Copy link
Owner

That markdown system seems ok. It'd be nice if there was something semi-standard that we could use, rather than inventing another new one. But traditional markdown is too complex for this scenario I think.

I don't have time at the moment to implement this parser though, so I'm not sure when this will get actioned.

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

3 participants
@AndreRenaud @SamWindell and others