MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / html2pptx

Function html2pptx

pptx/scripts/html2pptx.js:896–977  ·  view source on GitHub ↗
(htmlFile, pres, options = {})

Source from the content-addressed store, hash-verified

894}
895
896async function html2pptx(htmlFile, pres, options = {}) {
897 const {
898 tmpDir = process.env.TMPDIR || '/tmp',
899 slide = null
900 } = options;
901
902 try {
903 // Use Chrome on macOS, default Chromium on Unix
904 const launchOptions = { env: { TMPDIR: tmpDir } };
905 if (process.platform === 'darwin') {
906 launchOptions.channel = 'chrome';
907 }
908
909 const browser = await chromium.launch(launchOptions);
910
911 let bodyDimensions;
912 let slideData;
913
914 const filePath = path.isAbsolute(htmlFile) ? htmlFile : path.join(process.cwd(), htmlFile);
915 const validationErrors = [];
916
917 try {
918 const page = await browser.newPage();
919 page.on('console', (msg) => {
920 // Log the message text to your test runner's console
921 console.log(`Browser console: ${msg.text()}`);
922 });
923
924 await page.goto(`file://${filePath}`);
925
926 bodyDimensions = await getBodyDimensions(page);
927
928 await page.setViewportSize({
929 width: Math.round(bodyDimensions.width),
930 height: Math.round(bodyDimensions.height)
931 });
932
933 slideData = await extractSlideData(page);
934 } finally {
935 await browser.close();
936 }
937
938 // Collect all validation errors
939 if (bodyDimensions.errors && bodyDimensions.errors.length > 0) {
940 validationErrors.push(...bodyDimensions.errors);
941 }
942
943 const dimensionErrors = validateDimensions(bodyDimensions, pres);
944 if (dimensionErrors.length > 0) {
945 validationErrors.push(...dimensionErrors);
946 }
947
948 const textBoxPositionErrors = validateTextBoxPosition(slideData, bodyDimensions);
949 if (textBoxPositionErrors.length > 0) {
950 validationErrors.push(...textBoxPositionErrors);
951 }
952
953 if (slideData.errors && slideData.errors.length > 0) {

Callers

nothing calls this directly

Calls 9

getBodyDimensionsFunction · 0.85
extractSlideDataFunction · 0.85
validateDimensionsFunction · 0.85
validateTextBoxPositionFunction · 0.85
addBackgroundFunction · 0.85
addElementsFunction · 0.85
textMethod · 0.80
onMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected