Conversation
e71bf64 to
ef59a36
Compare
|
I'm waiting for feedback in this discussion in order to know the steps to follow. |
ef59a36 to
5ce7b1b
Compare
|
@jaywhj Was this closed because of the I think if it's open I can change the target branch in order to preserve this PR. |
|
@joapuiib Could be. After renaming, the master branch has been deleted by me. git checkout <your-PR−branch>
git fetch upstream
git rebase upstream/main
git push --force-with-leaseYou can keep your current PR branch, no need to create a new one. Just rebase it onto |
|
Additionally, I have a few questions regarding the code implementation that we could discuss together:
Below is a reference version with the proposed changes. Please evaluate whether this approach is feasible, or feel free to iterate further on top of it. <!-- Custom admonition icons -->
{% if config.theme.admonition %}
{% set _ = namespace(root_list = [], class_list = []) %}
{% for type, keys in config.theme.admonition | items %}
{# ---------- root ---------- #}
{% if keys.icon is defined and keys.icon %}
{% import ".icons/" ~ keys.icon ~ ".svg" as icon %}
{% set icon_svg = icon | replace("\n", "") | urlencode %}
{% set _.root_list = _.root_list + [
"--md-admonition-icon--" ~ type ~
":url('data:image/svg+xml;charset=utf-8," ~ icon_svg ~ "');"
] %}
{% endif %}
{% if keys.color is defined and keys.color %}
{% set _.root_list = _.root_list + [
"--md-admonition-color--" ~ type ~ ":" ~ keys.color ~ ";"
] %}
{% endif %}
{# ---------- class ---------- #}
{% set rules = [] %}
{% if keys.icon is defined and keys.icon %}
{% set rules = rules + [
"--md-admonition-icon:var(--md-admonition-icon--" ~ type ~ ");"
] %}
{% endif %}
{% if keys.color is defined and keys.color %}
{% set rules = rules + [
"--md-admonition-color:var(--md-admonition-color--" ~ type ~ ");"
] %}
{% endif %}
{% if rules | length %}
{% set rule_str = rules | join("") %}
{% set selector =
".md-typeset .admonition." ~ type ~
",.md-typeset details." ~ type
%}
{% set _.class_list = _.class_list + [
selector ~ "{" ~ rule_str ~ "}"
] %}
{% endif %}
{% endfor %}
{% set root = ":root{" ~ (_.root_list | join("")) ~ "}" %}
{% set classes = _.class_list | join("") %}
{{ ("\u003cstyle\u003e" ~ root ~ classes ~ "\u003c/style\u003e") | safe }}
{% endif %} |
|
@jaywhj But, can you reopen the PR so I try to change the target branch from
Class-specific admonition styles rules are already defined in src/templates/assets/stylesheets/main/extensions/markdown/_admonition.scss: // Admonition flavour - sets color and icon variables for each type
@each $name, $props in $admonitions {
.md-typeset .admonition.#{$name} {
--md-admonition-color: var(--md-admonition-color--#{$name});
--md-admonition-icon: var(--md-admonition-icon--#{$name});
}
}When overriding a bundled admonition color/icon, if we don't control that, the rules will be duplicated. Regarding your proposed changes. You use a list instead of a string in order to concatenate variables and style-rules. Edit: I've updated the code to integrate your variable handling suggestions but keep it a string. |
|
Let me check how this should be handled. The Reopen button is also grayed out and disabled on my end. |
|
@jaywhj Ok, I'll open a new PR. |
This PR adds the ability to configure custom admonition styles from
mkdocs|properdocs.yml.