Can pymdown-extensions inject its own CSS into the mkdocs project? #1925
-
I observed that the when using the superfences extension with ANSI text, pygments renders correct CSS classes for ANSI colored content but that is not visible in the browser as there is no CSS definition for these. In my project I had to add an extra CSS file that is adding the missing ANSI color definitions. While this sorted the rendering, it is a PITA to have to copy the same file to each website where I use it. Where could we include these extra styles so ANSI rendering will work out-of-the-box, without any extra user customizations? Should this be done in pymdown-extensions or directly into mkdocs-material? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Pymdown Extensions does not inject CSS. There are a few cases where, for basic functionality, it is not possible without setting some minimal style to an element (progress bar width for instance), but those cases are extremely rare and where we draw the line. At most, we may recommend CSS, but we allow the user to style their content in whatever way they want. We never force styling upon the user as that is not our goal. Now, let me answer your question more directly as this isn't really a question for Pymdown Extensions, but more a documentation system question. I use MkDocs, and you may have noticed that I do in fact use custom styling when dark mode is enabled in my documents. I actually have many repos all using the same styling. I do not copy them from site to site. What I do is create a MkDocs plugin that houses my custom assets and I include it and it injects all my assets. Here is the plugin source itself: https://github.com/facelessuser/mkdocs_pymdownx_material_extras/blob/master/mkdocs_pymdownx_material_extras/__init__.py The project keeps all my minimized assets in a folder that I find and include in |
Beta Was this translation helpful? Give feedback.
Pymdown Extensions does not inject CSS. There are a few cases where, for basic functionality, it is not possible without setting some minimal style to an element (progress bar width for instance), but those cases are extremely rare and where we draw the line. At most, we may recommend CSS, but we allow the user to style their content in whatever way they want. We never force styling upon the user as that is not our goal.
Now, let me answer your question more directly as this isn't really a question for Pymdown Extensions, but more a documentation system question. I use MkDocs, and you may have noticed that I do in fact use custom styling when dark mode is enabled in my documents. I actual…