Skip to content

Commit 477a192

Browse files
committed
Feature: Display Python files as raw plain text
- Add renderRawFile function for displaying raw file content - Python files now display as plain text without line numbers or syntax highlighting - Proper HTML escaping for safe display of raw content - Styled with pre-wrap for proper word wrapping and formatting preservation
1 parent 9995a01 commit 477a192

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

docs/app.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ function renderCode(text, languageClass) {
144144
codeBlock.innerHTML = `<span class="code-lines">${wrapped}</span>`;
145145
}
146146

147+
function renderRawFile(text) {
148+
codeBlock.textContent = text;
149+
codeBlock.innerHTML = `<pre>${escapeHtml(text)}</pre>`;
150+
}
151+
147152
function setActiveItem(element) {
148153
if (state.activeItem) {
149154
state.activeItem.classList.remove("active");
@@ -202,11 +207,11 @@ async function loadFile(path, meta = {}) {
202207
imageContent.classList.add("hidden");
203208
codeContainer.classList.add("hidden");
204209
} else if (languageClass === "python") {
205-
// For Python files, display as plain text without rendering
210+
// For Python files, display as raw plain text
206211
markdownContent.classList.add("hidden");
207212
imageContent.classList.add("hidden");
208213
codeContainer.classList.remove("hidden");
209-
codeBlock.textContent = text;
214+
renderRawFile(text);
210215
} else if (languageClass === "json") {
211216
let formatted = text;
212217
try {

docs/styles.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ input {
263263

264264
pre {
265265
margin: 0;
266+
padding: 0;
267+
background: transparent;
268+
border: none;
266269
}
267270

268271
code {
@@ -272,6 +275,14 @@ code {
272275
width: 100%;
273276
}
274277

278+
code pre {
279+
margin: 0;
280+
padding: 0;
281+
white-space: pre-wrap;
282+
word-wrap: break-word;
283+
overflow-wrap: break-word;
284+
}
285+
275286
#codeContainer {
276287
margin: 0;
277288
padding: 18px 20px;

0 commit comments

Comments
 (0)