How to use space-separated-tokens - 9 common examples

To help you get started, we’ve selected a few space-separated-tokens 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 Prettyhtml / prettyhtml / packages / prettyhtml-hastscript / factory.js View on Github external
var result

    /* Ignore nully and NaN values. */
    // eslint-disable-next-line no-self-compare
    if (value === null || value === undefined || value !== value) {
      return
    }

    info = find(schema, key)
    property = info.property
    result = value

    /* Handle list values. */
    if (typeof result === 'string') {
      if (info.spaceSeparated) {
        result = spaces(result)
      } else if (info.commaSeparated) {
        result = commas(result)
      } else if (info.commaOrSpaceSeparated) {
        result = spaces(commas(result).join(' '))
      }
    }

    /* Accept `object` on style. */
    if (property === 'style' && typeof value !== 'string') {
      result = style(result)
    }

    /* Class-names (which can be added both on the `selector` and here). */
    if (property === 'className' && properties.className) {
      result = properties.className.concat(result)
    }
github syntax-tree / hastscript / factory.js View on Github external
if (value === null || value === undefined || value !== value) {
      return
    }

    info = find(schema, key)
    property = info.property
    result = value

    // Handle list values.
    if (typeof result === 'string') {
      if (info.spaceSeparated) {
        result = spaces(result)
      } else if (info.commaSeparated) {
        result = commas(result)
      } else if (info.commaOrSpaceSeparated) {
        result = spaces(commas(result).join(' '))
      }
    }

    // Accept `object` on style.
    if (property === 'style' && typeof value !== 'string') {
      result = style(result)
    }

    // Class-names (which can be added both on the `selector` and here).
    if (property === 'className' && properties.className) {
      result = properties.className.concat(result)
    }

    properties[property] = parsePrimitives(info, property, result)
  }
}
github frctl / fractal / packages / fractal / fractal-plugin-preprocess-templates / src / attrs.js View on Github external
function resolveValue(existing, additional, propInfo) {
  if (!propInfo) {
    return toArray(existing).concat(toArray(additional)).join(' ');
  }
  if (propInfo.boolean || propInfo.overloadedBoolean) {
    return Boolean(additional);
  }
  if (propInfo.spaceSeparated || propInfo.commaSeparated) {
    // result should be an array
    if (typeof additional === 'string' && propInfo.spaceSeparated) {
      additional = spaceSep.parse(additional);
    } else if (typeof additional === 'string' && propInfo.commaSeparated) {
      additional = commaSep.parse(additional);
    }
    return toArray(existing).concat(toArray(additional));
  }
  if (propInfo.numeric || propInfo.positiveNumeric) {
    return parseInt(additional, 10);
  }
}
github syntax-tree / hastscript / factory.js View on Github external
var property
    var result

    // Ignore nully and NaN values.
    if (value === null || value === undefined || value !== value) {
      return
    }

    info = find(schema, key)
    property = info.property
    result = value

    // Handle list values.
    if (typeof result === 'string') {
      if (info.spaceSeparated) {
        result = spaces(result)
      } else if (info.commaSeparated) {
        result = commas(result)
      } else if (info.commaOrSpaceSeparated) {
        result = spaces(commas(result).join(' '))
      }
    }

    // Accept `object` on style.
    if (property === 'style' && typeof value !== 'string') {
      result = style(result)
    }

    // Class-names (which can be added both on the `selector` and here).
    if (property === 'className' && properties.className) {
      result = properties.className.concat(result)
    }
github Prettyhtml / prettyhtml / packages / prettyhtml-hast-to-html / lib / element.js View on Github external
'use strict'

var xtend = require('xtend')
var svg = require('property-information/svg')
var find = require('property-information/find')
var spaces = require('space-separated-tokens').stringify
var commas = require('comma-separated-tokens').stringify
var entities = require('stringify-entities')
var all = require('./all')
var constants = require('./constants')
const repeat = require('repeat-string')

module.exports = element

/* Constants. */
var emptyString = ''

/* Characters. */
var space = ' '
var quotationMark = '"'
var apostrophe = "'"
var equalsTo = '='
github zestedesavoir / zmarkdown / packages / remark-align / src / index.js View on Github external
toEat.push(block)
      stringToEat += block.slice(2, -2) + C_NEWPARAGRAPH
    }

    const add = eat(toEat.join(C_NEWLINE))
    const exit = this.enterBlock()
    const values = this.tokenizeBlock(stringToEat, now)
    exit()

    return add({
      type: elementType,
      children: values,
      data: {
        hName: 'div',
        hProperties: {
          class: spaceSeparated.parse(classes),
        },
      },
    })
  }
github remarkjs / remark-external-links / index.js View on Github external
function externalLinks(options) {
  var opts = options || {}
  var target = opts.target
  var rel = opts.rel
  var protocols = opts.protocols || defaultProtocols
  var content = opts.content

  if (typeof rel === 'string') {
    rel = spaceSeparated(rel)
  }

  if (content && typeof content === 'object' && !('length' in content)) {
    content = [content]
  }

  return transform

  function transform(tree) {
    var definition = definitions(tree)

    visit(tree, ['link', 'linkReference'], visitor)

    function visitor(node) {
      var ctx = node.type === 'link' ? node : definition(node.identifier)
github zestedesavoir / zmarkdown / packages / remark-custom-blocks / dist / index.js View on Github external
if (titleAllowed && blockTitle) {
      var titleNode = {
        type: "".concat(blockType, "CustomBlockHeading"),
        data: {
          hName: potentialBlock.details ? 'summary' : 'div',
          hProperties: {
            className: 'custom-block-heading'
          }
        },
        children: this.tokenizeInline(blockTitle, now)
      };
      blockChildren.unshift(titleNode);
    }

    var classList = spaceSeparated.parse(potentialBlock.classes || '');
    return add({
      type: "".concat(blockType, "CustomBlock"),
      children: blockChildren,
      data: {
        hName: potentialBlock.details ? 'details' : 'div',
        hProperties: {
          className: ['custom-block'].concat(_toConsumableArray(classList))
        }
      }
    });
  }
github syntax-tree / hast-util-to-html / lib / element.js View on Github external
'use strict'

var xtend = require('xtend')
var svg = require('property-information/svg')
var find = require('property-information/find')
var spaces = require('space-separated-tokens').stringify
var commas = require('comma-separated-tokens').stringify
var entities = require('stringify-entities')
var ccount = require('ccount')
var all = require('./all')
var constants = require('./constants')

module.exports = serializeElement

var space = ' '
var quotationMark = '"'
var apostrophe = "'"
var equalsTo = '='
var lessThan = '<'
var greaterThan = '>'
var slash = '/'

space-separated-tokens

Parse and stringify space separated tokens

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis

Popular space-separated-tokens functions