How to use the ferrum.lookahead function in ferrum

To help you get started, we’ve selected a few ferrum 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 adobe / helix-pipeline / src / html / parse-frontmatter.js View on Github external
filter(identity),
    // Pair up two fences each; we even do this if there is only a single
    // fence (even though by definition that could never form a frontmatter
    // block) in order to warn about ambiguous nodes
    lookahead(1, null),
    // Filter out pairs in which both the start and the end is definately
    // a settext heading or <hr>
    reject(([fst, last]) =&gt; toIgnore(fst) &amp;&amp; toIgnore(last)),
    // Decide which blocks to ignore, which deserve warnings and which
    // are actual frontmatter
    procwarnigns,
    filter(identity),
    // Filter out false positive warnings for pseudo frontmatter blocks
    // before actual frontmatter (warning gets invalidated by the fact
    // that it DIRECTLY PRECEDES an actual frontmatter block)
    lookahead(1, null),
    reject(([val, next]) =&gt; true
      &amp;&amp; val.type === 'warning'
      &amp;&amp; val.warning.startsWith('Found ambigous frontmatter')
      &amp;&amp; next
      &amp;&amp; next.type === 'frontmatter'
      &amp;&amp; val.end === next.start),
    /* eslint-disable-next-line no-unused-vars */
    map(([val, next]) =&gt; val),
  );
};
github adobe / helix-pipeline / src / html / parse-frontmatter.js View on Github external
}
      // Offset of the actual separator line (this may deviate from the)
      const offStart = mat.index + start(idx);
      const offEnd = offStart + size(mat[0]);
      // Is there a new line or EOF before/after the separator?
      const before = Boolean(str.slice(0, offStart).match(re(`(^|(^|\\n)${hspace}*\\n)$`)));
      const after = Boolean(str.slice(offEnd).match(re(`^(${hspace}*(\\n${hspace}*(\\n|$))|$)`)));
      return {
        idx, nod, offStart, offEnd, before, after,
      };
    }),
    filter(identity),
    // Pair up two fences each; we even do this if there is only a single
    // fence (even though by definition that could never form a frontmatter
    // block) in order to warn about ambiguous nodes
    lookahead(1, null),
    // Filter out pairs in which both the start and the end is definately
    // a settext heading or <hr>
    reject(([fst, last]) =&gt; toIgnore(fst) &amp;&amp; toIgnore(last)),
    // Decide which blocks to ignore, which deserve warnings and which
    // are actual frontmatter
    procwarnigns,
    filter(identity),
    // Filter out false positive warnings for pseudo frontmatter blocks
    // before actual frontmatter (warning gets invalidated by the fact
    // that it DIRECTLY PRECEDES an actual frontmatter block)
    lookahead(1, null),
    reject(([val, next]) =&gt; true
      &amp;&amp; val.type === 'warning'
      &amp;&amp; val.warning.startsWith('Found ambigous frontmatter')
      &amp;&amp; next
      &amp;&amp; next.type === 'frontmatter'

ferrum

Features from the rust language in javascript: Provides Traits/Type classes & an advanced library for working with sequences/iterators in js.

Apache-2.0
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis