Getting blank lines in AsciiDoc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting blank lines in AsciiDoc

paulrayner
How do I do blank lines in AsciiDoc so that they will come out correctly in Asciidoctor HTML rendering?


A plus character preceded by at least one space character at the end of a non-blank line forces a line break. It generates a line break (br) tag for HTML outputs and a custom XML asciidoc-br processing instruction for DocBook outputs. The asciidoc-br processing instruction is handled bya2x(1).

With AsciiDoc of:

 +

I get:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+</pre>
  </div>
</div>

I tried doing a verse paragraph style, with lines consisting of a space and plus sign per http://comments.gmane.org/gmane.text.formats.asciidoc/224:

[verse]
 +
 +


But I get HTML that looks like the following from Asciidoctor:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+
+</pre>
  </div>
</div>

Am I missing something here?

Thanks,
Paul.
Reply | Threaded
Open this post in threaded view
|

Re: Getting blank lines in AsciiDoc

mojavelinux
Administrator
Paul,

As always, there are a couple of ways to skin this cat (or shave this yak, whichever metaphor you prefer).

First, I'll explain why you see the output you see.

While it's true that a space followed by a plus at the end of the line marks a hard line break, that gets superseded by the rule that a space at the beginning of creates a literal paragraph. Literal paragraphs and blocks don't get the hard line break substitution, so that explains why the + remains in the output.

In the case of the verse, you get plus characters in the output because a verse is also treated as literal text and therefore doesn't get hard line break substitutions either (since the text is already displayed as preformatted).

Attributes to the rescue!

This is a prime example of when you would use attributes as fillers. There are a couple of attributes that apply here.

You could use a non-breaking space to start the line:

{nbsp} +
{nbsp} +

or a regular space:

{sp} +
{sp} +

The only downside in these cases is that you get a physical space in the output (that is selectable via a mouse). Instead, you can use a zero-width space:

{zwsp} +
{zwsp} +

That will give you the following output:

<div class="paragraph"><p>&#8203;<br>
&#8203;<br></p></div>

But the best solution is no space at all. For that, there's the empty attribute:

{empty} +
{empty} +

That gives you exactly the output you want:

<div class="paragraph"><p><br>
<br></p></div>

If you want to make this more semantic you can define an attribute as an alias for this line:

:blank: {empty} +
:blank: {empty} +

Now you can type:

{blank}
{blank}

Voila!. You get the same output.

