Header: firstname lastname <email> and include problem

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

Header: firstname lastname <email> and include problem

asciidocuser48
I have used asciidoc for some time, but new to asciidoctor, ruby, markdown...  
I'm at this point in the manual: http://asciidoctor.org/docs/user-manual/#author-and-email

I came across a strange situation, the author is missing.

Asciidoctor src:
-----------------------------------------------------------------
= Document Title
FirstName Lastname <email@domain.com>
include::/path/asciidoctor.conf[]

Author: {author}
Author Initials: {authorinitials}
-----------------------------------------------------------------

I get:
-----------------------------------------------------------------
Document Title
- email@domain.com

Author:
Author Initiials: FL
-----------------------------------------------------------------

I tried the other method.
-----------------------------------------------------------------
= Document Title
:author: FirstName Lastname
:email: <email@domain.com>
include::/path/asciidoctor.conf[]

Author: {author}
Author Initials: {authorinitials}
-----------------------------------------------------------------

I get:
-----------------------------------------------------------------
asciidoctor: WARNING: skipping reference to missing attribute: authorinitials

Document Title
- email@domain.com

Author:
Author Initiials: {authorinitials}
-----------------------------------------------------------------

If I put a blank line after the :email:, asciidoctor output for the author is correct, but the include is ignored.

