How to use smartquotes - 1 common examples

To help you get started, we’ve selected a few smartquotes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nypublicradio / audiogram / renderer / text-wrapper.js View on Github external
return function(context, caption) {

    if (!caption) {
      return;
    }

    var lines = [[]],
        maxWidth = 0,
        words = smartquotes(caption + "").trim().replace(/\s\s+/g, " \n").split(/ /g);

    context.font = theme.captionFont;
    context.textBaseline = "top";
    context.textAlign = theme.captionAlign || "center";

    // Check whether each word exceeds the width limit
    // Wrap onto next line as needed
    words.forEach(function(word,i){

      var width = context.measureText(lines[lines.length - 1].concat([word]).join(" ")).width;

      if (word[0] === "\n" || (lines[lines.length - 1].length && width > captionWidth)) {

        word = word.trim();
        lines.push([word]);
        width = context.measureText(word).width;

smartquotes

Smart quotes are smart typography.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular smartquotes functions