Closed dlwr closed 2 years ago
Why don't you use hamlit compile invalid-haml-syntax.html.haml | ruby -c
as explained in the issue?
Beacuse hamlit compile invalid-haml-syntax.html.haml
generates valid ruby code and it can't check haml syntax.
bundle exec exe/hamlit compile invalid-haml-syntax.haml
_buf = [];
;
;
; raise Hamlit::HamlSyntaxError.new(%q[Inconsistent indentation: 1 space used for indentation, but the rest of the document was indented using 2 spaces.], 3); _buf = _buf.join("".freeze)
$ bundle exec exe/hamlit compile invalid-haml-syntax.haml | ruby -c
Syntax OK
Oh, you're right. But just eval
-ing the compiled code (without BEGIN {return nil};
prepended) doesn't sound like a good idea. It's not what haml -c
does, either.
The root cause is here https://github.com/k0kubun/hamlit/blob/8ef1d85c9a55a3866dbc47169dc4df35d40dd9d9/lib/hamlit/parser.rb#L37-L38 Could you consider updating your patch with the following direction?
Hamlit::Engine
hamlit compile -c
is usedHamlit::Parser
instead of returning the exception.Let's continue with direction of https://github.com/k0kubun/hamlit/pull/188#issuecomment-1028590147 in https://github.com/k0kubun/hamlit/pull/189
(This PR would be related to https://github.com/k0kubun/hamlit/issues/166) Hi, I faced problem that
hamlit compile -c
missing syntax error of haml like below.So, I tried to solve this problem by adding full_check option
-C
to check haml syntax in this PR.I would be greateful to hear about any ideas or suggestions.