mirror of
https://github.com/NohamR/Code-to-PDF.git
synced 2026-05-24 19:58:50 +00:00
Update tag location and highlightBlock to highlightElement
This commit is contained in:
19
index.html
19
index.html
@@ -7,6 +7,16 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Code Formatter</title>
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-90N1Q923X2"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-90N1Q923X2');
|
||||
</script>
|
||||
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Fira+Code&family=Roboto&display=swap" rel="stylesheet">
|
||||
@@ -19,15 +29,6 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-90N1Q923X2"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() { dataLayer.push(arguments); }
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-90N1Q923X2');
|
||||
</script>
|
||||
<div class="hide-from-print">
|
||||
<h1><a href="index.html">Code to PDF</a></h1>
|
||||
<div class="options">
|
||||
|
||||
8
index.js
8
index.js
@@ -26,7 +26,7 @@ updateLineNumbers();
|
||||
hljs.configure({
|
||||
languages: ['java', 'javascript', 'html', 'typescript', 'cpp']
|
||||
});
|
||||
hljs.highlightBlock(code);
|
||||
hljs.highlightElement(code);
|
||||
code.classList.add(`language-${selectedLanguage}`);
|
||||
code.classList.add('hljs');
|
||||
documentNameInput.addEventListener('input', () => {
|
||||
@@ -52,7 +52,7 @@ codeTextArea.addEventListener('input', () => {
|
||||
localStorage.setItem('code', '');
|
||||
updateLineNumbers();
|
||||
}
|
||||
hljs.highlightBlock(code);
|
||||
hljs.highlightElement(code);
|
||||
});
|
||||
function updateLineNumbers() {
|
||||
let lines = codeTextArea.value.split('\n');
|
||||
@@ -78,13 +78,13 @@ languageSelector.addEventListener('change', () => {
|
||||
selectedLanguage = languageSelector.value.replace("<", "<").replace(">", ">");
|
||||
code.classList.add(`language-${selectedLanguage}`);
|
||||
localStorage.setItem('language', selectedLanguage);
|
||||
hljs.highlightBlock(code);
|
||||
hljs.highlightElement(code);
|
||||
});
|
||||
themeSelector.addEventListener('change', () => {
|
||||
themeStylesheet.href = getStylesheet(themeSelector.value);
|
||||
documentTitle.innerHTML = documentNameInput.value;
|
||||
localStorage.setItem('theme', themeSelector.value);
|
||||
hljs.highlightBlock(code);
|
||||
hljs.highlightElement(code);
|
||||
});
|
||||
function getStylesheet(style) {
|
||||
return `//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/${style}.min.css`;
|
||||
|
||||
Reference in New Issue
Block a user