erbook 8.0.0 → 9.0.0

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.
@@ -397,9 +397,9 @@
397
397
  ----------------------------------*/
398
398
  .ui-tabs { padding: .2em; zoom: 1; }
399
399
  .ui-tabs .ui-tabs-nav { list-style: none; position: relative; padding: .2em .2em 0; }
400
- .ui-tabs .ui-tabs-nav li { position: relative; float: left; border-bottom-width: 0 !important; margin: 0 .2em -1px 0; padding: 0; }
400
+ .ui-tabs .ui-tabs-nav li { position: relative; float: left; margin: 0 .2em -1px 0; padding: 0 0 1px 0; }
401
401
  .ui-tabs .ui-tabs-nav li a { float: left; text-decoration: none; padding: .5em 1em; }
402
- .ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 1px; border-bottom-width: 0; }
402
+ .ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 2px; border-bottom-width: 0 !important; }
403
403
  .ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
404
404
  .ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
405
405
  .ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border-width: 0; background: none; }
@@ -9,8 +9,8 @@ require 'inochi'
9
9
 
10
10
  Inochi.init :ERBook,
11
11
  :program => 'erbook',
12
- :version => '8.0.0',
13
- :release => '2009-10-10',
12
+ :version => '9.0.0',
13
+ :release => '2009-10-18',
14
14
  :website => 'http://snk.tuxfamily.org/lib/erbook/',
15
15
  :tagline => 'Write books, manuals, and documents in eRuby',
16
16
  :require => {
@@ -19,6 +19,7 @@ Inochi.init :ERBook,
19
19
  'coderay' => '>= 0.8', # for syntax coloring of source code
20
20
  'haml' => '>= 2.2.2', # for generating HTML and CSS
21
21
  'mime-types' => '>= 1.16', # for detecting MIME types
22
+ 'json' => nil, # for emitting JSON
22
23
  }
23
24
 
24
25
  module ERBook
@@ -81,7 +81,7 @@ module ERBook
81
81
  # Handles the method call from a node
82
82
  # placeholder in the input document.
83
83
  #
84
- def sandbox.__node_impl__ node_type, *node_args, &node_content
84
+ def sandbox.__node_handler__ node_type, *node_args, &node_content
85
85
  node = Node.new(
86
86
  :type => node_type,
87
87
  :definition => @format['nodes'][node_type],
@@ -153,7 +153,7 @@ module ERBook
153
153
  # does not accept a block until Ruby 1.9
154
154
  file, line = __FILE__, __LINE__; eval %{
155
155
  def sandbox.#{type} *node_args, &node_content
156
- __node_impl__ #{type.inspect}, *node_args, &node_content
156
+ __node_handler__ #{type.inspect}, *node_args, &node_content
157
157
  end
158
158
  }, binding, file, line
159
159
  end
@@ -163,7 +163,7 @@ module ERBook
163
163
  @processed_document = template.buffer
164
164
 
165
165
  # chain block-level nodes together for local navigation
166
- block_nodes = @nodes.select {|n| n.anchor? }
166
+ block_nodes = @nodes.select {|n| n.chain? }
167
167
 
168
168
  require 'enumerator'
169
169
  block_nodes.each_cons(2) do |a, b|
@@ -200,9 +200,16 @@ module ERBook
200
200
  actual_output[c.output] = actual_output_by_node[c]
201
201
 
202
202
  else
203
- # pull block-level child out of paragraph tag added by Maruku
204
- actual_output.sub! %r/(<p>\s*)?#{Regexp.quote c.output}/ do
205
- actual_output_by_node[c] + $1.to_s
203
+ # remove <p> around block-level child (added by Markdown)
204
+ actual_output.sub! %r{(<p>\s*)?#{
205
+ Regexp.quote c.output
206
+ }(\s*</p>)?} do
207
+ actual_output_by_node[c] +
208
+ if $1 and $2
209
+ ''
210
+ else
211
+ [$1, $2].join
212
+ end
206
213
  end
207
214
  end
208
215
  end
@@ -266,8 +273,11 @@ module ERBook
266
273
  Array(definition['number']).include? 'ordinal'
267
274
  end
268
275
 
269
- def anchor?
270
- not inline? and not silent?
276
+ ##
277
+ # Include this node in the previous/next navigation chain?
278
+ #
279
+ def chain?
280
+ definition['chain']
271
281
  end
272
282
 
273
283
  def inline?
@@ -1,5 +1,5 @@
1
- # This file defines the String#to_xhtml and String#to_inline_xhtml
2
- # methods, which are invoked to transform plain text into XHTML.
1
+ # This file defines the String#to_xhtml method which
2
+ # is invoked to transform plain text into XHTML.
3
3
  #
4
4
  # This particular implementation features the Markdown
5
5
  # formatting system via Maruku, syntax coloring via CodeRay,
@@ -44,25 +44,12 @@ class String
44
44
  }
45
45
 
46
46
  ##
47
- # Transforms this string into an *inline* XHTML string (one that
48
- # does not contain any block-level XHTML elements at the root).
47
+ # Transforms this string into XHTML.
49
48
  #
