mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-22 07:27:51 +00:00
Add Roman numerals function
This commit is contained in:
@@ -8,6 +8,7 @@ import { markedSmartypantsLite as MarkedSmartypantsLite }
|
||||
import { gfmHeadingId as MarkedGFMHeadingId, resetHeadings as MarkedGFMResetHeadingIDs } from 'marked-gfm-heading-id';
|
||||
import { markedEmoji as MarkedEmojis } from 'marked-emoji';
|
||||
import MarkedSubSuperText from 'marked-subsuper-text';
|
||||
import { romanize } from 'romans';
|
||||
|
||||
//Icon fonts included so they can appear in emoji autosuggest dropdown
|
||||
import diceFont from '../../themes/fonts/iconFonts/diceFont.js';
|
||||
@@ -59,6 +60,16 @@ mathParser.functions.signed = function (a) {
|
||||
if(a >= 0) return `+${a}`;
|
||||
return `${a}`;
|
||||
};
|
||||
// Add Roman numeral functions
|
||||
mathParser.functions.toRomans = function (a) {
|
||||
return romanize(a);
|
||||
};
|
||||
mathParser.functions.toRomansUpper = function (a) {
|
||||
return romanize(a).toUpperCase();
|
||||
};
|
||||
mathParser.functions.toRomansLower = function (a) {
|
||||
return romanize(a).toLowerCase();
|
||||
};
|
||||
|
||||
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||
renderer.html = function (token) {
|
||||
@@ -87,7 +98,7 @@ renderer.paragraph = function(token){
|
||||
//Fix local links in the Preview iFrame to link inside the frame
|
||||
renderer.link = function (token) {
|
||||
let { href, title, tokens } = token;
|
||||
const text = this.parser.parseInline(tokens)
|
||||
const text = this.parser.parseInline(tokens);
|
||||
let self = false;
|
||||
if(href[0] == '#') {
|
||||
self = true;
|
||||
@@ -110,7 +121,7 @@ renderer.link = function (token) {
|
||||
|
||||
// Expose `src` attribute as `--HB_src` to make the URL accessible via CSS
|
||||
renderer.image = function (token) {
|
||||
let {href, title, text} = token;
|
||||
const { href, title, text } = token;
|
||||
if(href === null)
|
||||
return text;
|
||||
|
||||
@@ -873,7 +884,7 @@ const extractHTMLStyleTags = (htmlString)=>{
|
||||
?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="'))
|
||||
.reduce((obj, attr)=>{
|
||||
const index = attr.indexOf('=');
|
||||
let [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
||||
const [key, value] = [attr.substring(0, index), attr.substring(index + 1)];
|
||||
obj[key.trim()] = value.replace(/"/g, '');
|
||||
return obj;
|
||||
}, {}) || null;
|
||||
|
||||
Reference in New Issue
Block a user