codnar 0.1.67 → 0.1.68
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/Rakefile +1 -0
- data/codnar.html +519 -182
- data/doc/root.html +1 -0
- data/doc/system.markdown +46 -15
- data/lib/codnar.rb +3 -0
- data/lib/codnar/coderay.rb +17 -0
- data/lib/codnar/data/coderay.css +127 -0
- data/lib/codnar/data/gvim.css +8 -0
- data/lib/codnar/data/style.css +0 -10
- data/lib/codnar/graphviz.rb +0 -2
- data/lib/codnar/markdown.rb +44 -40
- data/lib/codnar/rdoc.rb +9 -5
- data/lib/codnar/split_configurations.rb +29 -11
- data/lib/codnar/version.rb +1 -1
- data/test/coderay_highlight_syntax.rb +25 -0
- data/test/expand_markdown.rb +5 -5
- data/test/expand_rdoc.rb +4 -4
- data/test/format_code_configurations.rb +71 -0
- data/test/split_code.rb +1 -1
- data/test/split_documentation.rb +1 -1
- metadata +39 -22
- data/test/format_code_gvim_configurations.rb +0 -55
- data/test/format_code_sunlight_configurations.rb +0 -37
data/doc/root.html
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
<embed src="codnar/data/yui/reset.css" type="x-codnar/file"/>
|
8
8
|
<embed src="codnar/data/yui/base.css" type="x-codnar/file"/>
|
9
9
|
<embed src="codnar/data/style.css" type="x-codnar/file"/>
|
10
|
+
<embed src="codnar/data/gvim.css" type="x-codnar/file"/>
|
10
11
|
</style>
|
11
12
|
</head>
|
12
13
|
<body>
|
data/doc/system.markdown
CHANGED
@@ -183,11 +183,11 @@ And here is the implementation:
|
|
183
183
|
|
184
184
|
#### Syntax highlighting using GVIM ####
|
185
185
|
|
186
|
-
If you have
|
187
|
-
highlighting. This is a *slow* operation, as
|
188
|
-
|
189
|
-
scope; almost any language you can think of has a
|
190
|
-
definition. Here is a simple test that demonstrates using
|
186
|
+
If you have GVim istalled, it is possible to use it to generate syntax
|
187
|
+
highlighting. This is a *slow* operation, as GVim was never meant to be used as
|
188
|
+
a command-line tool. However, what it lacks in speed it compensates for in
|
189
|
+
scope; almost any language you can think of has a GVim syntax highlighting
|
190
|
+
definition. Here is a simple test that demonstrates using GVim for syntax
|
191
191
|
highlighting:
|
192
192
|
|
193
193
|
[[test/gvim_highlight_syntax.rb|named_chunk_with_containers]]
|
@@ -208,6 +208,23 @@ And here is the implementation:
|
|
208
208
|
|
209
209
|
[[lib/codnar/cache.rb|named_chunk_with_containers]]
|
210
210
|
|
211
|
+
#### Syntax highlighting using CodeRay ####
|
212
|
+
|
213
|
+
[CodeRay](http://coderay.rubychan.de/) is a Ruby gem that knows how to
|
214
|
+
highlight the syntax of many popular languages. It is much faster than using
|
215
|
+
GVim`but doesn't offer the huge range of programming languages offered by GVim
|
216
|
+
(for example, it does not currently offer shell script highlighting). If your
|
217
|
+
languages are covered by it, it may serve as a convenient replacement to the
|
218
|
+
slow GVim approach.
|
219
|
+
|
220
|
+
Here is a simple test that demonstrates using CodeRay for syntax highlighting:
|
221
|
+
|
222
|
+
[[test/coderay_highlight_syntax.rb|named_chunk_with_containers]]
|
223
|
+
|
224
|
+
And here is the implementation:
|
225
|
+
|
226
|
+
[[lib/codnar/coderay.rb|named_chunk_with_containers]]
|
227
|
+
|
211
228
|
#### Syntax highlighting using Sunlight ####
|
212
229
|
|
213
230
|
[Sunlight](http://sunlightjs.com/) offers a different approach for syntax
|
@@ -217,9 +234,8 @@ the DOM and convert it to highlighted HTML in the browser. This takes virtually
|
|
217
234
|
no time when splitting the code, but requires recomputing highlighting for all
|
218
235
|
the code chunks every time the HTML file is loaded. This can be pretty slow,
|
219
236
|
especially if using a browser with a slow Javascript engine, like IE. However,
|
220
|
-
|
221
|
-
|
222
|
-
coverage of different programming languages supported by GVIM.
|
237
|
+
this may be a reasonable trade-off, at least for small projects. Since Sunlight
|
238
|
+
is a new project, it supports a limited range of programming languages.
|
223
239
|
|
224
240
|
Here is a simple test that demonstrates using Sunlight for syntax highlighting:
|
225
241
|
|
@@ -267,7 +283,7 @@ box".
|
|
267
283
|
If one is willing to give up altogether on syntax highlighting and comment
|
268
284
|
formatting, the system would be applicable as-is to any programming language.
|
269
285
|
Properly highlighting almost any known programming language syntax would be a
|
270
|
-
simple matter of passing the correct syntax parameter to
|
286
|
+
simple matter of passing the correct syntax parameter to GVim.
|
271
287
|
|
272
288
|
Properly formatting comments in additional mark-up formats would be trickier.
|
273
289
|
First, a proper pattern needs to be established for extracting the comments
|
@@ -377,20 +393,35 @@ is very easy using GVim for syntax highlighting, as demonstrated here:
|
|
377
393
|
|
378
394
|
[[GVim syntax highlighting formatting configurations|named_chunk_with_containers]]
|
379
395
|
|
380
|
-
|
396
|
+
If you choose to use CSS classes instead of directly embedding fonts and colors
|
397
|
+
into the generated HTML, you will need a CSS stylesheet with the relevant
|
398
|
+
classes. Here is the default CSS stylesheet used by GVim:
|
399
|
+
|
400
|
+
[[lib/codnar/data/gvim.css|named_chunk_with_containers]]
|
401
|
+
|
402
|
+
#### Syntax highlighting using CodeRay ####
|
403
|
+
|
404
|
+
For supported programming languages, you may choose to use CodeRay instead of GVim.
|
405
|
+
|
406
|
+
[[CodeRay syntax highlighting formatting configurations|named_chunk_with_containers]]
|
407
|
+
|
408
|
+
If you choose to use CSS classes instead of directly embedding fonts and colors
|
409
|
+
into the generated HTML, you will need a CSS stylesheet with the relevant
|
410
|
+
classes. Here is the default CSS stylesheet used by CodeRay:
|
381
411
|
|
382
|
-
[[
|
412
|
+
[[lib/codnar/data/coderay.css|named_chunk_with_containers]]
|
383
413
|
|
384
414
|
#### Syntax highlighting using Sunlight ####
|
385
415
|
|
386
|
-
For small projects in
|
387
|
-
|
416
|
+
For small projects in supported languages, you may choose to use Sunlight
|
417
|
+
instead of GVim.
|
388
418
|
|
389
419
|
[[Sunlight syntax highlighting formatting configurations|named_chunk_with_containers]]
|
390
420
|
|
391
|
-
Here is a simple test demonstrating highlighting code syntax using
|
421
|
+
Here is a simple test demonstrating highlighting code syntax using the
|
422
|
+
different configurations (GVim, CodeRay, or Sunlight):
|
392
423
|
|
393
|
-
[[test/
|
424
|
+
[[test/format_code_configurations.rb|named_chunk_with_containers]]
|
394
425
|
|
395
426
|
#### Chunk splitting ####
|
396
427
|
|
data/lib/codnar.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require "andand"
|
2
2
|
require "base64"
|
3
3
|
require "cgi"
|
4
|
+
require "coderay"
|
4
5
|
require "digest/sha2"
|
5
6
|
require "erb"
|
6
7
|
require "fileutils"
|
7
8
|
require "irb"
|
9
|
+
require "open3"
|
8
10
|
require "rdiscount"
|
9
11
|
require "rdoc/markup/to_html"
|
10
12
|
require "tempfile"
|
@@ -18,6 +20,7 @@ require "olag/string_unindent"
|
|
18
20
|
|
19
21
|
require "codnar/version"
|
20
22
|
|
23
|
+
require "codnar/coderay"
|
21
24
|
require "codnar/hash_extensions"
|
22
25
|
require "codnar/markdown"
|
23
26
|
require "codnar/rdoc"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Codnar
|
2
|
+
|
3
|
+
# Extend the CodeRay module.
|
4
|
+
module CodeRay
|
5
|
+
|
6
|
+
# Convert a sequence of classified code lines to HTML using CodeRay syntax
|
7
|
+
# highlighting. The options control the way CodeRay behaves (e.g., <tt>:css
|
8
|
+
# => :class</tt>).
|
9
|
+
def self.lines_to_html(lines, syntax, options = {})
|
10
|
+
return Formatter.merge_lines(lines, "html") do |payload|
|
11
|
+
::CodeRay.scan(payload, syntax).div(options).chomp
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
/* Extracted from CodeRay output */
|
2
|
+
|
3
|
+
.CodeRay .line-numbers a {
|
4
|
+
text-decoration: inherit;
|
5
|
+
color: inherit;
|
6
|
+
}
|
7
|
+
.CodeRay {
|
8
|
+
background-color: hsl(0,0%,95%);
|
9
|
+
border: 1px solid silver;
|
10
|
+
color: black;
|
11
|
+
}
|
12
|
+
.CodeRay pre {
|
13
|
+
margin: 0px;
|
14
|
+
}
|
15
|
+
|
16
|
+
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
17
|
+
|
18
|
+
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
19
|
+
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
20
|
+
|
21
|
+
.CodeRay .line-numbers {
|
22
|
+
background-color: hsl(180,65%,90%);
|
23
|
+
color: gray;
|
24
|
+
text-align: right;
|
25
|
+
-webkit-user-select: none;
|
26
|
+
-moz-user-select: none;
|
27
|
+
user-select: none;
|
28
|
+
}
|
29
|
+
.CodeRay .line-numbers a {
|
30
|
+
background-color: hsl(180,65%,90%) !important;
|
31
|
+
color: gray !important;
|
32
|
+
text-decoration: none !important;
|
33
|
+
}
|
34
|
+
.CodeRay .line-numbers a:target { color: blue !important; }
|
35
|
+
.CodeRay .line-numbers .highlighted { color: red !important; }
|
36
|
+
.CodeRay .line-numbers .highlighted a { color: red !important; }
|
37
|
+
.CodeRay span.line-numbers { padding: 0px 4px; }
|
38
|
+
.CodeRay .line { display: block; float: left; width: 100%; }
|
39
|
+
.CodeRay .code { width: 100%; }
|
40
|
+
.CodeRay .code pre { overflow: auto; }
|
41
|
+
|
42
|
+
.CodeRay .debug { color: white !important; background: blue !important; }
|
43
|
+
|
44
|
+
.CodeRay .annotation { color:#007 }
|
45
|
+
.CodeRay .attribute-name { color:#b48 }
|
46
|
+
.CodeRay .attribute-value { color:#700 }
|
47
|
+
.CodeRay .binary { color:#509 }
|
48
|
+
.CodeRay .char .content { color:#D20 }
|
49
|
+
.CodeRay .char .delimiter { color:#710 }
|
50
|
+
.CodeRay .char { color:#D20 }
|
51
|
+
.CodeRay .class { color:#B06; font-weight:bold }
|
52
|
+
.CodeRay .class-variable { color:#369 }
|
53
|
+
.CodeRay .color { color:#0A0 }
|
54
|
+
.CodeRay .comment { color:#777 }
|
55
|
+
.CodeRay .comment .char { color:#444 }
|
56
|
+
.CodeRay .comment .delimiter { color:#444 }
|
57
|
+
.CodeRay .complex { color:#A08 }
|
58
|
+
.CodeRay .constant { color:#036; font-weight:bold }
|
59
|
+
.CodeRay .decorator { color:#B0B }
|
60
|
+
.CodeRay .definition { color:#099; font-weight:bold }
|
61
|
+
.CodeRay .delimiter { color:black }
|
62
|
+
.CodeRay .directive { color:#088; font-weight:bold }
|
63
|
+
.CodeRay .doc { color:#970 }
|
64
|
+
.CodeRay .doc-string { color:#D42; font-weight:bold }
|
65
|
+
.CodeRay .doctype { color:#34b }
|
66
|
+
.CodeRay .entity { color:#800; font-weight:bold }
|
67
|
+
.CodeRay .error { color:#F00; background-color:#FAA }
|
68
|
+
.CodeRay .escape { color:#666 }
|
69
|
+
.CodeRay .exception { color:#C00; font-weight:bold }
|
70
|
+
.CodeRay .float { color:#60E }
|
71
|
+
.CodeRay .function { color:#06B; font-weight:bold }
|
72
|
+
.CodeRay .global-variable { color:#d70 }
|
73
|
+
.CodeRay .hex { color:#02b }
|
74
|
+
.CodeRay .imaginary { color:#f00 }
|
75
|
+
.CodeRay .include { color:#B44; font-weight:bold }
|
76
|
+
.CodeRay .inline { background-color: hsla(0,0%,0%,0.07); color: black }
|
77
|
+
.CodeRay .inline-delimiter { font-weight: bold; color: #666 }
|
78
|
+
.CodeRay .instance-variable { color:#33B }
|
79
|
+
.CodeRay .integer { color:#00D }
|
80
|
+
.CodeRay .key .char { color: #60f }
|
81
|
+
.CodeRay .key .delimiter { color: #404 }
|
82
|
+
.CodeRay .key { color: #606 }
|
83
|
+
.CodeRay .keyword { color:#080; font-weight:bold }
|
84
|
+
.CodeRay .label { color:#970; font-weight:bold }
|
85
|
+
.CodeRay .local-variable { color:#963 }
|
86
|
+
.CodeRay .namespace { color:#707; font-weight:bold }
|
87
|
+
.CodeRay .octal { color:#40E }
|
88
|
+
.CodeRay .operator { }
|
89
|
+
.CodeRay .predefined { color:#369; font-weight:bold }
|
90
|
+
.CodeRay .predefined-constant { color:#069 }
|
91
|
+
.CodeRay .predefined-type { color:#0a5; font-weight:bold }
|
92
|
+
.CodeRay .preprocessor { color:#579 }
|
93
|
+
.CodeRay .pseudo-class { color:#00C; font-weight:bold }
|
94
|
+
.CodeRay .regexp .content { color:#808 }
|
95
|
+
.CodeRay .regexp .delimiter { color:#404 }
|
96
|
+
.CodeRay .regexp .modifier { color:#C2C }
|
97
|
+
.CodeRay .regexp { background-color:hsla(300,100%,50%,0.06); }
|
98
|
+
.CodeRay .reserved { color:#080; font-weight:bold }
|
99
|
+
.CodeRay .shell .content { color:#2B2 }
|
100
|
+
.CodeRay .shell .delimiter { color:#161 }
|
101
|
+
.CodeRay .shell { background-color:hsla(120,100%,50%,0.06); }
|
102
|
+
.CodeRay .string .char { color: #b0b }
|
103
|
+
.CodeRay .string .content { color: #D20 }
|
104
|
+
.CodeRay .string .delimiter { color: #710 }
|
105
|
+
.CodeRay .string .modifier { color: #E40 }
|
106
|
+
.CodeRay .string { background-color:hsla(0,100%,50%,0.05); }
|
107
|
+
.CodeRay .symbol .content { color:#A60 }
|
108
|
+
.CodeRay .symbol .delimiter { color:#630 }
|
109
|
+
.CodeRay .symbol { color:#A60 }
|
110
|
+
.CodeRay .tag { color:#070 }
|
111
|
+
.CodeRay .type { color:#339; font-weight:bold }
|
112
|
+
.CodeRay .value { color: #088; }
|
113
|
+
.CodeRay .variable { color:#037 }
|
114
|
+
|
115
|
+
.CodeRay .insert { background: hsla(120,100%,50%,0.12) }
|
116
|
+
.CodeRay .delete { background: hsla(0,100%,50%,0.12) }
|
117
|
+
.CodeRay .change { color: #bbf; background: #007; }
|
118
|
+
.CodeRay .head { color: #f8f; background: #505 }
|
119
|
+
.CodeRay .head .filename { color: white; }
|
120
|
+
|
121
|
+
.CodeRay .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; }
|
122
|
+
.CodeRay .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }
|
123
|
+
|
124
|
+
.CodeRay .insert .insert { color: #0c0; background:transparent; font-weight:bold }
|
125
|
+
.CodeRay .delete .delete { color: #c00; background:transparent; font-weight:bold }
|
126
|
+
.CodeRay .change .change { color: #88f }
|
127
|
+
.CodeRay .head .head { color: #f4f }
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/* Colors for GVim classes */
|
2
|
+
span.Constant { color: Crimson; }
|
3
|
+
span.Identifier { color: Teal; }
|
4
|
+
span.PreProc { color: Indigo; }
|
5
|
+
span.Special { color: Navy; }
|
6
|
+
span.Statement { color: Maroon; }
|
7
|
+
span.Type { color: Green; }
|
8
|
+
span.Comment { color: Purple; }
|
data/lib/codnar/data/style.css
CHANGED
@@ -72,16 +72,6 @@ table.layout td.html {
|
|
72
72
|
background-color: Beige;
|
73
73
|
}
|
74
74
|
|
75
|
-
/* Colors for GVim classes */
|
76
|
-
|
77
|
-
span.Constant { color: Crimson; }
|
78
|
-
span.Identifier { color: Teal; }
|
79
|
-
span.PreProc { color: Indigo; }
|
80
|
-
span.Special { color: Navy; }
|
81
|
-
span.Statement { color: Maroon; }
|
82
|
-
span.Type { color: Green; }
|
83
|
-
span.Comment { color: Purple; }
|
84
|
-
|
85
75
|
/* Fonts */
|
86
76
|
|
87
77
|
body {
|
data/lib/codnar/graphviz.rb
CHANGED
data/lib/codnar/markdown.rb
CHANGED
@@ -1,47 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# normal Markdown syntax, processing supports the following Codnar-specific
|
6
|
-
# extensions:
|
7
|
-
#
|
8
|
-
# * The notation "[[chunk|template]]" is expanded to embedding the specified
|
9
|
-
# chunk (name) using the specified template at Weave time.
|
10
|
-
# * The notation "[[#name]]" defines an empty anchor. The HTML anchor id is
|
11
|
-
# not the specified name, but rather the identifier generated from it (in
|
12
|
-
# the same way that chunk names are converted to identifiers).
|
13
|
-
# * The notation "[...](#name)" defines a link to an anchor, which is either
|
14
|
-
# the chunk with the specified name, or an empty anchor defined as above.
|
15
|
-
def self.to_html(markdown)
|
16
|
-
markdown = Markdown.embed_chunks(markdown)
|
17
|
-
markdown = Markdown.id_anchors(markdown)
|
18
|
-
html = RDiscount.new(markdown).to_html
|
19
|
-
html = Markdown.id_links(html)
|
20
|
-
return html.clean_markup_html
|
21
|
-
end
|
1
|
+
module Codnar
|
2
|
+
|
3
|
+
# Convert Markdown to HTML.
|
4
|
+
module Markdown
|
22
5
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
6
|
+
# Process a Markdown String and return the resulting HTML. In addition to the
|
7
|
+
# normal Markdown syntax, processing supports the following Codnar-specific
|
8
|
+
# extensions:
|
9
|
+
#
|
10
|
+
# * The notation "[[chunk|template]]" is expanded to embedding the specified
|
11
|
+
# chunk (name) using the specified template at Weave time.
|
12
|
+
# * The notation "[[#name]]" defines an empty anchor. The HTML anchor id is
|
13
|
+
# not the specified name, but rather the identifier generated from it (in
|
14
|
+
# the same way that chunk names are converted to identifiers).
|
15
|
+
# * The notation "[...](#name)" defines a link to an anchor, which is either
|
16
|
+
# the chunk with the specified name, or an empty anchor defined as above.
|
17
|
+
def self.to_html(markdown)
|
18
|
+
markdown = embed_chunks(markdown)
|
19
|
+
markdown = id_anchors(markdown)
|
20
|
+
html = RDiscount.new(markdown).to_html
|
21
|
+
html = id_links(html)
|
22
|
+
return html.clean_markup_html
|
34
23
|
end
|
35
|
-
end
|
36
24
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
protected
|
26
|
+
|
27
|
+
# Expand "[[chunk|template]]" to HTML embed tags. Use identifiers instead of
|
28
|
+
# names in the +src+ field for safety, unless the template is a magical file
|
29
|
+
# template, in which case we must preserve the file path.
|
30
|
+
def self.embed_chunks(markdown)
|
31
|
+
return markdown.gsub(/\[\[(.*?)\|(.*?)\]\]/) do
|
32
|
+
src = $1
|
33
|
+
template = $2
|
34
|
+
src = src.to_id unless Codnar::Weaver::FILE_TEMPLATE_PROCESSORS.include?(template)
|
35
|
+
"<embed src='#{src}' type='x-codnar/#{template}'/>"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Expand "[[#name]]" anchors to HTML anchor tags with the matching identifier.
|
40
|
+
def self.id_anchors(markdown)
|
41
|
+
return markdown.gsub(/\[\[#(.*?)\]\]/) { "<a id='#{$1.to_id}'/>" }
|
42
|
+
end
|
43
|
+
|
44
|
+
# Expand "href='#name'" links to the matching "href='#id'" links.
|
45
|
+
def self.id_links(html)
|
46
|
+
return html.gsub(/href=(["'])#(.*?)(["'])/) { "href=#{$1}##{$2.to_id}#{$3}" }
|
47
|
+
end
|
41
48
|
|
42
|
-
# Expand "href='#name'" links to the matching "href='#id'" links.
|
43
|
-
def self.id_links(html)
|
44
|
-
return html.gsub(/href=(["'])#(.*?)(["'])/) { "href=#{$1}##{$2.to_id}#{$3}" }
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
data/lib/codnar/rdoc.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Codnar
|
2
|
+
|
3
|
+
# Convert RDoc to HTML.
|
4
|
+
module RDoc
|
5
|
+
|
6
|
+
# Process a RDoc String and return the resulting HTML.
|
7
|
+
def self.to_html(rdoc)
|
8
|
+
return ::RDoc::Markup::ToHtml.new.convert(rdoc).clean_markup_html
|
9
|
+
end
|
3
10
|
|
4
|
-
# Process a RDoc String and return the resulting HTML.
|
5
|
-
def self.to_html(rdoc)
|
6
|
-
return ::RDoc::Markup::ToHtml.new.convert(rdoc).clean_markup_html
|
7
11
|
end
|
8
12
|
|
9
13
|
end
|
@@ -39,7 +39,7 @@ module Codnar
|
|
39
39
|
# "Split" a documentation file containing pure RDoc documentation.
|
40
40
|
SPLIT_RDOC_DOCUMENTATION = SPLIT_HTML_DOCUMENTATION.deep_merge(
|
41
41
|
"formatters" => {
|
42
|
-
"doc" => "Formatter.markup_lines_to_html(lines, RDoc)",
|
42
|
+
"doc" => "Formatter.markup_lines_to_html(lines, Codnar::RDoc, 'rdoc')",
|
43
43
|
"unindented_html" => "Formatter.unindented_lines_to_html(lines)",
|
44
44
|
}
|
45
45
|
)
|
@@ -47,7 +47,7 @@ module Codnar
|
|
47
47
|
# "Split" a documentation file containing pure Markdown documentation.
|
48
48
|
SPLIT_MARKDOWN_DOCUMENTATION = SPLIT_HTML_DOCUMENTATION.deep_merge(
|
49
49
|
"formatters" => {
|
50
|
-
"doc" => "Formatter.markup_lines_to_html(lines, Markdown, 'markdown')",
|
50
|
+
"doc" => "Formatter.markup_lines_to_html(lines, Codnar::Markdown, 'markdown')",
|
51
51
|
"unindented_html" => "Formatter.unindented_lines_to_html(lines)",
|
52
52
|
}
|
53
53
|
)
|
@@ -277,7 +277,7 @@ module Codnar
|
|
277
277
|
# configuration that classifies some lines as +comment+.
|
278
278
|
FORMAT_RDOC_COMMENTS = {
|
279
279
|
"formatters" => {
|
280
|
-
"comment" => "Formatter.markup_lines_to_html(lines,
|
280
|
+
"comment" => "Formatter.markup_lines_to_html(lines, Codnar::RDoc, 'rdoc')",
|
281
281
|
"unindented_html" => "Formatter.unindented_lines_to_html(lines)",
|
282
282
|
},
|
283
283
|
}
|
@@ -295,31 +295,49 @@ module Codnar
|
|
295
295
|
|
296
296
|
# {{{ GVim syntax highlighting formatting configurations
|
297
297
|
|
298
|
-
# Format code using GVim's
|
298
|
+
# Format code using GVim's syntax highlighting, using explicit HTML
|
299
299
|
# constructs. Assumes some previous configuration already classified the
|
300
300
|
# code lines.
|
301
301
|
FORMAT_CODE_GVIM_HTML = lambda do |syntax|
|
302
|
-
return Configuration.
|
302
|
+
return Configuration.klass_code_format('GVim', syntax, "[]")
|
303
303
|
end
|
304
304
|
|
305
|
-
# Format code using GVim's
|
306
|
-
#
|
307
|
-
#
|
305
|
+
# Format code using GVim's syntax highlighting, using CSS classes instead
|
306
|
+
# of explicit font and color styles. Assumes some previous configuration
|
307
|
+
# already classified the code lines.
|
308
308
|
FORMAT_CODE_GVIM_CSS = lambda do |syntax|
|
309
|
-
return Configuration.
|
309
|
+
return Configuration.klass_code_format('GVim', syntax, "[ '+:let html_use_css=1' ]")
|
310
310
|
end
|
311
311
|
|
312
312
|
# Return a configuration for highlighting a specific syntax using GVim.
|
313
|
-
def self.
|
313
|
+
def self.klass_code_format(klass, syntax, options)
|
314
314
|
return {
|
315
315
|
"formatters" => {
|
316
|
-
"#{syntax}_code" => "
|
316
|
+
"#{syntax}_code" => "#{klass}.lines_to_html(lines, '#{syntax}', #{options})",
|
317
317
|
},
|
318
318
|
}
|
319
319
|
end
|
320
320
|
|
321
321
|
# }}}
|
322
322
|
|
323
|
+
# {{{ CodeRay syntax highlighting formatting configurations
|
324
|
+
|
325
|
+
# Format code using CodeRay's syntax highlighting, using explicit HTML
|
326
|
+
# constructs. Assumes some previous configuration already classified the
|
327
|
+
# code lines.
|
328
|
+
FORMAT_CODE_CODERAY_HTML = lambda do |syntax|
|
329
|
+
return Configuration.klass_code_format('CodeRay', syntax, "{}")
|
330
|
+
end
|
331
|
+
|
332
|
+
# Format code using CodeRay's syntax highlighting, using CSS classes
|
333
|
+
# instead of explicit font and color styles. Assumes some previous
|
334
|
+
# configuration already classified the code lines.
|
335
|
+
FORMAT_CODE_CODERAY_CSS = lambda do |syntax|
|
336
|
+
return Configuration.klass_code_format('CodeRay', syntax, "{ :css => :class }")
|
337
|
+
end
|
338
|
+
|
339
|
+
# }}}
|
340
|
+
|
323
341
|
# {{{ Sunlight syntax highlighting formatting configurations
|
324
342
|
|
325
343
|
# Format code using Sunlight's syntax highlighting. This assumes the HTML
|