Quantcast

What's the 'right' way to include JavaScript in an ASCIIDoctor document?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com

I imagine I can do it with inlined HTML, but there seems to be a better way; there’s a document attribute I can define, :scriptsdir:… I just can’t figure out how to use it to load an actual .js file.

 

Can someone point me in the right direction?

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

LightGuard
Administrator
You're doing this with awestruct, right? It would be easier to do this inside a layout.


On Tue, Apr 1, 2014 at 1:43 PM, Victor Danilchenko <[hidden email]> wrote:

I imagine I can do it with inlined HTML, but there seems to be a better way; there’s a document attribute I can define, :scriptsdir:… I just can’t figure out how to use it to load an actual .js file.

 

Can someone point me in the right direction?

 




--
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com

Yeah, I considered doing that, but if I use e.g. the base layout, the CSS gets all messed up – the <body> tag doesn’t receive the correct ASCIIDoctor styling, and somesuch. I add the classes into the template of course, but that doesn’t strike me as a good idea in the long-term, fitting a square peg into a round hole.

 

And if I don’t use an explicit layout, then I get the nice default ASCIIDoctor layout, but no good way (that I know of) to include scripts.

 

Is there some sort of hybrid approach, where I can use the default ASCIIDoctor layout, but load script files as well? Or can I at least copy the default ASCIIDoctor layout from somewhere, and customize that to use as my own layout? I have no idea where it is…

 

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Tuesday, April 01, 2014 4:16 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

You're doing this with awestruct, right? It would be easier to do this inside a layout.

 

On Tue, Apr 1, 2014 at 1:43 PM, Victor Danilchenko <[hidden email]> wrote:

I imagine I can do it with inlined HTML, but there seems to be a better way; there’s a document attribute I can define, :scriptsdir:… I just can’t figure out how to use it to load an actual .js file.

 

Can someone point me in the right direction?

 



 

--

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

LightGuard
Administrator
The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.


On Tue, Apr 1, 2014 at 2:38 PM, Victor Danilchenko <[hidden email]> wrote:

Yeah, I considered doing that, but if I use e.g. the base layout, the CSS gets all messed up – the <body> tag doesn’t receive the correct ASCIIDoctor styling, and somesuch. I add the classes into the template of course, but that doesn’t strike me as a good idea in the long-term, fitting a square peg into a round hole.

 

And if I don’t use an explicit layout, then I get the nice default ASCIIDoctor layout, but no good way (that I know of) to include scripts.

 

Is there some sort of hybrid approach, where I can use the default ASCIIDoctor layout, but load script files as well? Or can I at least copy the default ASCIIDoctor layout from somewhere, and customize that to use as my own layout? I have no idea where it is…

 

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Tuesday, April 01, 2014 4:16 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

You're doing this with awestruct, right? It would be easier to do this inside a layout.

 

On Tue, Apr 1, 2014 at 1:43 PM, Victor Danilchenko <[hidden email]> wrote:

I imagine I can do it with inlined HTML, but there seems to be a better way; there’s a document attribute I can define, :scriptsdir:… I just can’t figure out how to use it to load an actual .js file.

 

Can someone point me in the right direction?

 



 

--




--
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com

Thanks, I will look into that!

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 

On Tue, Apr 1, 2014 at 2:38 PM, Victor Danilchenko <[hidden email]> wrote:

Yeah, I considered doing that, but if I use e.g. the base layout, the CSS gets all messed up – the <body> tag doesn’t receive the correct ASCIIDoctor styling, and somesuch. I add the classes into the template of course, but that doesn’t strike me as a good idea in the long-term, fitting a square peg into a round hole.

 

And if I don’t use an explicit layout, then I get the nice default ASCIIDoctor layout, but no good way (that I know of) to include scripts.

 

Is there some sort of hybrid approach, where I can use the default ASCIIDoctor layout, but load script files as well? Or can I at least copy the default ASCIIDoctor layout from somewhere, and customize that to use as my own layout? I have no idea where it is…

 

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Tuesday, April 01, 2014 4:16 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

You're doing this with awestruct, right? It would be easier to do this inside a layout.

 

On Tue, Apr 1, 2014 at 1:43 PM, Victor Danilchenko <[hidden email]> wrote:

I imagine I can do it with inlined HTML, but there seems to be a better way; there’s a document attribute I can define, :scriptsdir:… I just can’t figure out how to use it to load an actual .js file.

 

Can someone point me in the right direction?

 



 

--



 

--

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com
In reply to this post by LightGuard

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com
In reply to this post by LightGuard

Well, I can also include .js files in a pass-through block… not a terrible option, to be sure, but still kludgey.

 

 

From: Victor Danilchenko
Sent: Wednesday, April 02, 2014 9:28 AM
To: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

LightGuard
Administrator
I know Dan is working on catching up on emails, so until he's able to answer with something better, I know the pass through block will work. You could also create a new macro / extension to do it. 

Sent from Mailbox for iPhone


On Wed, Apr 2, 2014 at 7:29 AM, Victor Danilchenko <[hidden email]> wrote:

Well, I can also include .js files in a pass-through block… not a terrible option, to be sure, but still kludgey.

 

 

From: Victor Danilchenko
Sent: Wednesday, April 02, 2014 9:28 AM
To: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

LightGuard
Administrator
Found this: http://asciidoctor.org/docs/user-manual/#docinfo-file

As it's scripts you want to add, you probably should do a docinfo-footer file, but that should help you on your way. 

Sent from Mailbox for iPhone


