How to use @times-components/markup-forest - 10 common examples

To help you get started, we’ve selected a few @times-components/markup-forest 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 newsuk / times-components / packages / article-skeleton / src / article-skeleton.js View on Github external
onRelatedArticlePress={onRelatedArticlePress}
          onTopicPress={onTopicPress}
        />
      
    ),
    []
  );

  const fixedContent = useMemo(
    () => [...fixup(isTablet, content), { name: "footer" }],
    [content, isTablet]
  );
  const images = fixedContent.filter(node => node.name === "image");

  const dropcapsDisabled = isDropcapsDisabled(data);
  const renderChild = render(renderers({ dropcapsDisabled, ...props, images }));
  // eslint-disable-next-line react/prop-types
  const Child = useCallback(
    ({ item, index }) => (
      
        
          {item.name === "footer"
            ? footer
            : renderChild(item, index.toString(), index)}
        
      
    ),
    [footer]
  );

  // FIXME: remove this when ios memory leaks are resolved
  const Scroller = React.useCallback(
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(renderTree(emphasis, coreRenderers));

        expect(output).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(renderTree(paragraph, coreRenderers));

        expect(output).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(renderTree(subscript, coreRenderers));

        expect(output).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(renderTree(superscript, coreRenderers));

        expect(output).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(
          
        );

        expect(output).toMatchSnapshot();
      }
    },
github newsuk / times-components / packages / markup / __tests__ / shared.base.js View on Github external
test: () => {
        const output = renderComponent(
          
        );

        expect(output).toMatchSnapshot();
      }
    }
github newsuk / times-components / packages / article-paragraph / article-paragraph.showcase.js View on Github external
const renderParagraphWithScale = ({ select, boolean }, ast) => {
  const scale = select("Scale", scales, scales.medium);
  const section = select("Section", sections, "The Times Magazine");
  const theme = themeFactory(section, "magazinestandard");
  const enableDropcap = boolean && boolean("Enable DropCap", true);

  return (
    
      {renderTree(ast, {
        ...coreRenderers,
        dropCap(key, { value }) {
          return (
            enableDropcap && (
              
            )
          );
        },
github newsuk / times-components / packages / article-paragraph / article-paragraph.showcase.web.js View on Github external
const renderParagraph = ({ select, boolean }, ast) => {
  const sections = Object.keys(colours.section).sort();
  const sectionIdx = select("Section", sections, 0);
  const enableDropcap = boolean && boolean("Enable DropCap", true);
  const section = sections[sectionIdx];
  const theme = themeFactory(section, "magazinecomment");
  const colour = theme.sectionColour;
  const font = theme.dropCapFont;
  const dropCapAst = !ast && select("DropCap Type", dropCapTypes, dropCapData);

  return renderTree(ast || dropCapAst, {
    ...coreRenderers,
    dropCap(key, { value }) {
      return (
        enableDropcap && (
          
            {unescape(value)}
          
        )
      );
    },
    paragraph(key, attributes, children, indx, node) {
      return (
        
          {children}
        
      );
github newsuk / times-components / packages / article / src / article-body / article-body-row.web.js View on Github external
const ArticleRow = ({ content: { data, index } }) =>
  renderTree(data, {
    ...coreRenderers,
    ad(key, attributes) {
      return {
        element: (
          
        )
      };
    },
    paragraph(key, attributes, children) {
      return {
        element: (

@times-components/markup-forest

Utility functions for traversing The Times' AST

BSD-3-Clause
Latest version published 7 months ago

Package Health Score

80 / 100
Full package analysis