Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symbols near HAML expressions

Tags:

haml

In HAML I often want to use a tag with punctuation following immediately after the tag. For example, I might want to put something in bold but have a closing bracket. The formatting would look like this: (Example sentence with bold text.)

Note that the 'bold text' is in bold but the period and closing bracket '.)' are not.

The obvious HAML is like this:

(Example sentence with
%span.important bold text
\.)

but this causes an extra space between 'bold text' and '.)'. Here's one way of doing it instead:

(Example sentence with
%span.important bold text
%span>\.)

Where enclosing the '.)' in a span with > makes the space disappear. However, this requires an unnecessary span.

Is there any way of getting the desired output, without the extra span?

like image 235
Peter Avatar asked May 25 '11 01:05

Peter


1 Answers

That initial code snippet shouldn't work in HAML at all:

(Example sentence with
%b bold text
.)

The third line would result in an Illegal element: classes and ids must have values error. It should be:

(Example sentence with
%b bold text
\.)

However, that just fixes the code error. It still displays the way you're complaining about. I only know of two ways to address it:

  1. Just use inline HTML tags in your HAML file: (Example sentence with <b>bold text</b>.)
  2. Install maruku (or another markdown gem) and do the following:
:markdown  
  (Example sentence with **bold text**.)
like image 81
D. Simpson Avatar answered Oct 24 '22 03:10

D. Simpson