We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
|
html2haml does not treat | well when it appears as the last character of an element.
Let's say I have the following html.
<span>|</span>
It is converted to
%span |
in haml, which is rendered back to
<span></span>
in html. As you can see, the | is missing because it at the end of line is treated as a line separator.
One solution is to print the following as a haml:
Using ruby works, too.
%span= "|"
But don't know if converting a plain text to ruby is a good thing to do.
I had this case when I was to print links in a loop, with | as separator(Just imagine a category sub-header like "Ruby | Haml" for an article ).
It might be the case that I can avoid the problem by the way I write html, but it would be nice if conversion works for any html.
I am guessing that https://github.com/haml/html2haml/blob/master/lib/html2haml/html.rb#L389 (where it checks if text can be in the same line as a parent element) would be a good place to check |;(Code and and after is what I added)
and
if !child.to_s.include?("\n") and !uninterp(child.to_s).end_with?(Haml::Parser::MULTILINE_CHAR_VALUE)
It passed the tests, and works fine with my case.
If that looks OK, I would write a pull request, or someone can integrate this. If not, any suggestion, comment, advice, or fix would be appreciated.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
html2haml does not treat
|
well when it appears as the last character of an element.Problem
Let's say I have the following html.
It is converted to
%span |
in haml, which is rendered back to
in html. As you can see, the
|
is missing because it at the end of line is treated as a line separator.Solution
One solution is to print the following as a haml:
%span |
Using ruby works, too.
But don't know if converting a plain text to ruby is a good thing to do.
When this happens?
I had this case when I was to print links in a loop, with
|
as separator(Just imagine a category sub-header like "Ruby | Haml" for an article ).It might be the case that I can avoid the problem by the way I write html, but it would be nice if conversion works for any html.
So what I want?
I am guessing that https://github.com/haml/html2haml/blob/master/lib/html2haml/html.rb#L389 (where it checks if text can be in the same line as a parent element) would be a good place to check
|
;(Codeand
and after is what I added)It passed the tests, and works fine with my case.
If that looks OK, I would write a pull request, or someone can integrate this.
If not, any suggestion, comment, advice, or fix would be appreciated.
The text was updated successfully, but these errors were encountered: