From 82b9f825d524fbb0ad9b14443e9e18a9b8224924 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 11 Sep 2021 21:52:37 -0400 Subject: [PATCH] Update class Features snippet to v3 Puts adjacent `term :: definition` s into the same `dl` block for easier spacing of sets of terms. --- .../snippetbar/snippets/classfeature.gen.js | 54 +++++++++---------- shared/naturalcrit/markdown.js | 12 ++--- themes/5ePhb.style.less | 6 +-- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippets/classfeature.gen.js b/client/homebrew/editor/snippetbar/snippets/classfeature.gen.js index e6e18e754..7e2e7e858 100644 --- a/client/homebrew/editor/snippetbar/snippets/classfeature.gen.js +++ b/client/homebrew/editor/snippetbar/snippets/classfeature.gen.js @@ -1,4 +1,5 @@ const _ = require('lodash'); +const dedent = require('dedent-tabs').default; module.exports = function(classname){ @@ -10,33 +11,32 @@ module.exports = function(classname){ const hitDie = _.sample([4, 6, 8, 10, 12]); const abilityList = ['Strength', 'Dexerity', 'Constitution', 'Wisdom', 'Charisma', 'Intelligence']; - const skillList = ['Acrobatics ', 'Animal Handling', 'Arcana', 'Athletics', 'Deception', 'History', 'Insight', 'Intimidation', 'Investigation', 'Medicine', 'Nature', 'Perception', 'Performance', 'Persuasion', 'Religion', 'Sleight of Hand', 'Stealth', 'Survival']; + const skillList = ['Acrobatics', 'Animal Handling', 'Arcana', 'Athletics', 'Deception', 'History', 'Insight', 'Intimidation', 'Investigation', 'Medicine', 'Nature', 'Perception', 'Performance', 'Persuasion', 'Religion', 'Sleight of Hand', 'Stealth', 'Survival']; - return [ - '## Class Features', - `As a ${classname}, you gain the following class features`, - '#### Hit Points', - '___', - `- **Hit Dice:** 1d${hitDie} per ${classname} level`, - `- **Hit Points at 1st Level:** ${hitDie} + your Constitution modifier`, - `- **Hit Points at Higher Levels:** 1d${hitDie} (or ${hitDie/2 + 1}) + your Constitution modifier per ${classname} level after 1st`, - '', - '#### Proficiencies', - '___', - `- **Armor:** ${_.sampleSize(['Light armor', 'Medium armor', 'Heavy armor', 'Shields'], _.random(0, 3)).join(', ') || 'None'}`, - `- **Weapons:** ${_.sampleSize(['Squeegee', 'Rubber Chicken', 'Simple weapons', 'Martial weapons'], _.random(0, 2)).join(', ') || 'None'}`, - `- **Tools:** ${_.sampleSize(['Artian\'s tools', 'one musical instrument', 'Thieve\'s tools'], _.random(0, 2)).join(', ') || 'None'}`, - '', - '___', - `- **Saving Throws:** ${_.sampleSize(abilityList, 2).join(', ')}`, - `- **Skills:** Choose two from ${_.sampleSize(skillList, _.random(4, 6)).join(', ')}`, - '', - '#### Equipment', - 'You start with the following equipment, in addition to the equipment granted by your background:', - '- *(a)* a martial weapon and a shield or *(b)* two martial weapons', - '- *(a)* five javelins or *(b)* any simple melee weapon', - `- ${_.sample(['10 lint fluffs', '1 button', 'a cherished lost sock'])}`, - '\n\n\n' - ].join('\n'); + return dedent` + ## Class Features + As a ${classname}, you gain the following class features + #### Hit Points + + **Hit Dice:** :: 1d${hitDie} per ${classname} level + **Hit Points at 1st Level:** :: ${hitDie} + your Constitution modifier + **Hit Points at Higher Levels:** :: 1d${hitDie} (or ${hitDie/2 + 1}) + your Constitution modifier per ${classname} level after 1st + + #### Proficiencies + + **Armor:** :: ${_.sampleSize(['Light armor', 'Medium armor', 'Heavy armor', 'Shields'], _.random(0, 3)).join(', ') || 'None'} + **Weapons:** :: ${_.sampleSize(['Squeegee', 'Rubber Chicken', 'Simple weapons', 'Martial weapons'], _.random(0, 2)).join(', ') || 'None'} + **Tools:** :: ${_.sampleSize(['Artian\'s tools', 'one musical instrument', 'Thieve\'s tools'], _.random(0, 2)).join(', ') || 'None'} + + **Saving Throws:** :: ${_.sampleSize(abilityList, 2).join(', ')} + **Skills:** :: Choose two from ${_.sampleSize(skillList, _.random(4, 6)).join(', ')} + + #### Equipment + You start with the following equipment, in addition to the equipment granted by your background: + - *(a)* a martial weapon and a shield or *(b)* two martial weapons + - *(a)* five javelins or *(b)* any simple melee weapon + - ${_.sample(['10 lint fluffs', '1 button', 'a cherished lost sock'])} + + `; }; diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 250d67850..15591e387 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -208,7 +208,7 @@ const definitionLists = { level : 'block', start(src) { return src.match(/^.*?::.*/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const regex = /^([^\n]*?)::([^\n]*)/ym; + const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; let match; let endIndex = 0; const definitions = []; @@ -228,12 +228,10 @@ const definitionLists = { } }, renderer(token) { - return `
- ${token.definitions.reduce((html, def)=>{ - return `${html}
${this.parser.parseInline(def.dt)}
` - + `
${this.parser.parseInline(def.dd)}
\n`; - }, '')} -
`; + return `
${token.definitions.reduce((html, def)=>{ + return `${html}
${this.parser.parseInline(def.dt)}
` + + `
${this.parser.parseInline(def.dd)}
\n`; + }, '')}
`; } }; diff --git a/themes/5ePhb.style.less b/themes/5ePhb.style.less index 3d1b2d406..2dd7cb5a6 100644 --- a/themes/5ePhb.style.less +++ b/themes/5ePhb.style.less @@ -739,13 +739,10 @@ body { dl { line-height : 1.3em; padding-left : 1em; - text-indent : -1em; + white-space : pre-line; & + * { margin-top : 0.28cm; } - & + dl { - margin-top : 0; - } } dl + * { margin-top : 0.17cm; @@ -756,6 +753,7 @@ body { dt { display : inline; margin-right : 5px; + margin-left : -1em; } dd { display : inline;