Function markdownWrapCodeBlock

  • Wraps a given code string in a markdown code block.

    Parameters

    • code: string

      The code string to be wrapped.

    • language: string = ''

      The language of the code string. Default is an empty string.

    Returns string

    The code string wrapped in a markdown code block.

    Remarks

    This function is useful when you want to format a string of code to be displayed in markdown.

    Example

    markdownWrapCodeBlock("console.log('Hello, World!')", "javascript");;
    //=> "```javascript\nconsole.log('Hello, World!')\n```"

Generated using TypeDoc