I noticed Asciidoctor is extremely sensitive in the document header. I basically copied my asciidoc file over and made a few changes to attributes, and after many hours, i found out that i cannot have any blank lines in the included file. Comments (//) are okay.

For now, I commented all the ifdef-endif out of the included file because they were being dumped in the output's header section and some ifdef's ended up in the html meta data, and other strangeness.

Glancing over the doc, I really like the experimental UI macros and the :hardbreaks: attribute. The time to convert a document to html5 is super fast.

I'm really missing the ability to define all listing blocks as source so I don't need to add the line  [source].

Ted
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

Ted
It looks like you just need a blank line before your include directive.

see: http://asciidoctor.org/docs/user-manual/#include-partitioning
Note the blank lines before and after the include directives. This practice is recommended whenever including AsciiDoc content to avoid unexpected results.

e.g. Example.adoc

= Rendered with Asciidoctor
Ted Bergeron <ted@example.com>
:icons: font

include::chapter01.adoc[]

== About the Author

You can contact {author} at {email}.
First name:  {firstname} and Last name: {lastname}.
Also supports Middle name: {middlename}.

Author initals: {authorinitials}


- Ted @TedAtCIS
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

asciidocuser48
In reply to this post by asciidocuser48
If I put a blank line between, I get an error: stylesheet does not exist or cannot be read.  
If there is no blank line between, I do not get that error and the html contains the correct stylesheet.

I just swapped the two lines, include and FirstName,  and it worked.

I did have blank lines in the include file (which only contains simple attribute assignments at this time) and got errors. I changed them all to comments (//) and it worked.

I know blank lines are very important to separate blocks, but I didn't think it mattered if it was a list of attributes.




Ted
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

Ted
asciidocuser48 wrote
I know blank lines are very important to separate blocks, but I didn't think it mattered if it was a list of attributes.
The include directive is not an attribute, so it should not be in the document header.

Place the include where ever you want the content to be included. Hopefully this make more sense:

e.g.

= Rendered with Asciidoctor
Ted Bergeron <ted@example.com>
:icons: font


== About the Author

You can contact {author} at {email}.
First name:  {firstname} and Last name: {lastname}.
Also supports Middle name: {middlename}.

Author initals: {authorinitials}

include::chapter01.adoc[]

More content here.

include::chapter02.adoc[]

More content here.
- Ted @TedAtCIS
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

rockyallen
Ted wrote
The include directive is not an attribute, so it should not be in the document header.
I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice?

Ted
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

Ted
rockyallen wrote
I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice?
Since it works, it does seem like a good idea. I totally missed what you and asciidocuser48 were trying to do.

So can you post examples that work?

I wonder if you could put the FirstName Lastname <email@domain.com> in your attributes file and include it, like this?

= Document Title 
include::/path/AllAttributes.txt[] 

Author: {author} 
Author Initials: {authorinitials} 

It seems like as long as it was the first line of the included file it might work?

- Ted @TedAtCIS
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

mojavelinux
Administrator
In reply to this post by rockyallen
> Ted wrote:
> The include directive is not an attribute, so it should not be in the document header.

This is not correct. The include directive can be used anywhere. Of course, what that include contributes to the document is important. You have to think about how the document would be parsed if the include is expanded in place, since that's what happens.

> rockyallen wrote:
> I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice? 

This is a perfectly good practice. In fact, I encourage it.

> asciidocuser48 wrote
I did have blank lines in the include file (which only contains simple attribute assignments at this time) and got errors. I changed them all to comments (//) and it worked.

The document header cannot have any blank lines (which includes lines in an include). The reason is that a blank line is what separates the header from the body. If you define attributes in the body, they only apply to the body. So, for instance, you cannot set the author or stylesheet from the body.


-Dan



On Wed, Jan 31, 2018 at 2:43 PM, rockyallen [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Ted wrote
The include directive is not an attribute, so it should not be in the document header.
I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice?




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Header-firstname-lastname-email-and-include-problem-tp6145p6155.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

mojavelinux
Administrator
In reply to this post by rockyallen
I'm confident that the following document will work correctly as long as asciidoctor.conf has only attribute entries and no blank lines:

= Document Title
FirstName Lastname <[hidden email]>
include::/path/asciidoctor.conf[]

Author: {author}
Author Initials: {authorinitials}

-Dan

On Thu, Feb 1, 2018 at 1:07 PM, Dan Allen <[hidden email]> wrote:
> Ted wrote:
> The include directive is not an attribute, so it should not be in the document header.

This is not correct. The include directive can be used anywhere. Of course, what that include contributes to the document is important. You have to think about how the document would be parsed if the include is expanded in place, since that's what happens.

> rockyallen wrote:
> I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice? 

This is a perfectly good practice. In fact, I encourage it.

> asciidocuser48 wrote
I did have blank lines in the include file (which only contains simple attribute assignments at this time) and got errors. I changed them all to comments (//) and it worked.

The document header cannot have any blank lines (which includes lines in an include). The reason is that a blank line is what separates the header from the body. If you define attributes in the body, they only apply to the body. So, for instance, you cannot set the author or stylesheet from the body.


-Dan



On Wed, Jan 31, 2018 at 2:43 PM, rockyallen [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Ted wrote
The include directive is not an attribute, so it should not be in the document header.
I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice?




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Header-firstname-lastname-email-and-include-problem-tp6145p6155.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Header: firstname lastname <email> and include problem

mojavelinux
Administrator
In reply to this post by rockyallen
Since this issue about blank lines in the header often comes up, I think it's worth thinking about whether we can make the parser more lenient / forgiving. I'll propose some ideas in an issue.

-Dan

On Thu, Feb 1, 2018 at 1:09 PM, Dan Allen <[hidden email]> wrote:
I'm confident that the following document will work correctly as long as asciidoctor.conf has only attribute entries and no blank lines:

= Document Title
FirstName Lastname <[hidden email]>
include::/path/asciidoctor.conf[]

Author: {author}
Author Initials: {authorinitials}

-Dan

On Thu, Feb 1, 2018 at 1:07 PM, Dan Allen <[hidden email]> wrote:
> Ted wrote:
> The include directive is not an attribute, so it should not be in the document header.

This is not correct. The include directive can be used anywhere. Of course, what that include contributes to the document is important. You have to think about how the document would be parsed if the include is expanded in place, since that's what happens.

> rockyallen wrote:
> I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice? 

This is a perfectly good practice. In fact, I encourage it.

> asciidocuser48 wrote
I did have blank lines in the include file (which only contains simple attribute assignments at this time) and got errors. I changed them all to comments (//) and it worked.

The document header cannot have any blank lines (which includes lines in an include). The reason is that a blank line is what separates the header from the body. If you define attributes in the body, they only apply to the body. So, for instance, you cannot set the author or stylesheet from the body.


-Dan



On Wed, Jan 31, 2018 at 2:43 PM, rockyallen [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Ted wrote
The include directive is not an attribute, so it should not be in the document header.
I often group header attributes in an include file like this to enforce a common look across multiple documents, and it works fine. Is this a bad practice?




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Header-firstname-lastname-email-and-include-problem-tp6145p6155.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux