How can I change text colour mid word in asciidoc syntax?
Asked Answered
G

1

5

I have the task of converting some documents to asciidoc format.

I have ONLY the asciidoc standard tools - I do NOT have access to any of the css sheets that asciidoctor uses to render my output.

I have a need to change colour of a word mid word.

Let's assume the word is RedNectar

I want the first three letters rendered in red, the last five in yellow

If I split the word and use [red]#Red# [yellow]#Nectar#

I get the right colours, but a space between them

enter image description here

But if I remove the space, [red]#Red#[yellow]#Nectar# it renders as:

enter image description here

[The yellow highlighting is simply the preview indicating a problem]

So what magic do I have to perform to get these two half-words to join? In many cases, I have the same problem between words as wee, when I use the {nbsp} (non-breaking space) between words - it's now seen as a space at all and I strike the same kind of problem as you can see here - I HAVE a space between Red and Nectar - it's just a {nbsp} - and STILL doesn't render properly.

enter image description here

Gisborne answered 20/3, 2022 at 4:14 Comment(0)
T
8

Use an unconstrained formatting pair for the second formatted word:

 [.red]#Red#[.yellow]##Nectar##
Titanate answered 20/3, 2022 at 12:46 Comment(1)
Be careful. You might first have to define roles discuss.asciidoctor.org/Color-for-Text-td7509.html.Fe

© 2022 - 2024 — McMap. All rights reserved.