This plugin converts numbers at the start of section and activity titles into icons, providing a visual and distinct numbering for your course elements.
By defualt the number must be the very first element of the title and followed immediately by a period (e.g., "1."), to be automatically transformed into an icon when the page loads, but you can configure another format if you like, see the Configuring the Regular Expression
Site administration
> Plugins
> Filters
> Section number icon filter
to configure the plugin settings.To determine which part of the title will be transformed into the icon, this plugin utilizes a special syntax called Regular Expressions (often shortened to "regex"). Regex is a powerful tool for matching patterns of characters within a string.
This capability allows for the creation of quite sophisticated patterns, extending the plugin's utility beyond its original purpose. For example, you could potentially display words, informational snippets, or other content as icons.
The regex MUST include two capture groups, which can optionally be named. The first capture group (or the one specifically named "icon") is responsible for identifying the "icon" element itself. The second capture group (or the one named "title") should capture the remaining portion of the title. This separation allows you to potentially remove any formatting or markup used for the numbering.
You can learn more about regular expressions and test your patterns using the online tool Regexr.com. Feel free to click on any of the regex examples on this page to experiment with them directly.
When you're using subsections, you'll typically want to have sub-numbering as well. To achieve this, you'll need to adjust the default search regular expression.
You can set the regex to "^#([\d\.]*)\s+(.*)
" to enable a numbering format like "#1.2" and "#1", allowing you to use a number after the dot. See Other useful regex
^#([\d\\.A-Z]*)\s+(.*)
" that include numbers, uppercase letters and dot, preceeded by a hash (#).^(.*?)\s+(.*)
" or combining with the above format without the hash, you can use "^([\d\\.A-Z]*)\s+(.*)
";^([IXV]+)\.\s*(.*)
".^((?:EASY)+|(?:NORMAL)+|(?:DIFFICULT)+)\s*(.*)
".(?<title>.*?)\s+(?<num>\d+)$
";^(\d*?)\.\s*(.*)
"This plugin employs basic Bootstrap styling to generate the badges, and it intelligently inherits text colors from the surrounding elements.
The badge's background color will automatically match the color of the title text. The number displayed within the icon will have its color inverted to ensure good contrast: it will appear black on light backgrounds and white on dark backgrounds.
For more advanced customization of the badge appearance, you can easily apply your own styles by targeting the following CSS classes at the site level:
.numicon-container
: This class controls the positioning of the badge..numicon-icon
: This class styles the actual circular badge element..numicon-num
: This class styles the number text displayed inside the badge.By adding or modifying CSS rules for these classes in your site's custom CSS, you have full control over the visual presentation of the icons.
Once you've configured the plugin, it will automatically convert any leading numbers found in section and activity titles (where the feature is enabled) into their corresponding icons.
To make this work, simply name your sections following the default format ("{number}. {title}") or the custom regex pattern you've configured in the settings. Keep in mind that the plugin's effect isn't visible while you're in course editing mode. To see the Numicon icons, you'll need to disable the "Edit mode".
Please submit bugs and feature requests as new GitHub issues. Provide a meaningful description with relevant information to help us understand and address the issue effectively.
Screenshot of the plugin in action, with theme "Boost" and "Custom section/Topic" format.
Course view
Section view
Mod view