Skip to content

Commit

Permalink
Merge pull request #5 from hemidactylus/SL-fix-overflow-codeblocks
Browse files Browse the repository at this point in the history
Fix for bgcolor of overflowing code blocks. This goes with shared-assets (CSS) changes which I'm also deploying.
  • Loading branch information
hemidactylus authored May 4, 2023
2 parents 6cea6dd + 804985d commit 0553d11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/DataStax-Academy/katapod"
},
"description": "",
"version": "1.2.0",
"version": "1.2.1",
"license": "Apache-2.0",
"engines": {
"vscode": "^1.64.0"
Expand Down
17 changes: 9 additions & 8 deletions src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const stepPageHtmlPostfix = `
window.scrollTo(0, 0);
break;
case "mark_executed_block":
const codeBlock = document.getElementById(message.blockId);
if (codeBlock) {
codeBlock.classList.add("executed");
const codeBlockPre = document.getElementById("pre_" + message.blockId);
if (codeBlockPre) {
codeBlockPre.classList.add("executed");
break;
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ export function loadPage(target: TargetStep, env: KatapodEnvironment) {

// process inline code
md.renderer.rules.code_inline = function (tokens: any, idx: any, options: any, env: any, slf: any) {
// modified from: https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js#L21-L27
// modified from: https://github.com/markdown-it/markdown-it/blob/2b6cac25823af011ff3bc7628bc9b06e483c5a08/lib/renderer.js#L21-L27
var token = tokens[idx];
return '<code class="inline_code"' + slf.renderAttrs(token) + '>' +
md.utils.escapeHtml(token.content) +
Expand All @@ -217,10 +217,11 @@ export function loadPage(target: TargetStep, env: KatapodEnvironment) {
const executionHref = `command:katapod.sendText?${renderCommandUri(parsedCommand)}`;
const aSpanEle = suppressExecution ? '<span>': `<a class="codeblock" title="Click to execute" href="${executionHref}">`;
const aSpanEleCloser = suppressExecution ? '</span>': '</a>';
const preEle = `<pre` + slf.renderAttrs(token) + `>`;
const codeEleClasses = suppressExecution ? "codeblock nonexecutable" : "codeblock executable";
const codeEleStyle = parsedCommand.backgroundColor ? ` style="background-color: ${parsedCommand.backgroundColor};"` : "";
const codeEle = `<code id="${parsedCommand.codeBlockId}" class="${codeEleClasses}"${codeEleStyle}>`;
const preEleClasses = suppressExecution ? "nonexecutable" : "executable";
const preEleStyle = parsedCommand.backgroundColor ? ` style="background-color: ${parsedCommand.backgroundColor};"` : "";
const preEle = `<pre id="pre_${parsedCommand.codeBlockId}"` + slf.renderAttrs(token) + ` class="${preEleClasses}"${preEleStyle}>`;
const codeEleClasses = "codeblock";
const codeEle = `<code id="${parsedCommand.codeBlockId}" class="${codeEleClasses}">`;

return `${aSpanEle}${preEle}${codeEle}${renderedCode}</code></pre>${aSpanEleCloser}`;

Expand Down

0 comments on commit 0553d11

Please sign in to comment.