How to use @canopycanopycanopy/b-ber-shapes-directives - 10 common examples

To help you get started, we’ve selected a few @canopycanopycanopy/b-ber-shapes-directives 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 triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _isUnsupportedAttribute = (genus, attr) => {
  let key
  if (BLOCK_DIRECTIVES.indexOf(genus) > -1) {
    // these are all containers which share the same attributes, so they're
    // grouped under a single property
    key = 'block'
  } else {
    // this will be the directive name, e.g., figure, video, etc
    key = genus
  }

  return SUPPORTED_ATTRIBUTES[key][attr] !== true // bool
}
github triplecanopy / b-ber / packages / b-ber-grammar-section / src / index.js View on Github external
import find from 'lodash.find'
import state from '@canopycanopycanopy/b-ber-lib/State'
import { Html } from '@canopycanopycanopy/b-ber-lib'
import { BLOCK_DIRECTIVES } from '@canopycanopycanopy/b-ber-shapes-directives'
import log from '@canopycanopycanopy/b-ber-logger'
import plugin from '@canopycanopycanopy/b-ber-parser-section'
import createRenderer from '@canopycanopycanopy/b-ber-grammar-renderer'
import {
  attributes,
  htmlId,
} from '@canopycanopycanopy/b-ber-grammar-attributes'

// this matches *all* container-type directives, and outputs the appropriate
// HTML based on user-defined attributes
const containers = BLOCK_DIRECTIVES.join('|')
const MARKER_OPEN_RE = new RegExp(
  `^(${containers}|exit)(?::([^\\s]+)(\\s.*)?)?$`
) // treat `exit` like an opening marker since we're using it as such
const MARKER_CLOSE_RE = /(exit)(?::([^\s]+))?/

// since `context` needs to be available in this `render` method, we curry it
// in and pass the resulting function to the `createRenderer` below. we also
// set a default for `context` since we'll need some of its properties during
// testing

function isGallery(directive) {
  return (
    directive &&
    directive.type === 'gallery' &&
    (state.build === 'web' || state.build === 'reader')
  )
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _directiveOrder = genus =>
  BLOCK_DIRECTIVES.indexOf(genus) > -1
    ? 'block'
    : INLINE_DIRECTIVES.indexOf(genus) > -1
    ? 'inline'
    : MISC_DIRECTIVES.indexOf(genus) > -1
    ? 'misc'
    : null
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _lookUpFamily = genus =>
  FRONTMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'frontmatter'
    : BODYMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'bodymatter'
    : BACKMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'backmatter'
    : ''
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _lookUpFamily = genus =>
  FRONTMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'frontmatter'
    : BODYMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'bodymatter'
    : BACKMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'backmatter'
    : ''
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _lookUpFamily = genus =>
  FRONTMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'frontmatter'
    : BODYMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'bodymatter'
    : BACKMATTER_DIRECTIVES.indexOf(genus) > -1
    ? 'backmatter'
    : ''
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _requiresAltTag = genus =>
  DIRECTIVES_REQUIRING_ALT_TAG.indexOf(genus) > -1
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _directiveOrder = genus =>
  BLOCK_DIRECTIVES.indexOf(genus) > -1
    ? 'block'
    : INLINE_DIRECTIVES.indexOf(genus) > -1
    ? 'inline'
    : MISC_DIRECTIVES.indexOf(genus) > -1
    ? 'misc'
    : null
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const _directiveOrder = genus =>
  BLOCK_DIRECTIVES.indexOf(genus) > -1
    ? 'block'
    : INLINE_DIRECTIVES.indexOf(genus) > -1
    ? 'inline'
    : MISC_DIRECTIVES.indexOf(genus) > -1
    ? 'misc'
    : null
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const attributesObject = (attrs, _genus, context = {}) => {
  const { fileName, lineNumber } = context
  const attrsObject = {}

  let genus = _genus

  if (!genus || typeof genus !== 'string') {
    log.error(`No directive provided: ${fileName}:${lineNumber}`)
  }

  if (ALL_DIRECTIVES.indexOf(genus) < 0) {
    log.error(`Invalid directive: [${genus}] at ${fileName}:${lineNumber}`)
  }

  if (DRAFT_DIRECTIVES.indexOf(genus) > -1) {
    log.warn(`render [epub:${genus}] is [draft]. substituting with [chapter]`)
    genus = 'chapter'
  }

  if (DEPRECATED_DIRECTIVES.indexOf(genus) > -1) {
    log.warn(
      `render [epub:${genus}] is [deprecated]. substituting with [chapter]`
    )
    genus = 'chapter'
  }

  if (attrs && typeof attrs === 'string') {