Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event.js updated for dark mode and puppet.js introduced for download html function #1882

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 0 additions & 285 deletions public/css/mermaid.css

This file was deleted.

28 changes: 28 additions & 0 deletions public/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -1490,3 +1490,31 @@ md.use(pdfPlugin)
export default {
md
}
// Function to determine the Mermaid theme based on system or custom theme settings
function getMermaidTheme() {
// Check if dark mode is preferred
const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
return isDarkMode ? 'dark' : 'default'; // 'dark' for dark mode, 'default' for light mode
}

// Function to initialize Mermaid with the correct theme
function initializeMermaid() {
// Initialize Mermaid with the chosen theme
window.mermaid.initialize({
theme: getMermaidTheme(),
});

// Select Mermaid elements and re-initialize them
const $ele = document.querySelectorAll('.mermaid'); // Adjust selector as needed
$ele.forEach(ele => {
window.mermaid.init(undefined, ele); // Re-render each diagram
});
}

// Call the initialize function once the page has fully loaded
document.addEventListener('DOMContentLoaded', initializeMermaid);

// Listen for changes in the system's color scheme and re-render the diagrams accordingly
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
initializeMermaid(); // Re-initialize with the new theme
});
21 changes: 21 additions & 0 deletions pupeter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();

// Replace with the URL of your HackMD document
await page.goto('https://hackmd.io/YOUR_DOCUMENT_URL');

// Wait for the content to be fully rendered
await page.waitForSelector('body'); // Adjust the selector based on the element that signals the page has loaded

// Extract the HTML
const html = await page.evaluate(() => document.documentElement.outerHTML);

// Save the HTML to a file or output it
const fs = require('fs');
fs.writeFileSync('protocol.html', html);

await browser.close();
})();