I'm using asciidoctor-maven-plugin to convert .adoc files to html file...
Would want to include a link to javascript in the generated html file...
Basically would like to see something like below in the html file that is generated from the .adoc file
<script src="custom.js"></script>
Tried setting attributes like linkcss scriptsdir etc..but of no luck...
Any help?
One way is like in
http://mrhaki.blogspot.ie/2014/06/awesome-asciidoc-include-raw-html.html
But then have to add it in every .adoc file...is there a way to get it automatically added just like the CSS (using stylesheet)
Use docinfo files, see the documentation for more detail.
You create docinfo files by adding another file named <doc_file_name>-docinfo.html for HTML generation or <doc_file_name>-docinfo.xml for docbook generation. The contents of the docinfo file are copied into the generated output, in the head section for html. If you want to add things to the bottom of the document there are footer docinfo files for that. It follows the same as a normal docinfo but the file name is <doc_file_name>-docinfo-footer.html or <doc_file_name>-docinfo-footer.xml
Happy docing :) Let me, or preferably the list know of any other maven issues you find.
You can use the passthrough block for that using ++++:
++++
<p>
Content in a passthrough block is passed to the output unprocessed.
That means you can include raw HTML, like this embedded Gist:
</p>
<script src="http://gist.github.com/mojavelinux/5333524.js">
</script>
++++
Source: http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#more-delimited-blocks
Related
I have created 3 different html, css and javascript files but I am now confuse how can I interlink them and upload as a single file
Looks like you're just getting introduced to web development, these might come in handy for finding out how to bring your HTML, JS and CSS files together:
(Link JS File) - https://www.w3schools.com/tags/att_script_src.asp
(Link CSS file) - https://www.w3schools.com/tags/tag_link.asp
https://www.w3schools.com/
In order to make your codes to be run by browser you need to include all your sources in one .html file. You need to link those files inside this file and there are different requirement of each file extensions to be included.
In order to link CSS file you use link element with src attribute to indicate the source of your file. Another attribute rel defines the relationship between a linked resource and the current document. In here it is stylesheet document and need to get this value.
Sample: <link rel="stylesheet" href="styles.css">
In order to link your JS file, you need to use element which is used to define a client-side script (JavaScript). You may add it internally or externally. According to your question you need to add it externally. First, add your script element and then refer to it using the src attribute in the script tag.
Sample: <script src="myJSFile.js">
Resources for learning more in these topics:
https://www.w3schools.com/tags/tag_link.asp
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
https://www.w3schools.com/tags/att_script_src.asp
To inter-link different HTML files together, you can just use Hyperlink, Hyperlinking is a feature of HTML to link multiple documents (HTML) files together. It'll show up as a button on your HTML.
Here's an example of how you can implement it. href="your-path-to-your-html"
Click here to visit school
Click here to visit inventory
Click here to visit battle
To understand more about hyperlinking, you can read this for better examples: https://www.w3schools.com/htmL/html_links.asp
I have js file and if I put <script src="link_to_file"></script> on bottom of my html page, it doesn't work.
Instead, if I put <script>function( etc..</script> on bottom of my html page, it works.
What is problem?
Try this:
HTML
bottom
<script src="external-script.js><script>
EXTERNAL JS
Add $(document).ready(function () {})
Make sure jQuery is loaded first.
Check your global variables.
Make sure that you're using the right path, that's depending om your folder structure. For example, if the js file is in the same folder as your html file, use
<script src = 'fileName.js'></script>
Do not forget to include the .js extension at the end of the file name. The file name should be same as the name of your js file.
Anyhow, you do not have to put the script in the head section as someone has suggested. It's in fact, not a good practice.
I have a csv file containing co-ordinates. I want to know all the elements which were there at that co-ordinate. I know about the function :
document.elementFromPoint(co-ordX,co-ordY)
which returns the element at the postion. One possible solution I know about is manually coping this into the HTML source. Is there a way to automate this (copying the script into the HTML source and then opening the HTML file in the browser) since I have a number of HTML files and this needs to be done for all of them?
This question seems to be how do I add the same JS to a bunch of html files.
The simple solution is to put your code in a file called track.js and the use a decent code editor to do multi-file search and replace. I would suggest using sublime text 2 for this. Open the folder with you files and then replace
</head>
With
<script src="track.js"></script></head>
I'm totally new at coding and i have some trouble using the dragNodes plugin. I can make the plugin work by itself with the generated random graph example, but I am struggling to make it work with my own graph.
I don't understand what to put in the html. I tried to put only that:
`<script src="sigma.js/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js"></script>sigma.plugins.dragNodes(s, s.renderers[0]);`
and it doesn't make my nodes move. I think I have to change the content of "s" and "s.renderers[0]" but I cannot find where., and I don't know how to do it...
Basically, I would love if anyone could give me some explanations about how to plug a plugin in my page?
If you could help me, I'm lost and that would be awesome! Thank you a lot!
I think you are mixing up two things:
How to use script into html
How to include external js files in a web page.
In order to insert javascript directly into an html page you have to use the script tag as follow (called inline js):
<body>
<script>
// some inline js
var a = 1;
</script>
</body>
In order to include js from an external file you have to reference the file with the src attribute just like you did.
<script src="sigma.js/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js"></script>
The only thing that you missed is that sigma.plugins.dragNodes(s, s.renderers[0]); is also some js code, you thus have to put it into script tags to that it can be interpreted as such by the browser.
Here is what you probably are trying to write:
<script src="sigma.js/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js">
</script>
<script>
sigma.plugins.dragNodes(s, s.renderers[0]);
</script>
Having all this into <body>tags.
I should also mention that to render your graph using sigma you should have an instance of sigma in your page, and in your case it should be called s.
To learn more about js/web programming I would advise this: http://www.codecademy.com/
As far as documentation for sigma is concerned check out their tutorial: http://sigmajs.org/
In addition to Nicolas Joseph's answer (put javascript in script tag), you should also download the js library that is required and save the html file in the appropriate path.
For example if your file.html is in a directory dir (dir/file/.html)
Then the command:
<script src="sigma.js/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js">
</script>
will search for a file named sigma.plugins.dragNodes.js in the following path:
dir/sigma.js/plugins/sigma.plugins.dragNodes/sigma.plugins.dragNodes.js
To check out which librarires you are missing you should open debug mode in your browser (right click->inspect element) and check the console tab.
Cheers
I am new to CakePhp. I want to get the help of the external javascript and css files. I have downloaded those files. And included those files in webroot directory (js and css sub directories). So If I want to use those in a view.ctp how can I call them. Can you explain me simply ?
Simply use the HTML helper like so :
print $this->Html->css("name_of_css_file");
print $this->Html->script("name_of_javascript_file");
So long as you not doing anything crazy and are using the default ".css" and ".js" extensions - you can leave out the extensions from the above code.
Cake is still PHP. You must add link do css in head of html file (.ctp view file).
There are two ways, write link tag with rel and src attributes or using HtmlHelper