nanoc3 3.1.5 → 3.1.6

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/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.1.6 (2010-11-21)
4
+
5
+ * Fixed issues with incompatible encodings
6
+
3
7
  ## 3.1.5 (2010-08-24)
4
8
 
5
9
  * Improved `#render` documentation
@@ -229,14 +229,14 @@ module Nanoc3::DataSources
229
229
  def parse(content_filename, meta_filename, kind)
230
230
  # Read content and metadata from separate files
231
231
  if meta_filename
232
- content = content_filename ? File.read(content_filename) : ''
233
- meta = YAML.load_file(meta_filename) || {}
232
+ content = content_filename ? read(content_filename) : ''
233
+ meta = YAML.load(read(meta_filename)) || {}
234
234
 
235
235
  return [ meta, content ]
236
236
  end
237
237
 
238
238
  # Read data
239
- data = File.read(content_filename)
239
+ data = read(content_filename)
240
240
 
241
241
  # Check presence of metadata section
242
242
  if data !~ /\A-{3,5}\s*$/
@@ -259,6 +259,20 @@ module Nanoc3::DataSources
259
259
  [ meta, content ]
260
260
  end
261
261
 
262
+ # Reads the content of the file with the given name and returns a string
263
+ # in UTF-8 encoding. The original encoding of the string is derived from
264
+ # the default external encoding, but this can be overridden by the
265
+ # “encoding” configuration attribute in the data source configuration.
266
+ def read(filename)
267
+ data = File.read(filename)
268
+ if data.respond_to?(:encode)
269
+ data.force_encoding(@config[:encoding]) if @config && @config[:encoding]
270
+ data.encode('UTF-8')
271
+ else
272
+ data
273
+ end
274
+ end
275
+
262
276
  end
263
277
 
264
278
  end
@@ -14,10 +14,10 @@ module Nanoc3::DataSources
14
14
  # itself can start with a metadata section: it can be stored at the top of
15
15
  # the file, between `---` (three dashes) separators. For example:
16
16
  #
17
- # ---
18
- # title: "Moo!"
19
- # ---
20
- # h1. Hello!
17
+ # ---
18
+ # title: "Moo!"
19
+ # ---
20
+ # h1. Hello!
21
21
  #
22
22
  # The metadata section can be omitted. If the file does not start with
23
23
  # three or five dashes, the entire file will be considered as content.
@@ -26,7 +26,7 @@ module Nanoc3::DataSources
26
26
  # an `index.*` filename, such as `index.txt`, will have the filesystem path
27
27
  # with the `index.*` part stripped as a identifier. For example:
28
28
  #
29
- # foo/bar/index.html → /foo/bar/
29
+ # foo/bar/index.html → /foo/bar/
30
30
  #
31
31
  # In other cases, the identifier is calculated by stripping the extension.
32
32
  # If the `allow_periods_in_identifiers` attribute in the configuration is
@@ -34,24 +34,24 @@ module Nanoc3::DataSources
34
34
  # extensions; if it is false or unset, all extensions will be stripped.
35
35
  # For example:
36
36
  #
37
- # (`allow_periods_in_identifiers` set to true)
38
- # foo.entry.html → /foo.entry/
39
- #
40
- # (`allow_periods_in_identifiers` set to false)
41
- # foo.html.erb → /foo/
37
+ # (`allow_periods_in_identifiers` set to true)
38
+ # foo.entry.html → /foo.entry/
39
+ #
40
+ # (`allow_periods_in_identifiers` set to false)
41
+ # foo.html.erb → /foo/
42
42
  #
43
43
  # Note that it is possible for two different, separate files to have the
44
44
  # same identifier. It is recommended to avoid such situations.
45
45
  #
46
46
  # Some more examples:
47
47
  #
48
- # content/index.html → /
49
- # content/foo.html → /foo/
50
- # content/foo/index.html → /foo/
51
- # content/foo/bar.html → /foo/bar/
52
- # content/foo/bar.baz.html → /foo/bar/ OR /foo/bar.baz/
53
- # content/foo/bar/index.html → /foo/bar/
54
- # content/foo.bar/index.html → /foo.bar/
48
+ # content/index.html → /
49
+ # content/foo.html → /foo/
50
+ # content/foo/index.html → /foo/
51
+ # content/foo/bar.html → /foo/bar/
52
+ # content/foo/bar.baz.html → /foo/bar/ OR /foo/bar.baz/
53
+ # content/foo/bar/index.html → /foo/bar/
54
+ # content/foo.bar/index.html → /foo.bar/
55
55
  #
56
56
  # The file extension does not determine the filters to run on items; the
57
57
  # Rules file is used to specify processing instructors for each item.
@@ -63,7 +63,7 @@ module Nanoc3::Filters
63
63
  element.inner_html = highlighted_code
64
64
  end
65
65
 
66
- doc.to_s
66
+ doc.to_html(:encoding => 'UTF-8')
67
67
  end
68
68
 
69
69
  private
data/lib/nanoc3.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.1.5'
6
+ VERSION = '3.1.6'
7
7
 
8
8
  end
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 5
10
- version: 3.1.5
9
+ - 6
10
+ version: 3.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Denis Defreyne
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-24 00:00:00 +02:00
18
+ date: 2010-11-21 00:00:00 +01:00
19
19
  default_executable: nanoc3
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency