0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Add written number functions

This commit is contained in:
G.Ambatte
2025-03-13 12:22:08 +13:00
parent 7371f57ded
commit 543d18f9d9

View File

@@ -9,6 +9,7 @@ import { gfmHeadingId as MarkedGFMHeadingId, resetHeadings as MarkedGFMResetHead
import { markedEmoji as MarkedEmojis } from 'marked-emoji';
import MarkedSubSuperText from 'marked-subsuper-text';
import { romanize } from 'romans';
import writtenNumber from 'written-number';
//Icon fonts included so they can appear in emoji autosuggest dropdown
import diceFont from '../../themes/fonts/iconFonts/diceFont.js';
@@ -84,6 +85,22 @@ mathParser.functions.toCharUpper = function (a) {
mathParser.functions.toCharLower = function (a) {
return mathParser.functions.toChar(a).toLowerCase();
};
// Add word functions
mathParser.functions.toWords = function (a) {
return writtenNumber(a);
};
mathParser.functions.toWordsUpper = function (a) {
return mathParser.functions.toWords(a).toUpperCase();
};
mathParser.functions.toWordsLower = function (a) {
return mathParser.functions.toWords(a).toLowerCase();
};
mathParser.functions.toWordsCamel = function (a) {
const words = mathParser.functions.toWords(a).split(' ');
return words.map((word)=>{
return _.capitalize(word);
}).join(' ');
};
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (token) {