roll-parser - v3.4.0
    Preparing search index...

    Function renderBreakdown

    • Rebuilds a roll's breakdown from RollResult.parts, applying marks to every die.

      With no marks the output is byte-identical to RollResult.rendered — a property test pins that over generated notation. Pass any object to take over: omitted slots render plain, so {} strips markup entirely and { ...MARKDOWN_MARKS, critical: … } keeps the rest of the markdown.

      The trailing = <total> is included, and becomes the degree label for a vs roll, exactly as rendered does.

      Parameters

      Returns string

      The rendered breakdown

      import { roll } from 'roll-parser';
      import { renderBreakdown } from 'roll-parser/render';
      import { createMockRng } from 'roll-parser/testing';

      const result = roll('4d6kh3', { rng: createMockRng([3, 6, 2, 5]) });

      renderBreakdown(result); // '4d6[3, 6, ~~2~~, 5] = 14'
      renderBreakdown(result, {}); // '4d6[3, 6, 2, 5] = 14'
      renderBreakdown(result, {
      dropped: (_die, text) => `<s>${text}</s>`,
      critical: (_die, text) => `<b>${text}</b>`,
      }); // '4d6[3, <b>6</b>, <s>2</s>, 5] = 14'