50
- def to_inline_xhtml
51
- to_xhtml true
52
- end
53
-
54
- ##
55
- # Transforms this string into XHTML while ensuring that the
56
- # result contains one or more block-level elements at the root.
57
- #
58
- # [inline]
59
- # If true, the resulting XHTML will *not*
60
- # contain a block-level element at the root.
61
- #
62
- def to_xhtml inline = false
49
+ def to_xhtml
63
50
  with_protected_tags(self, VERBATIM_TAGS, true) do |text|
64
51
  html = with_protected_tags(text, PROTECTED_TAGS, false) do
65
- |s| s.thru_maruku inline
52
+ |s| s.thru_maruku
66
53
  end
67
54
 
68
55
  # Markdown's "code spans" should really be "pre spans"
@@ -90,11 +77,7 @@ class String
90
77
  ##
91
78
  # Returns the result of running this string through Maruku.
92
79
  #
93
- # [inline]
94
- # If true, the resulting XHTML will *not*
95
- # be wrapped in a XHTML paragraph element.
96
- #
97
- def thru_maruku inline = false #:nodoc:
80
+ def thru_maruku #:nodoc:
98
81
  #
99
82
  # XXX: add a newline at the beginning of the text to
100
83
  # prevent Maruku from interpreting the first line
@@ -104,9 +87,10 @@ class String
104
87
  # see this bug report for details:
105
88
  # http://rubyforge.org/tracker/?func=detail&atid=10735&aid=25697&group_id=2795
106
89
  #
107
- html = Maruku.new("\n#{self}").to_html
108
- html.sub! %r{\A<p>(.*)</p>\Z}, '\1' if inline
109
- html
90
+ Maruku.new("\n#{self}").to_html.
91
+
92
+ # omit the <p> added by Maruku
93
+ sub(%r{\A<p>(.*)</p>\Z}, '\1')
110
94
  end
111
95
 
112
96
  ##
@@ -116,8 +100,9 @@ class String
116
100
  # or a class="para" attribute, according to whether it
117
101
  # spans a single line or multiple lines of code.
118
102
  #
119
- # In the latter case, the <code> element is replaced with a <pre> element
120
- # so that its multi-line body appears correctly in text-mode web browsers.
103
+ # In the latter case, the <code> element is replaced
104
+ # with a <pre> element so that its multi-line body
105
+ # appears correctly in text-mode web browsers.
121
106
  #
122
107
  # If a <code> element has a lang="..." attribute,
123
108
  # then that attribute's value is considered to be
@@ -128,7 +113,9 @@ class String
128
113
  def thru_coderay #:nodoc:
129
114
  gsub %r{<(code)(.*?)>(.*?)</\1>}m do
130
115
  elem, atts, code = $1, $2, CGI.unescapeHTML($3).sub(/\A\r?\n/, '')
