Skip to content

Commit 3635686

Browse files
committed
fix: remove inline styles from code blocks
1 parent 8865ca4 commit 3635686

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/WebUIMarkdown/WebUIMarkdown.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public struct HtmlRenderer: MarkupWalker {
318318
let lineCount = lines.count
319319

320320
// Build the HTML for the code block
321-
html += "<div class=\"code-block-wrapper\" style=\"position:relative;\">"
321+
html += "<div class=\"code-block-wrapper\">"
322322

323323
// Add filename if available and enabled
324324
if showCodeFilename, let filename = filename {
@@ -334,13 +334,13 @@ public struct HtmlRenderer: MarkupWalker {
334334
// Generate line numbers HTML
335335
let lineNumbersHTML = (1...lineCount).map { "<span>\($0)</span>" }.joined(separator: "\n")
336336

337-
html += "<pre class=\"line-numbers\" style=\"display:flex;\"><div class=\"line-numbers\" style=\"text-align:right;user-select:none;color:#888;padding-right:8px;\">\(lineNumbersHTML)</div>"
337+
html += "<pre class=\"line-numbers\"><div class=\"line-numbers-container\">\(lineNumbersHTML)</div>"
338338
} else {
339339
html += "<pre>"
340340
}
341341

342342
// Add the code with basic syntax highlighting
343-
html += "<code class=\"language-\(language)\" style=\"flex:1;\">"
343+
html += "<code class=\"language-\(language)\">"
344344

345345
// For now, we'll use a very simple approach to avoid HTML escaping issues
346346
// Just display the escaped code without syntax highlighting
@@ -552,8 +552,8 @@ public struct HtmlRenderer: MarkupWalker {
552552
/// - Returns: A tuple containing the wrapped code lines and the HTML for line numbers.
553553
public func wrapWithLineNumbers(_ code: String) -> (String, String) {
554554
let lines = code.components(separatedBy: .newlines)
555-
let linesHTML = lines.map { "<span>\($0)</span>" }.joined(separator: "\n")
556-
let numbersHTML = (1...lines.count).map { "<span>\($0)</span>" }.joined(separator: "\n")
555+
let linesHTML = lines.map { "<span class=\"code-line\">\($0)</span>" }.joined(separator: "\n")
556+
let numbersHTML = (1...lines.count).map { "<span class=\"line-number\">\($0)</span>" }.joined(separator: "\n")
557557
return (linesHTML, numbersHTML)
558558
}
559559

0 commit comments

Comments
 (0)