@@ -4,71 +4,7 @@ class CleanHtmlFilter < Filter
4
4
def call
5
5
# Remove unnecessary elements
6
6
css ( 'head, script, style' ) . remove
7
-
8
- # Add syntax highlighting CSS
9
- style = doc . document . create_element ( 'style' )
10
- style . content = <<-CSS
11
- .highlight { background: #272b30; color: #e9ecef; border-radius: 4px; margin: 1em 0; }
12
- .highlight pre { margin: 0; padding: 10px; }
13
- .highlight .k { color: #cc7832; font-weight: bold; } /* Keyword */
14
- .highlight .kd { color: #cc7832; font-weight: bold; } /* Keyword.Declaration */
15
- .highlight .nb { color: #6897bb; } /* Name.Builtin */
16
- .highlight .nx { color: #ffc66d; } /* Name.Other */
17
- .highlight .nf { color: #ffc66d; } /* Name.Function */
18
- .highlight .mi { color: #6897bb; } /* Literal.Number.Integer */
19
- .highlight .s1 { color: #6a8759; } /* Literal.String.Single */
20
- .highlight .s2 { color: #6a8759; } /* Literal.String.Double */
21
- .highlight .c1 { color: #808080; font-style: italic; } /* Comment.Single */
22
- .highlight .lineno { color: #606366; margin-right: 10px; -webkit-user-select: none; user-select: none; }
23
- .highlight-javascript { padding: 0; }
24
-
25
- /* Method signatures */
26
- .sig { padding: 5px 10px; }
27
- .sig-name { color: #ffc66d; }
28
- .sig-param { color: #e9ecef; }
29
- .sig-param .sig-type { color: #6897bb; }
30
- .sig-returns { color: #cc7832; }
31
- .sig-returns .sig-type { color: #6897bb; }
32
- .sig-paren { color: #e9ecef; }
33
- .property .pre { color: #cc7832; }
34
-
35
- /* Inline code */
36
- code.literal { background: #2b2b2b; padding: 2px 4px; border-radius: 3px; }
37
- code.literal .pre { color: #e9ecef; }
38
-
39
- /* Links */
40
- .reference { color: #6897bb; text-decoration: none; }
41
- .reference:hover { text-decoration: underline; }
42
- .reference.external { color: #6a8759; }
43
-
44
- /* Notes */
45
- .admonition.note { background: #2b2b2b; padding: 12px 15px; border-left: 4px solid #6897bb; margin: 1em 0; }
46
- .admonition-title { color: #6897bb; font-weight: bold; margin: 0 0 5px 0; }
47
- CSS
48
- doc . at_css ( 'head' ) ? doc . at_css ( 'head' ) . add_child ( style ) : doc . add_child ( style )
49
-
50
- # Create a wrapper div for better styling
51
- if root = at_css ( 'body' )
52
- content = root . inner_html
53
- else
54
- content = doc . inner_html
55
- end
56
-
57
- # Create Django-like structure
58
- content = <<-HTML
59
- < div class ="document ">
60
- < div class ="documentwrapper ">
61
- < div class ="bodywrapper ">
62
- < div class ="body " role ="main ">
63
- #{ content }
64
- </ div>
65
- </ div>
66
- </ div>
67
- </ div>
68
- HTML
69
-
70
- doc . inner_html = content
71
-
7
+
72
8
# Handle source links
73
9
css ( 'h2' ) . each do |node |
74
10
if node . content . strip == 'Source'
@@ -319,6 +255,10 @@ def call
319
255
end
320
256
end
321
257
258
+ # Remove the navigation arrows and links
259
+ css ( '.nav' ) . remove if at_css ( '.nav' )
260
+ # If the arrows are in a different container, adjust the selector accordingly
261
+
322
262
doc
323
263
end
324
264
0 commit comments