Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return element => {
// Get the tag name and find the corresponding component
const tagName = element[0].name;
const Component = library.get(tagName);
// If no component exists for this tag, return the HTML wrapped in a table row
if (!Component) {
return `${$.html(element, opts.cheerio)}`;
}
const props = {
children: () => element.html()
};
const attributes = element.attr();
const restAttrs = [];
if (Component.props) {
Object.keys(Component.props).forEach(key => {
props[key] = Component.props[key];
});
}
// Find attributes on the input HTML that matches defined component props
// Other attributes are collected in a string called `props.rest`
export const createZhuyinRu = ( $$rb, $rt ) => {
// -
// -
// -
// -
// -
// -
// -
const html = (
`${
$.html( $$rb ) +
getZhuyinHTML( $rt )
}`
)
return $( html )
}
export function renderToString(element: JSX.Element) {
return cheerio.html(render(element))
}
if ( !parent || !Array.isArray( parent.children )) {
return
}
const idxBefore = parent.children.indexOf( this )
const idxAfter = idxBefore + content.contents().length
this::dom.replaceWith(
`${
$.html( content ) +
$.html( this )
}`
)
parent.children = Array.from($(
$.html( parent ).replace( /<\/?hanio\-fake>/gi, '' )
).contents())
return parent.children[ idxAfter ]
},
return customFontsCache[hash];
}
const textToSvg = await load(options.fontPath);
const str = textToSvg.getSVG(options.text, options.textToSvg);
let $svg = $(str);
const $rect = $('
$$rb.map( $rb => {
if ( !$rb ) return ''
return $.html( $rb )
}).join( '' ) + $.html( $rt )
)
html() { return $.html( this ) },
isElmt() { return this::dom.prop( 'type' ) === 'tag' },
function getSvgWithoutFill(filePath: string): string {
const iconSvg = readFileSync(filePath, { encoding: 'utf-8' });
const cheerioIcon = loadWithCheerio(iconSvg);
const svg = cheerioIcon('svg');
svg.removeAttr('fill');
svg.children().removeAttr('fill');
return html(svg) || '';
}
parse(el) {
return {
type: "description",
text: turndown(cheerio.html(el))
};
}
};
$img.attr('width', $svg.attr('width'));
$img.attr('height', $svg.attr('height'));
$img.attr(
'src',
`data:image/svg+xml;base64,${Buffer.from(str, 'utf8').toString('base64')}`
);
if (options.supportsFallback)
options.attrs = renderFallback(
options.text,
$svg.attr('height'),
options.fontColor,
options.backgroundColor,
options.attrs
);
$img = applyAttributes($img, options.attrs);
const result = $.html($img);
customFontsCache[hash] = result;
debug(`caching result for ${hash}`, result);
return result;
}