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

Add background color key to inline monospace #306

Closed
Xcodo opened this issue Aug 21, 2015 · 12 comments
Closed

Add background color key to inline monospace #306

Xcodo opened this issue Aug 21, 2015 · 12 comments
Assignees
Milestone

Comments

@Xcodo
Copy link

Xcodo commented Aug 21, 2015

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 `.

@mojavelinux mojavelinux added this to the v1.5.0.beta.1 milestone Aug 22, 2015
@mojavelinux mojavelinux self-assigned this Aug 22, 2015
@mojavelinux
Copy link
Member

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).

@Xcodo
Copy link
Author

Xcodo commented Aug 24, 2015

Thanks for the clarification. I look forward to when you have time to implement it!

@mojavelinux mojavelinux changed the title Add background colour key to inline monospace Add background color key to inline monospace May 2, 2016
@ctargett
Copy link

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.

@billybooth
Copy link
Contributor

billybooth commented Mar 22, 2019

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’re 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?

@mojavelinux
Copy link
Member

@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 asciidoctor/asciidoctor#1043

@mojavelinux
Copy link
Member

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.

@mojavelinux
Copy link
Member

Btw, we can add border at the same time, and border radius, and all those goodies.

mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 8, 2019
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 8, 2019
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 8, 2019
@habamax
Copy link
Contributor

habamax commented Jul 8, 2019

I have tried to test it and the result is:

Example text:

== test 1
Following dictionaries should be maintained:

	- `Gender`
	- `Country`
	- `DocumentTypes`
	- `Carrier`
	- `...`

theme params

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

result

image

Another theme params (no border offset)

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

result

image

@habamax
Copy link
Contributor

habamax commented Jul 8, 2019

@mojavelinux fyi and thanks for this :)

@mojavelinux
Copy link
Member

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.

@mojavelinux
Copy link
Member

To clarify, you can fix by using:

`+...+`

@habamax
Copy link
Contributor

habamax commented Jul 8, 2019

Got it, thx!

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Dec 11, 2023
Copyright (garbage) strings may contain characters that are reserved for
formatting in Asciidoc. Avoid formatting to break in such cases by
disabling "nested formatting" while using monospaced text. See [1] and
[2] for background information.

[1]: #8019
[2]: asciidoctor/asciidoctor-pdf#306

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Dec 11, 2023
Copyright (garbage) strings may contain characters that are reserved for
formatting in Asciidoc. Avoid formatting to break in such cases by
disabling "nested formatting" while using monospaced text. See [1], [2]
and [3] for background information.

[1]: #8019
[2]: asciidoctor/asciidoctor-pdf#306
[3]: https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#literals-and-source-code

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Dec 12, 2023
Copyright (garbage) strings may contain characters that are reserved for
formatting in Asciidoc. Avoid formatting to break in such cases by
disabling "nested formatting" while using monospaced text. See [1], [2]
and [3] for background information.

[1]: #8019
[2]: asciidoctor/asciidoctor-pdf#306
[3]: https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#literals-and-source-code

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
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

5 participants