question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create new admonitions

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’m not certain that this isn’t already possible, but given the issues raised in #999 and #1314 I suspect it isn’t.

I’d like to use custom-made admonitions. For example, I wanted to create an “extra credit” admonition and specify a new icon to be used.

Describe the solution you’d like

I thought perhaps this would be possible with some custom css like this:

:root {
  --pst-icon-grad-cap: '\f0eb';
  --pst-color-admonition-extra: var(--pst-color-success);
  --pst-icon-admonition-extra: var(--pst-icon-grad-cap);
}
.admonition.extra {
    border-color: rgba(var(--pst-color-admonition-extra), 1)
}
.admonition.extra .admonition-title {
    background-color: rgba(var(--pst-color-admonition-extra), .1)
}
.admonition.extra .admonition-title:before {
    color: rgba(var(--pst-color-admonition-extra), 1);
    content: var(--pst-icon-admonition-extra)
}

But I guess this assumes that a previously undefined admonition can be handled, which doesn’t appear to be the case. When I try to build my book I get an error message WARNING: Unknown directive type "extra".

I think a workaround would be simply to take an existing admonition and use CSS to overwrite the formatting with the icon that I want, but I’d like to still be able to use the existing admonitions and to do this I’d have to pick one to overwrite.

I don’t quite understand yet the workflow that creates the book, so I’m not sure where the existing admonitions are defined. I’ve tried looking in the various github repositories but haven’t been able to find it.

Is this something that can be done with the existing setup, or would it require an actual change to the codebase?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
brownsarahmcommented, Sep 23, 2021

I agree that’s the right place to put it, since it relies on custom css, and then also link to it from the admonitions section. WIll work on this soon.

2reactions
stoffprofcommented, May 31, 2021

Ah yes, that’s right. Much easier than I realized. In case anyone else comes along having trouble seeing how to do this, here’s what I did:

In the Jupyter notebook:

:::{admonition} Extra credit
An "extra credit" exercise is presented here.
:::

Then, in format.css:

.admonition-extra-credit {
    border-left-color: rgba(var(--pst-color-success), 1);
}
.admonition-extra-credit .admonition-title {
    background-color: rgba(var(--pst-color-success), .1)
}
.admonition-extra-credit .admonition-title:before {
    color: rgba(var(--pst-color-success), 1);
    content: '\f19d';
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Document how to create a new admonition type #9 - GitHub
Up till now I have been using the built-in admonitions and just created a new stylesheet to use different icons to match what...
Read more >
Admonitions | Asciidoctor Docs
These are called admonitions. This page introduces you to admonition types AsciiDoc provides, how to add admonitions to your document, and how to...
Read more >
Admonitions - Material for MkDocs
Admonitions, also known as call-outs, are an excellent choice for including side content without significantly interrupting the document flow. Material for ...
Read more >
Admonitions - Docusaurus
Admonitions are implemented with a Remark plugin. The plugin is designed to be configurable. To customize the Remark plugin for a specific ...
Read more >
Admonitions :: Antora Docs
An admonition, also known as a notice, helps draw attention to content with a special label or icon. There are five built-in admonition...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found