Themes
The m-theme-*.css files provide final theming for the
style. Currently, m.css provides two themes, a dark and a light one. A theme
file consists of just a set of CSS variables, which affect fonts, colors and
other properties. Together with theme file, m.css provides also a “driver file”
that includes all the other necessary CSS files except fonts via CSS
@import
statements — so you can reference just m-dark.css
instead
of four distinct files.
Dark
The dark theme is contained in the m-dark.css (or
m-dark.compiled.css
) file. Besides that, you need to reference also
Source Sans Pro font
(used for page copy) and Source Code Pro
(used for pre-formatted text and code). You can get them on Google Fonts. Full
markup including theme color (used for example by Vivaldi or Android browser)
is below:
<link rel="stylesheet" href="m-dark.css" /> <!-- or m-dark.compiled.css --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?Source+Sans+Pro:400,400i,600,600i%7Cfamily=Source+Code+Pro:400,400i,600" /> <meta name="theme-color" content="#22272e" />
This theme is used on this site and also on https://magnum.graphics.
Light
The light theme is contained in the m-light.css (or
m-light.compiled.css
) file. Besides that, you need to reference also
Libre Baskerville font
(used for page copy) and Source Code Pro
(used for pre-formatted text and code).
<link rel="stylesheet" href="m-light.css" /> <!-- or m-light.compiled.css --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,400i,700,700i%7CSource+Code+Pro:400,400i,600" /> <meta name="theme-color" content="#cb4b16" />
If you want to see this theme live, go to http://blog.mosra.cz.
Make your own
Making your own theme is usually just a matter of modifying CSS variables in
the theme file. To give an example, a portion of the m-theme-dark.css
file
looks like this:
*/ :root { /* Text properties */ --font: 'Source Sans Pro', sans-serif; --code-font: 'Source Code Pro', monospace; --font-size: 16px; --code-font-size: 0.9em; /* *not* rem, so it follows surrounding font size */ --line-height: normal; --paragraph-indent: 1.5rem; --paragraph-align: justify; --link-decoration: underline; --link-decoration-nav: none; --link-decoration-heading: none; --nav-brand-case: uppercase; --nav-menu-case: none; --nav-heading-case: uppercase; --nav-categories-case: lowercase; --landing-header-case: lowercase; --heading-font-weight: 600; /* Shapes */ --border-radius: 0.2rem;
The project also bundles a Python script for postprocessing the CSS files
into a single *.compiled.css
file without @import
statements or
variables, if you need. Download it here:
Its usage is simple — just call it with the files you want to compile
together and it will create a *.compiled.css
file in the same directory:
cd css ./postprocess.py m-dark.css # Creates a m-dark.compiled.css file
Modifying the Pygments highlighting style
If you want to modify the Pygments style, it’s a bit more involved. You need to
edit the *.py
file instead of the *.css
:
After making changes, copy it somewhere so Pygments can load it as a style and then generate a CSS file out of it:
sudo cp pygments-dark.py /usr/lib/python3.10/site-packages/pygments/styles/dark.py pygmentize -f html -S dark -a .m-code > pygments-dark.css sudo cp pygments-console.py /usr/lib/python3.10/site-packages/pygments/styles/console.py pygmentize -f html -S console -a .m-console > pygments-console.css
Alternatively, you can use any of the builtin styles — pick the one you like
at http://pygments.org/demo/ and then tell pygmentize
to generate a CSS for
it. For example, the below command is for the pastie
style. Note that you
might want to remove the first two lines of the resulting CSS (setting
background-color
) as those would in most cases conflict with the style
in m.css.
pygmentize -f html -S pastie -a .m-code > pygments-pastie.css