On Wed, Apr 2, 2014 at 7:52 AM, Jason Porter <[hidden email]> wrote:

I know Dan is working on catching up on emails, so until he's able to answer with something better, I know the pass through block will work. You could also create a new macro / extension to do it. 

Sent from Mailbox for iPhone


On Wed, Apr 2, 2014 at 7:29 AM, Victor Danilchenko <[hidden email]> wrote:

Well, I can also include .js files in a pass-through block… not a terrible option, to be sure, but still kludgey.

 

 

From: Victor Danilchenko
Sent: Wednesday, April 02, 2014 9:28 AM
To: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

vdanilchenko@vistaprint.com

Ah, thanks! I tried that one before, and got it to work, but abandoned it because I needed to be able to let users use their own docinfo – but upon another re-reading I realized that I can combine :docinfo: in a document with :docinfo1: set globally, thus killing two birds with one stone.

 

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Wednesday, April 02, 2014 9:59 AM
To: [hidden email]
Cc: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Found this: http://asciidoctor.org/docs/user-manual/#docinfo-file

 

As it's scripts you want to add, you probably should do a docinfo-footer file, but that should help you on your way. 


Sent from Mailbox for iPhone

 

On Wed, Apr 2, 2014 at 7:52 AM, Jason Porter <[hidden email]> wrote:

I know Dan is working on catching up on emails, so until he's able to answer with something better, I know the pass through block will work. You could also create a new macro / extension to do it. 


Sent from Mailbox for iPhone

 

On Wed, Apr 2, 2014 at 7:29 AM, Victor Danilchenko <[hidden email]> wrote:

Well, I can also include .js files in a pass-through block… not a terrible option, to be sure, but still kludgey.

 

 

From: Victor Danilchenko
Sent: Wednesday, April 02, 2014 9:28 AM
To: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What's the 'right' way to include JavaScript in an ASCIIDoctor document?

mojavelinux
The Asciidoctor Awestruct integration has a special attribute for including additional Javascript files in the page.

You can see an example here:


The `page-javascripts` attribute is the root name of a file in the javascripts directory to add to the head.

Another approach is to edit the layout and add additional scripts if a given attribute is set in the page. You can see an example here:


The `scriptsdir` attribute in Asciidoctor is only for dealing with path resolution for known, internal scripts. Basically, it's not really used atm, kind of a legacy thing for AsciiDoc Python compatibility.

Cheers.

-Dan

On Wed, Apr 2, 2014 at 9:06 AM, Victor Danilchenko <[hidden email]> wrote:

Ah, thanks! I tried that one before, and got it to work, but abandoned it because I needed to be able to let users use their own docinfo – but upon another re-reading I realized that I can combine :docinfo: in a document with :docinfo1: set globally, thus killing two birds with one stone.

 

 

 

From: Jason Porter [mailto:[hidden email]]
Sent: Wednesday, April 02, 2014 9:59 AM
To: [hidden email]
Cc: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Found this: http://asciidoctor.org/docs/user-manual/#docinfo-file

 

As it's scripts you want to add, you probably should do a docinfo-footer file, but that should help you on your way. 


Sent from Mailbox for iPhone

 

On Wed, Apr 2, 2014 at 7:52 AM, Jason Porter <[hidden email]> wrote:

I know Dan is working on catching up on emails, so until he's able to answer with something better, I know the pass through block will work. You could also create a new macro / extension to do it. 


Sent from Mailbox for iPhone

 

On Wed, Apr 2, 2014 at 7:29 AM, Victor Danilchenko <[hidden email]> wrote:

Well, I can also include .js files in a pass-through block… not a terrible option, to be sure, but still kludgey.

 

 

From: Victor Danilchenko
Sent: Wednesday, April 02, 2014 9:28 AM
To: [hidden email]
Subject: RE: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

Hmmm. So I was running out the door yesterday, but I checked out your links, and that’s just CSS theming, which I already use (I ended up including custom .css file which in turn includes a theme-generated .css file). However, that’s just CSS – not JS resources.

 

What baffles me is that there is :scriptsdir: attribute – but what does it mean, how is it used? There’s a similar-looking :imagesdir: attribute, and to it corresponds the ability to say in the .adoc file:

 

image::MyImage.png[MyImage, 480, 270]

 

But I could find nothing comparable to make use of the :scriptsdir: attribute. Why does it exist at all? What does it do? It SEEMS as if there would be some way to use it to include .js files, but I couldn’t find anything like that.

 

At the moment, it looks like my best bet is to fit a square peg into the round hole, and force a manually modified layout to behave like an ASCIIDoctor document (e.g. by manually adding the CSS classes which would typically be added by ASCIIDoctor based on document attributes). I see no way to either use the built-in ASCIIDoctor layout and just add JS resources, or to clone or subclass the built-in ASCIIDoctor layout and tweak it slightly – that layout seems to be hard-wired into ASCIIDoctor, and not available as a separate resources.

 

Is there not a better way?

 

 

From: Jason Porter [[hidden email]]
Sent: Tuesday, April 01, 2014 4:49 PM
To: [hidden email]
Subject: Re: [awestruct] What's the 'right' way to include JavaScript in an ASCIIDoctor document?

 

The default Asciidoctor layout is all done in a CSS file (or in a style tag if you're embedding everything into the document). You may find others you like at http://themes.asciidoctor.org/preview/. Also be sure to check out http://discuss.asciidoctor.org/Can-I-get-asciidoctor-s-default-styling-stylesheet-td940.html for a little more detail.

 

 

 




--
Loading...