Currently it does not seem to be possible to create a custom theme in which a background colour can be added to inline monospace (literal in the theme YAML).
This is the default styling in the HTML output in the inline code style and it would be nice to be able to replicate this.
Default HTML CSS:
:not(pre) > code {
font-size: 0.9375em;
font-style: normal !important;
letter-spacing: 0px;
padding: 0.1em 0.5ex;
word-spacing: -0.15em;
background-color: #F7F7F8;
border-radius: 4px;
line-height: 1.45;
text-rendering: optimizespeed;
}
As far as I can see this is currently possible in source block formatting (code YAML section), but not in the inline case surrounded by `.
It's not yet possible to put background colors on inline elements in Asciidoctor PDF. However, Prawn does support this (using a render_behind calback).
Thanks for the clarification. I look forward to when you have time to implement it!
I'd love to have this - our mono font isn't too different from the regular font, so sometimes the monospaced text (which we have a lot of) gets a little lost. Being able to highlight those passages would help.
I ended up here after desiring background consistency between block code and inline code. I see that, when using rogue, support was added for line highlighting via #663 and which #345 indicates is related to this request. Do inline blocks support the use of custom/generic rogue themes as well (we鈥檙e in transition to adoc and currently use Pygments or whatever the default is), or is further work required to make background coloring work for inline code?
@billybooth highlighting for inline snippets is a separate issue. There's an open issue in core about how to express it in AsciiDoc, which could then be carried out by the converter. See https://github.com/asciidoctor/asciidoctor/issues/1043
I realized that I had already done the work for this issue in the open pull request for #451 (see #664). What was left was a way to put some padding between the background/border and the text. I decided to introduce the key border-offset for this purpose (taking a nod from outline-offset in CSS). It doesn't affect the text in any way. It just moves the background/border outwards. Adding padding to the text itself is a much harder problem because of how Prawn is implemented. But I think the border-offset is a very reasonable trade-off to get this working sooner rather than later.
Btw, we can add border at the same time, and border radius, and all those goodies.
I have tried to test it and the result is:
== test 1
Following dictionaries should be maintained:
- `Gender`
- `Country`
- `DocumentTypes`
- `Carrier`
- `...`
literal:
font_color: $base_font_color
font_family: Literal
font_size: $base_font_size
border_radius: 2
border_width: 1
border_offset: 2

literal:
font_color: $base_font_color
font_family: Literal
font_size: $base_font_size
border_radius: 1
border_width: 2

@mojavelinux fyi and thanks for this :)
Thanks for checking.
I see what's happening. Unfortunately, there's nothing I can do about that right now. The monospaced text can't have any sort of nested formatting. Prawn just doesn't understand how to work with nested formatting, so it ends up not being able to render behind the outer group (instead, it tries to render behind each nested formatted phrase). This is just where we start to hit limits in Prawn that I just can't fix from Asciidoctor PDF.
To clarify, you can fix by using:
`+...+`
Got it, thx!
Most helpful comment
I'd love to have this - our mono font isn't too different from the regular font, so sometimes the monospaced text (which we have a lot of) gets a little lost. Being able to highlight those passages would help.