131
- lang = atts[/\blang=('|")(.*?)\1/i, 2] || :ruby
116
+
117
+ lang = atts[/\blang=('|")(.*?)\1/i, 2]
118
+ lang = :ruby if lang !~ /\S/
132
119
 
133
120
  body = CodeRay.scan(code, lang).html(:css => :style)
134
121
 
@@ -143,7 +130,11 @@ class String
143
130
  tail = "</#{elem}>"
144
131
  end
145
132
 
146
- %{#{head} class="#{span}"#{atts}>#{body}#{tail}}
133
+ unless atts.sub!(/\b(class=('|"))(.*?\2)/){ $1 + span + ' ' + $3 }
134
+ atts << %{ class="#{span}"}
135
+ end
136
+
137
+ %{#{head}#{atts}>#{body}#{tail}}
147
138
  end
148
139
  end
149
140
 
@@ -0,0 +1,17 @@
1
+ unless ERBook.const_defined? :INOCHI
2
+ fail "ERBook must be established by Inochi"
3
+ end
4
+
5
+ ERBook::INOCHI.each do |param, value|
6
+ const = param.to_s.upcase
7
+
8
+ unless ERBook.const_defined? const
9
+ fail "ERBook::#{const} must be established by Inochi"
10
+ end
11
+
12
+ unless ERBook.const_get(const) == value
13
+ fail "ERBook::#{const} is not what Inochi established"
14
+ end
15
+ end
16
+
17
+ puts "Inochi establishment tests passed!"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suraj N. Kurapati
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-10 00:00:00 -07:00
12
+ date: 2009-10-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "1.16"
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: json
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
65
75
  - !ruby/object:Gem::Dependency
66
76
  name: inochi
67
77
  type: :development
@@ -82,9 +92,8 @@ dependencies:
82
92
  - !ruby/object:Gem::Version
83
93
  version: "1"
84
94
  version:
85
- description: " ERBook 8.0.0\n\n Write books, manuals, and documents in eRuby\n\n http://snk.tuxfamily.org/lib/erbook/\n\n ERBook is an extensible document processor that emits [1]any\n document you can imagine from [2]eRuby templates, which allow\n scripting and dynamic content generation.\n\n\
86
- Version 8.0.0 (2009-10-10)\n\n This release simplifies [3]node definitions, adds [4]Table\n nodes for building tables the HTML way, and introduces\n [5]Arbitrary floats to combat the [6]explosion of\n special-purpose document nodes.\n\n * [7]Incompatible changes\n\n * [8]New features\n\n * [9]Housekeeping\n\n Incompatible changes\n\n * Reduce and rename [10]node definitions attributes:\n + toc: true -> index: tree\n + lof: true -> index: list\n + index: true -> number: section\n + number: true -> number: ordinal\n + depth: true -> (removed)\n + bypass: true -> (removed)\n\n * Rename [11]The ERBook::Document::Node class properties to\n be more self-documenting:\n + args -> arguments\n + defn -> definition\n + trace -> backtrace\n + index -> section_number\n + number -> ordinal_number\n\n * Replace formal blocks (figure, table, example, equation,\n procedure) with [12]Arbitrary floats.\n\n * Append an exclamation mark (!) to the names of\n [13]Admonition nodes, thereby making them a special case\n of [14]Arbitrary floats.\n\n New features\n\n * Add \"params\" attribute to [15]node definitions.\n\n * Add [16]Table nodes for building tables the HTML way.\n\n Housekeeping\n\n * Use YAML hash merging to DRY node definitions in XHTML\n format.\n\n * Use [17]Table nodes instead of PHP Markdown Extra table\n syntax in the user manual.\n\n * Remove the \"digest\" [18]Node definition attribute from\n the user manual. Its use was discontinued a few major\n versions ago.\n\n\
87
- References\n\n 1. http://snk.tuxfamily.org/lib/erbook/#HelloWorld\n 2. http://en.wikipedia.org/wiki/ERuby\n 3. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 4. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 5. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 6. http://www.docbook.org/tdg/en/html/part2.html\n 7. http://snk.tuxfamily.org/lib/erbook/#Incompatible-changes\n 8. http://snk.tuxfamily.org/lib/erbook/#New-features\n 9. http://snk.tuxfamily.org/lib/erbook/#Housekeeping\n 10. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 11. http://snk.tuxfamily.org/lib/erbook/#Node-class\n 12. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 13. http://snk.tuxfamily.org/lib/erbook/#Admonition-nodes\n 14. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 15. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 16. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 17. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 18. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n"
95
+ description: " Version 9.0.0 (2009-10-18)\n\n This release adds new nodes to the XHTML format, reduces the\n size of generated XHTML documents and also improves their\n usability and validity.\n\n * [1]Incompatible changes\n\n * [2]New features\n\n * [3]Bug fixes\n\n * [4]Housekeeping\n\n Incompatible changes\n\n * The String#to_inline_xhtml method has been removed. Use\n the String#to_xhtml method, which now returns inline\n XHTML, instead.\n\n New features\n\n * Add \"text\" and \"code\" nodes for <pre> and <code>.\n\n * Add \"chain\" parameter to [5]XHTML node definitions.\n\n * Add [6]command! floats for listing shell commands and\n their output.\n\n * Reduce XHTML output size by activating image data URIs at\n runtime using JavaScript. Previously, data URIs were\n emitted into XHTML at compile time.\n\n * Upgrade from XHTML 1.0 Transitional to Strict.\n\n Bug fixes\n\n * Add support for [7]multiple tab rows in jQuery UI tab\n bars.\n\n * Auto-detected mime types were inserted incorrectly in\n base64 embeds.\n\n * Prevent block-level children of <ins> from appearing\n underlined on screen (Opera browsers) and in print\n (Microsoft browsers).\n\n * <blockquote/> icon did not appear in print style.\n\n * Prevent mini navigation menus from colliding.\n\n Housekeeping\n\n * Remove the need for highlighting scroll target by setting\n body height so that any element can be brought to the top\n of the screen via scrolling.\n\n * Place mini navigation menus on jQuery UI tab bars when\n possible.\n\n * Show logo image in full and centered above document\n header.\n\n * Completely remove <p> around block-level child (added by\n Markdown).\n\n * Fix XHTML validation errors on <table>, <tfoot>, <img> in\n RDoc strings, and output of syntax coloring library.\n\n * DRY up XHTML node definitions using YAML hash merging\n operator.\n\n\
96
+ References\n\n 1. http://snk.tuxfamily.org/lib/erbook/#Incompatible-changes\n 2. http://snk.tuxfamily.org/lib/erbook/#New-features\n 3. http://snk.tuxfamily.org/lib/erbook/#Bug-fixes\n 4. http://snk.tuxfamily.org/lib/erbook/#Housekeeping\n 5. http://snk.tuxfamily.org/lib/erbook/#xhtml-nodes\n 6. http://snk.tuxfamily.org/lib/erbook/#xhtml-nodes-command\n 7. http://dev.jqueryui.com/ticket/4882\n"
88
97
  email: sunaku@gmail.com
89
98
  executables:
90
99
  - erbook
@@ -161,6 +170,7 @@ files:
161
170
  - lang/de.yaml
162
171
  - lang/nl.yaml
163
172
  - lang/phrases.yaml
173
+ - test/erbook.rb
164
174
  - lib/erbook/template.rb
165
175
  - lib/erbook/to_xhtml.rb
166
176
  - lib/erbook/document.rb