Created
April 23, 2010 02:18
-
-
Save freshtonic/376081 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%p | |
Blah blah blah blah | |
%a(href='#foo') foo | |
and | |
%a(href='#bar') bar | |
\. | |
-# The problem with the above Haml fragment is that I am left with a space after <a href='#bar'>bar</a> and before the period. | |
-# Haml's whitespace removal does not resolve the issue, because it can either remove ALL whitespace | |
-# around an element or ALL whitespace within an element. Neither option seems to fit the bill. | |
-# AFAIK from reading the docs, you can't put whitespace removal around the text node either. | |
-# What's the (preferably clean) solution? | |
%p | |
Blah blah blah blah | |
%a(href='#foo') foo | |
and | |
<a href='#bar'>bar</a>. | |
-# works around the issue. |
%p
Blah blah blah blah
%a(href='#foo') foo
and
bar.
-# the above works around the issue
crazy
There are a couple ways to do this. One is to use the succeed helper:
%p
= succeed '.' do
Blah blah blah blah
%a(href='#foo') foo
and
%a(href='#bar') bar
The other (which I prefer) is to use another markup syntax for content (as opposed to Haml for document structure). See http://chriseppstein.github.com/blog/2010/02/08/haml-sucks-for-content/. Here's an example using Textile, but you could do something similar with Markdown:
:textile
Blah blah blah blah "foo":#foo and "bar":#bar.
@jeremyw oh rad, thanks for the heads up!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text node being the period at the end.
Everything would work beautifully if Haml if I could say 'remove white space before/after the node' instead of 'inside/surrounding the node'. And it would be even awesomer if text nodes supported the > and < operators.