ron 0.1 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/ron/layout.html CHANGED
@@ -1,39 +1,75 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>#{name}(#{section}) -- #{tagline}</title>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ron/v#{Ron::VERSION}'>
6
+ <title>#{name}(#{section})#{tagline ? " -- " + tagline : ''}</title>
5
7
  <style type='text/css'>
6
- body {
8
+ body {margin:0}
9
+ #man, #man code, #man pre, #man tt, #man kbd, #man samp {
7
10
  font-family:consolas,monospace;
8
- font-size:18px;
9
- line-height:1.25;
10
- color:#111
11
+ font-size:16px;
12
+ line-height:1.3;
13
+ color:#343331;
14
+ background:#fff; }
15
+ #man { max-width:89ex; text-align:justify; margin:0 25px 25px 25px }
16
+ #man h1, #man h2, #man h3 { color:#232221;clear:left }
17
+ #man h1 { font-size:28px; margin:15px 0 30px 0; text-align:center }
18
+ #man h2 { font-size:18px; margin-bottom:0; margin-top:10px; line-height:1.3; }
19
+ #man h3 { font-size:16px; margin:0 0 0 4ex; }
20
+ #man p, #man ul, #man ol, #man dl, #man pre { margin:0 0 18px 0; }
21
+ #man pre {
22
+ color:#333231;
23
+ background:#edeceb;
24
+ padding:5px 7px;
25
+ margin:0px 0 20px 0;
26
+ border-left:2ex solid #ddd}
27
+ #man pre + h2, #man pre + h3 {
28
+ margin-top:22px;
11
29
  }
12
- #man { max-width:42em;text-align:justify;margin:25px }
13
- #man h1, #man h2, #man h3, #man strong, #man code { color:#111 }
14
- #man h1 { text-align:center }
15
- #man h2 { font-size:20px;margin-bottom:0 }
16
- #man h3 { font-size:18px;margin:0 0 0 50px }
17
- #man p, #man ul, #man ol, #man dl, #man pre
18
- { margin:0 0 24px 0; }
19
- #man pre { color:#555;font-size:16px }
20
- #man > p, #man > ul, #man > ol, #man > dl, #man > pre
21
- { margin:0 0 24px 80px; }
22
- #man dt { margin:0;clear:left }
23
- #man dt.flush { float:left;width:105px }
24
- #man dd { margin:0 0 0 105px }
25
- #man code { font-weight:bold; }
26
- #man pre code { font-weight:normal;color:#555 }
27
- #man em { font-style:normal;text-decoration:underline }
30
+ #man h2 + pre, #man h3 + pre {
31
+ margin-top:5px;
32
+ }
33
+ #man > p, #man > ul, #man > ol, #man > dl, #man > pre { margin-left:8ex; }
34
+ #man dt { margin:0; clear:left }
35
+ #man dt.flush { float:left; width:8ex }
36
+ #man dd { margin:0 0 0 9ex }
37
+ #man code, #man strong, #man b { font-weight:bold; color:#131211; }
38
+ #man pre code { font-weight:normal; color:#232221; background:inherit }
39
+ #man em, var, u {
40
+ font-style:normal; color:#333231; border-bottom:1px solid #999; }
41
+ #man h1.man-title { display:none; }
42
+ #man ol.man, #man ol.man li { margin:2px 0 10px 0; padding:0;
43
+ float:left; width:33%; list-style-type:none;
44
+ text-transform:uppercase; font-size:18px; color:#999;
45
+ letter-spacing:1px;}
46
+ #man ol.man { width:100%; }
47
+ #man ol.man li.tl { text-align:left }
48
+ #man ol.man li.tc { text-align:center;letter-spacing:4px }
49
+ #man ol.man li.tr { text-align:right }
50
+ #man ol.man a { color:#999 }
51
+ #man ol.man a:hover { color:#333231 }
28
52
  </style>
29
53
  </head>
30
54
  <body>
31
55
  <div id='man'>
32
56
 
33
- <h1>#{@name}(#{@section})</h1>
57
+ <h1 class='man-title'>#{name}(#{section})</h1>
58
+
59
+ <ol class='head man'>
60
+ <li class='tl'>#{name if section}#{"("+section+")" if name and section}</li>
61
+ <li class='tc'>#{manual}</li>
62
+ <li class='tr'>#{name if section}#{"("+section+")" if name and section}</li>
63
+ </ol>
34
64
 
35
65
  #{html}
36
66
 
