hamlit 0.6.0 → 0.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3179fc842accfe9d500d85b4ab45abccd47cb1eb
4
- data.tar.gz: 38eb7023728651efbd6d741b8d3de821e5dfc782
3
+ metadata.gz: 9c08c9aec751d231ce8bfa1c8a2f47ee8f7d3be0
4
+ data.tar.gz: 479dc3dac50ba716b8a77a78b52e334a8d670b9e
5
5
  SHA512:
6
- metadata.gz: 74173d10d57f2419290f473b9b8a419a5f1cee0e371008bcbc1a7c18862796f7ecd18d0ce0bff63c2b44cf63f7f2e8c3be3e7c63919a97cfd061474a20ad0788
7
- data.tar.gz: adfacd5b5d7625d66741e9fee4fa5ce3206a490cd91915406ebc758f47c53fe6732ef8bca5e23ca5a74846da9272565067351dba85f9c7d10a64de398c3ef3a5
6
+ metadata.gz: 068959a68a071911879281fbe37e5d7b8c5feca7b8b7e4529396dcc71f99d2e127b3d4f600dc5b5edcd0ed244033976e20216f8dea58fdbe45a63a2404e6ac1a
7
+ data.tar.gz: a9680ba6c4321d62f48edaf7deb83e7c90e1d2ca53e0de234440abd85c5dd0ccc3011f31d4e636d651c4accf02b01eb30a99034640a2599789bc3a16a294100c
@@ -1,3 +1,8 @@
1
+ ## v0.6.1
2
+
3
+ - Bugfix of line numbers for better error backtrace
4
+ - https://github.com/k0kubun/hamlit/pull/19
5
+
1
6
  ## v0.6.0
2
7
 
3
8
  - Automatically escape html in all situations
data/README.md CHANGED
@@ -41,7 +41,7 @@ so it is able to parse such an attribute.
41
41
  ### Passing haml-spec
42
42
 
43
43
  [haml/haml-spec](https://github.com/haml/haml-spec) is a basic suite of tests for Haml interpreters.
44
- For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly mode only, which is used on production).
44
+ For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly and escape\_html mode only, which is used on production).
45
45
 
46
46
  Hamlit is used on [githubranking.com](http://githubranking.com/).
47
47
 
@@ -55,7 +55,7 @@ module Hamlit
55
55
  width = next_width
56
56
  if width != @current_indent * 2
57
57
  if width != Hamlit::EOF && (width > @current_indent * 2 || width.odd?)
58
- ast << [:multi, [:newline], [:newline]]
58
+ ast << [:newline]
59
59
  ast << syntax_error(
60
60
  "inconsistent indentation: #{2 * @current_indent} spaces used for indentation, "\
61
61
  "but the rest of the document was indented using #{width} spaces"
@@ -69,8 +69,9 @@ module Hamlit
69
69
  if @outer_removal.include?(@current_indent) && ast.last == [:static, "\n"]
70
70
  ast.delete_at(-1)
71
71
  end
72
+ ast << [:newline] if @current_indent > 0
72
73
  ast << node
73
- ast << [:newline]
74
+ ast << [:newline] if @current_indent == 0
74
75
  ast << [:static, "\n"] unless skip_newline?(node)
75
76
  end
76
77
  ast
@@ -1,3 +1,3 @@
1
1
  module Hamlit
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -16,4 +16,43 @@ describe Hamlit::Engine do
16
16
  )
17
17
  end
18
18
  end
19
+
20
+ describe '#call' do
21
+ let(:haml) do
22
+ <<-HAML.unindent
23
+ !!! html
24
+
25
+ %html
26
+ %head
27
+ %title Simple Haml
28
+ %body
29
+ %h1= 'header'
30
+ - unless false
31
+ %ul
32
+ - for i in [1, 2, 3]
33
+ - if i
34
+ %li
35
+ %strong= 'hello'
36
+ - else
37
+ %li
38
+ %a{:href => i}= i
39
+ - else
40
+ %p last line
41
+ HAML
42
+ end
43
+ let(:engine) { described_class.new }
44
+
45
+ it 'generates code with the same lineno as a template' do
46
+ lines = engine.call(haml).split("\n")
47
+ expect(lines[0]).to include('DOCTYPE')
48
+ expect(lines[6]).to include('header')
49
+ expect(lines[7]).to include('unless')
50
+ expect(lines[9]).to include('for i in')
51
+ expect(lines[10]).to include('if i')
52
+ expect(lines[12]).to include('hello')
53
+ expect(lines[13]).to include('else')
54
+ expect(lines[16]).to include('else')
55
+ expect(lines[17]).to include('last line')
56
+ end
57
+ end
19
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun