mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
function highlightPrompts() {
|
|
document.querySelectorAll('pre > code').forEach(codeBlock => {
|
|
if (codeBlock.dataset.promptProcessed) return;
|
|
codeBlock.dataset.promptProcessed = 'true';
|
|
|
|
// Match `pwndbg>` and `>`.
|
|
const lines = codeBlock.querySelectorAll('span[id^="__span"]');
|
|
|
|
lines.forEach(lineEl => {
|
|
const text = lineEl.textContent;
|
|
const match = text.match(/^(pwndbg>|>)(.*)/);
|
|
if (match) {
|
|
const prompt = match[1];
|
|
const rest = match[2];
|
|
|
|
lineEl.innerHTML = '';
|
|
|
|
const promptSpan = document.createElement('span');
|
|
promptSpan.className = 'pwndbg-prompt';
|
|
promptSpan.textContent = prompt;
|
|
|
|
const contentSpan = document.createElement('span');
|
|
contentSpan.className = 'pwndbg-cmd';
|
|
contentSpan.textContent = rest;
|
|
|
|
lineEl.appendChild(promptSpan);
|
|
lineEl.appendChild(contentSpan);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// Run on page load.
|
|
// https://squidfunk.github.io/mkdocs-material/customization/#additional-javascript
|
|
document$.subscribe(highlightPrompts)
|