67
+ <ol class='foot man'>
68
+ <li class='tl'>#{organization}</li>
69
+ <li class='tc'>#{date.strftime('%B %Y')}</li>
70
+ <li class='tr'>#{name if section}#{"("+section+")" if name and section}</li>
71
+ </ol>
72
+
37
73
  </div>
38
74
  </body>
39
75
  </html>
data/lib/ron/roff.rb CHANGED
@@ -16,9 +16,9 @@ module Ron
16
16
 
17
17
  protected
18
18
  def title_heading(name, section, tagline, manual, version, date)
19
- comment "generated with Ron"
19
+ comment "generated with Ron/v#{Ron::VERSION}"
20
20
  comment "http://github.com/rtomayko/ron/"
21
- macro "TH", %["#{escape(name.upcase)}" #{section} "#{date}" "#{version}" "#{manual}"]
21
+ macro "TH", %["#{escape(name.upcase)}" "#{section}" "#{date.strftime('%B %Y')}" "#{version}" "#{manual}"]
22
22
  end
23
23
 
24
24
  def block_filter(node)
@@ -54,9 +54,13 @@ module Ron
54
54
  end
55
55
  inline_filter(node.children)
56
56
  when 'pre'
57
+ indent = prev.nil? || !%w[h1 h2 h3].include?(prev.name)
58
+ macro "IP", %w["" 4] if indent
57
59
  macro "nf"
60
+ write "\n"
58
61
  inline_filter(node.search('code').children)
59
62
  macro "fi"
63
+ macro "IP", %w["" 0] if indent
60
64
 
61
65
  # definition lists
62
66
  when 'dl'
@@ -74,6 +78,25 @@ module Ron
74
78
  end
75
79
  write "\n"
76
80
 
81
+ # ordered/unordered lists
82
+ # when 'ol'
83
+ # macro "IP", '1.'
84
+ # block_filter(node.children)
85
+ when 'ul'
86
+ block_filter(node.children)
87
+ macro "IP", %w["" 0]
88
+ when 'li'
89
+ case node.parent.name
90
+ when 'ul'
91
+ macro "IP", %w["\(bu" 4]
92
+ end
93
+ if node.search('p', 'ol', 'ul', 'dl', 'div').any?
94
+ block_filter(node.children)
95
+ else
96
+ inline_filter(node.children)
97
+ end
98
+ write "\n"
99
+
77
100
  else
78
101
  warn "unrecognized block tag: %p", node.name
79
102
  end
@@ -85,14 +108,24 @@ module Ron
85
108
  return
86
109
  end
87
110
 
111
+ prev = node.previous_sibling
112
+ prev = prev.previous_sibling until prev.nil? || prev.element?
113
+
88
114
  case node.name
89
115
  when 'text'
90
- write escape(node.to_s.sub(/\n+$/, ' '))
91
- when 'code', 'b', 'strong'
116
+ text = node.content.dup
117
+ text.sub!(/^\n+/m, '') if prev && prev.name == 'br'
118
+ if node.previous_sibling.nil? && node.next_sibling
119
+ text.sub!(/\n+$/m, '')
120
+ else
121
+ text.sub!(/\n+$/m, ' ')
122
+ end
123
+ write escape(text)
124
+ when 'code', 'b', 'strong', 'kbd', 'samp'
92
125
  write '\fB'
93
126
  inline_filter(node.children)
94
127
  write '\fR'
95
- when 'em', 'i', 'u'
128
+ when 'var', 'em', 'i', 'u'
96
129
  write '\fI'
97
130
  inline_filter(node.children)
98
131
  write '\fR'
@@ -126,7 +159,7 @@ module Ron
126
159
 
127
160
  # write text to output buffer
128
161
  def write(text)
129
- @buf << text
162
+ @buf << text unless text.nil? || text.empty?
130
163
  end
131
164
 
132
165
  # write text to output buffer on a new line.
data/lib/ron.rb CHANGED
@@ -3,13 +3,14 @@
3
3
  # install standard UNIX roff(7) formatted manpages or to generate
4
4
  # beautiful HTML manpages.
5
5
  module Ron
6
- VERSION = '0.1'
6
+ VERSION = '0.3'
7
7
 
8
8
  require 'ron/document'
9
9
  require 'ron/roff'
10
10
 
11
- # Create a new Ron::Document for the given ron file.
12
- def self.new(filename, &block)
13
- Document.new(filename, &block)
11
+ # Create a new Ron::Document for the given ron file. See
12
+ # Ron::Document.new for usage information.
13
+ def self.new(filename, attributes={}, &block)
14
+ Document.new(filename, attributes, &block)
14
15
  end
15
16
  end