(Btw, blank would be a nice built-in attribute to have, don't you think?).

For completeness, I'll mention the solution w/ verse:

If you want to use the verse block, you can use the zero-width space by itself:

[verse]
{zwsp}
{zwsp}

That will give you the output:

<div class="verseblock">
<pre class="content">&#8203;
&#8203;</pre>
<div class="attribution">
</div></div>

I like the first option better of using {blank} in the context of a normal paragraph.

There may be other solutions, but that should get you started!

-Dan

On Fri, Mar 15, 2013 at 11:16 AM, paulrayner [via Asciidoctor :: Discussion] <[hidden email]> wrote:
How do I do blank lines in AsciiDoc so that they will come out correctly in Asciidoctor HTML rendering?


A plus character preceded by at least one space character at the end of a non-blank line forces a line break. It generates a line break (br) tag for HTML outputs and a custom XML asciidoc-br processing instruction for DocBook outputs. The asciidoc-br processing instruction is handled bya2x(1).

With AsciiDoc of:

 +

I get:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+</pre>
  </div>
</div>

I tried doing a verse paragraph style, with lines consisting of a space and plus sign per http://comments.gmane.org/gmane.text.formats.asciidoc/224:

[verse]
 +
 +


But I get HTML that looks like the following from Asciidoctor:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+
+</pre>
  </div>
</div>

Am I missing something here?

Thanks,
Paul.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Getting-blank-lines-in-AsciiDoc-tp47.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

Reply | Threaded
Open this post in threaded view
|

Re: Getting blank lines in AsciiDoc

mojavelinux
Administrator
In reply to this post by paulrayner
I'll turn this into a wiki page.

-Dan

On Fri, Mar 15, 2013 at 12:56 PM, Dan Allen <[hidden email]> wrote:
Paul,

As always, there are a couple of ways to skin this cat (or shave this yak, whichever metaphor you prefer).

First, I'll explain why you see the output you see.

While it's true that a space followed by a plus at the end of the line marks a hard line break, that gets superseded by the rule that a space at the beginning of creates a literal paragraph. Literal paragraphs and blocks don't get the hard line break substitution, so that explains why the + remains in the output.

In the case of the verse, you get plus characters in the output because a verse is also treated as literal text and therefore doesn't get hard line break substitutions either (since the text is already displayed as preformatted).

Attributes to the rescue!

This is a prime example of when you would use attributes as fillers. There are a couple of attributes that apply here.

You could use a non-breaking space to start the line:

{nbsp} +
{nbsp} +

or a regular space:

{sp} +
{sp} +

The only downside in these cases is that you get a physical space in the output (that is selectable via a mouse). Instead, you can use a zero-width space:

{zwsp} +
{zwsp} +

That will give you the following output:

<div class="paragraph"><p>&#8203;<br>
&#8203;<br></p></div>

But the best solution is no space at all. For that, there's the empty attribute:

{empty} +
{empty} +

That gives you exactly the output you want:

<div class="paragraph"><p><br>
<br></p></div>

If you want to make this more semantic you can define an attribute as an alias for this line:

:blank: {empty} +
:blank: {empty} +

Now you can type:

{blank}
{blank}

Voila!. You get the same output.

(Btw, blank would be a nice built-in attribute to have, don't you think?).

For completeness, I'll mention the solution w/ verse:

If you want to use the verse block, you can use the zero-width space by itself:

[verse]
{zwsp}
{zwsp}

That will give you the output:

<div class="verseblock">
<pre class="content">&#8203;
&#8203;</pre>
<div class="attribution">
</div></div>

I like the first option better of using {blank} in the context of a normal paragraph.

There may be other solutions, but that should get you started!

-Dan

On Fri, Mar 15, 2013 at 11:16 AM, paulrayner [via Asciidoctor :: Discussion] <[hidden email]> wrote:
How do I do blank lines in AsciiDoc so that they will come out correctly in Asciidoctor HTML rendering?


A plus character preceded by at least one space character at the end of a non-blank line forces a line break. It generates a line break (br) tag for HTML outputs and a custom XML asciidoc-br processing instruction for DocBook outputs. The asciidoc-br processing instruction is handled bya2x(1).

With AsciiDoc of:

 +

I get:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+</pre>
  </div>
</div>

I tried doing a verse paragraph style, with lines consisting of a space and plus sign per http://comments.gmane.org/gmane.text.formats.asciidoc/224:

[verse]
 +
 +


But I get HTML that looks like the following from Asciidoctor:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+
+</pre>
  </div>
</div>

Am I missing something here?

Thanks,
Paul.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Getting-blank-lines-in-AsciiDoc-tp47.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597




--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

Reply | Threaded
Open this post in threaded view
|

Re: Getting blank lines in AsciiDoc

mojavelinux
Administrator
In reply to this post by paulrayner
https://github.com/asciidoctor/asciidoctor/wiki/How-to-insert-sequential-blank-lines

On Fri, Mar 15, 2013 at 12:57 PM, Dan Allen <[hidden email]> wrote:
I'll turn this into a wiki page.

-Dan


On Fri, Mar 15, 2013 at 12:56 PM, Dan Allen <[hidden email]> wrote:
Paul,

As always, there are a couple of ways to skin this cat (or shave this yak, whichever metaphor you prefer).

First, I'll explain why you see the output you see.

While it's true that a space followed by a plus at the end of the line marks a hard line break, that gets superseded by the rule that a space at the beginning of creates a literal paragraph. Literal paragraphs and blocks don't get the hard line break substitution, so that explains why the + remains in the output.

In the case of the verse, you get plus characters in the output because a verse is also treated as literal text and therefore doesn't get hard line break substitutions either (since the text is already displayed as preformatted).

Attributes to the rescue!

This is a prime example of when you would use attributes as fillers. There are a couple of attributes that apply here.

You could use a non-breaking space to start the line:

{nbsp} +
{nbsp} +

or a regular space:

{sp} +
{sp} +

The only downside in these cases is that you get a physical space in the output (that is selectable via a mouse). Instead, you can use a zero-width space:

{zwsp} +
{zwsp} +

That will give you the following output:

<div class="paragraph"><p>&#8203;<br>
&#8203;<br></p></div>

But the best solution is no space at all. For that, there's the empty attribute:

{empty} +
{empty} +

That gives you exactly the output you want:

<div class="paragraph"><p><br>
<br></p></div>

If you want to make this more semantic you can define an attribute as an alias for this line:

:blank: {empty} +
:blank: {empty} +

Now you can type:

{blank}
{blank}

Voila!. You get the same output.

(Btw, blank would be a nice built-in attribute to have, don't you think?).

For completeness, I'll mention the solution w/ verse:

If you want to use the verse block, you can use the zero-width space by itself:

[verse]
{zwsp}
{zwsp}

That will give you the output:

<div class="verseblock">
<pre class="content">&#8203;
&#8203;</pre>
<div class="attribution">
</div></div>

I like the first option better of using {blank} in the context of a normal paragraph.

There may be other solutions, but that should get you started!

-Dan

On Fri, Mar 15, 2013 at 11:16 AM, paulrayner [via Asciidoctor :: Discussion] <[hidden email]> wrote:
How do I do blank lines in AsciiDoc so that they will come out correctly in Asciidoctor HTML rendering?


A plus character preceded by at least one space character at the end of a non-blank line forces a line break. It generates a line break (br) tag for HTML outputs and a custom XML asciidoc-br processing instruction for DocBook outputs. The asciidoc-br processing instruction is handled bya2x(1).

With AsciiDoc of:

 +

I get:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+</pre>
  </div>
</div>

I tried doing a verse paragraph style, with lines consisting of a space and plus sign per http://comments.gmane.org/gmane.text.formats.asciidoc/224:

[verse]
 +
 +


But I get HTML that looks like the following from Asciidoctor:

<div class="literalblock">
  
  <div class="content monospaced">
    <pre>+
+</pre>
  </div>
</div>

Am I missing something here?

Thanks,
Paul.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Getting-blank-lines-in-AsciiDoc-tp47.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597




--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597




--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597