How to add an image to asciidoc book cover page? - pdf-generation

I would like to create a pdf book using asciidoc. The title page should include the title, subtitle and an image. So far I could not find any documentation on how to achive this.
Intuivly I would do something like
My book title
=============
:author: myself
:toc:
image:images/titelimage.png[width=400]
but this just adds image:images/titelimage.png[width=400] as a subtitle. What I would like to have is something like
My book title
<titleimage>
subtitle
Is there a way to do this in ascciidoc? If not, what do I need to do to get this?

If you're using asciidoctor-pdf you can define an attribute for the logo. It will place the image above the document title.
:title-logo-image: images/titelimage.png
See an example pdf here and the raw adoc.

If anyone is still looking for this answer, this is the correct way to do it (using asciidoctor-pdf):
= Book title
Authors
:front-cover-image: image::./images/title_page.png[]
This gives you the image by itself as the first page followed by a page that shows the title, authors, revision etc.
If you want the image on the same page as the title and author, you need to use :title-logo-image: instead.

If you want a PDF using the docbook 4.x output you should:
Generate a docinfo file with an image for the front page. This is an XML file looking like the following example. It is discussed at http://www.methods.co.nz/asciidoc/userguide.html#X87
Example:
<mediaobject>
<imageobject>
<imagedata align="center" depth="400" fileref="../images/tiger.png" />
</imageobject>
</mediaobject>
<subtitle>Subtitle of this book</subtitle>
Then, customize your DocBook stylesheets to include the media element for the title page (by default the stylesheets do not include this). http://www.sagehill.net/docbookxsl/TitlePagePrint.html
DocBook 5 includes a cover element in its stylesheets.

This:
= The Book's Title
:author: First Last
:email: first.last#company.com
:toc:
:toc-placement: preamble
:doctype: book
image:./images/title_page.jpg[]
Produces:
My book title
first.last#company.com - first.last#company.com
Image
Table of Contents
...

you just need to add a empty line between the toc and the images: instruction. That's how asciidoc kinda separates blocs.

Related

Custom id in Sphinx documentation generator

How to create a custom Id for headlines in Sphinx (Jinja)?
Sphinx defines Id same with the headline text by default, but I want to define a different Id
If you write this in text file :
Headline text
=============
After converting it to HTML file by Sphinx, it looks like this:
<span id="headline-text"></span><h2>Headline text<a class="headerlink" href="#headline-text" title="Permalink to this headline">¶</a></h2>
But I don't want this Id and I want to define my own custom Id for this tag
If text isn't English, the default value is 's-id{number}', which number sets by Sphinx.
Now I want to write something in another language and I'm looking for a way to change it.
After many searches, I came up with a way like the following, but the problem is that when I look at the HTML source, I see that it still has its own ID next to mine like following:
.. _my-custom-id:
مثال سرتیتر
============
And after converting to HTML:
<span id="s-id1"></span><span id="my-custom-id"></span><span id="id1"></span><h1>مثال سرتیتر<a class="headerlink" href="#my-custom-id" title="Permalink to this headline">¶</a></h1>
As you can see, this method still doesn't work and Sphinx still defines its default ID.
What is the solution?

Insert clickable SVG image into Sphinx documentation

I have SVG image file with several nodes each is associated with URL. If I open this file directly in browser I can click on each node and it will open different URLs. However when I use this picture in my Sphinx documentation it doesn't work - picture rendered as a whole so I need to open it by View Image and only then I can click on nodes.
I'm using standard image directive:
.. image:: myfile.svg
Probably I need to use something else?
Sphinx generates <img> tags for images, which makes sense in most cases. However, to have the links inside the svg be clickable, you should use an <object> tag, i.e.:
.. raw:: html
<object data="myfile.svg" type="image/svg+xml"></object>
(Regarding the GitHub issue you linked to, I don't think there's a lot that Sphinx can do here—it's really quite complicated—short of introducing a new option to the .. image directive that lets the user specify whether to render as an img or object tag.)
One simple solution would be to add a link to the svg file in this .. image:: myfile.svg command:
.. image:: myfile.svg
:target: _images/myfile.svg
Take care of checking the relative directory where the images are copied when the html files are generated. By default, it should be _images/.
This way, you can click the SVG file, to see it in a plain page, and then click on it as usual (not a perfect solution but still..).
I am probably misunderstanding the OP's requirements, but why not just include the SVG into the sphinx documentation as html? This appears to work for me:
.. raw:: html
:file: images/image.svg
To include clickable svg links within sphinx I did the following:
.. raw:: html
:file: ../graphs/pymedphys_analysis.gamma.svg
See:
https://raw.githubusercontent.com/pymedphys/pymedphys/1915b9496e93782bdac7dcebff7e26e470e5ff57/docs/graphs/graphs.rst
This then freed me to write the following within an imported style sheet:
svg {
width: 100%;
}
https://github.com/pymedphys/pymedphys/blob/f4d404fa1cf3f551c4aa80ef27438f418c61a436/docs/_static/style.css
This made the svg fit the container as desired.
See:
https://pymedphys.com/developer/dependencies.html#pymedphys
I like this way
.. raw:: html
<a href="https://www.google.com/">
<img src="https://img.shields.io/static/v1?&style=plastic&logo=appveyor&label=Google&message=link2google&color=FF0000" alt="No message"/></a>
I'm still looking for a better solution myself, but I ran into the same problem and used this workaround.
You can use the download directive to give the user a link to the file.
:download:`svg <images/image.svg>`

How to add an additional article info on sidebar in Joomla 1.5?

I want a sidebar on article page, with additional info. Is there such a solution for Joomla 1.5.
I mean that I add an article and the info is pulled from my text between the tags e.g.
{info_for-sidebar}
Lorem ipsum....
{/info_for-sidebar}
And this info shows in sidebar for current article with actual info.
Is this possible?
Setting up something like what you are asking for require some sort of workarounds.
First, lets agree that what you are calling a "sidebar" is nothing but a content... You enter that content as a part of your article.
So, to achieve what you are asking for I would recommend you use what is called CCK - Content Construction Kit - extension for Joomla using Form2Content. There's a free light edition that would be enough.
Form2Content let you setup a content type. You define what fields you want for each content. Then you create a template that will use the info you are going to enter on the fields to built an article layout.
So let's say you are going to create 3 fields like this :
1- Intro text
2- Full text
3- Sidebar
You are going to create a template as we said. each content type will have 2 templates an intro text template and a full text template
The full text template shall be like this :
<div class="content-container">
<div class="content-sidebar">{$SIDEBAR}</div>
<div class="content-fulltext">{$FULLTEXT}</div>
<br clear="both" />
</div>
The {$SIDEBAR} and {$FULLTEXT} are the text you entered in the form and Form2Content will use it to create a regular content with layout.
If you don't want to use another extension or that solution looks too complicated, you could use a javascript solution. For example you could create an HTML module in Joomla and assign its to the sidebar. On this module switch the view to HTML code and enter this:
<div class="content-sidebar"></div>
When you enter an article, switch the view to HTML code and enter the text you want to show on the sidebar and add a class to the paragraph or the div like this :
<p class="special-content">Lorem ipsum dolor<p>
Then use jQuery to append this special text to the sidebar like this :
jQuery(".content-sidebar").append(".special-content");
Note: Joomla does not load jQuery by default, you have to add it on your template or use a plugin.

Joomla Ja Slideshow Descriptions

How do you display the descriptions in Ja Slideshow?
I found an example on the forums that goes like this:
[desc img="img.jpg" url="http://www.url.com"]
<h1> Title </h1>
<p>Bla</p>
[/desc]
However, even if i match url of desc item to url of img, it's not being displayed, and i'm not all together on how that would work for multiple images?
Easy to do:
sl-1.jpg:caption=<h3>This is description for header 1</h3><br><p>Testing</hp>&url=http://www.yoururlhere.com
sl-2.jpg:caption=<h3>This is description for header 2</h3><br><p>Testing</hp>&url=http://www.yoururlhere.com
sl-3.jpg:caption=<h3>This is description for header 3</h3><br><p>Testing</hp>&url=http://www.yoururlhere.com
sl-4.jpg:caption=<h3>This is description for header 4</h3><br><p>Testing</hp>&url=http://www.yoururlhere.com

How do I add an image to an item in RSS 2.0?

Is there a way to send only an Image with a link and some alt text for each item in an RSS feed?
I looked at the enclosure tag but this is only for videos and music.
The enclosure element can be used to transmit pictures. The RSS 2.0 spec is quite clear about that, saying that the type is a MIME type. It does not say it is restricted to audio or video.
Here's an example: a set of photo feeds from Agence France Presse
One of solutions is to use CDATA in description
<![CDATA[
Image inside RSS
<img src="http://example.com/img/smiley.gif" alt="Smiley face">
]>
Note, that you may have a problem with hotlink prevented site.
This is possible in RRS2,
see
http://cyber.law.harvard.edu/rss/rss.html#ltenclosuregtSubelementOfLtitemgt
So you have to use the enclosure tag, to add media
You should use the enclosure tag within item to include the image. You can use it for images by setting the correct Mime Type (for example: image/jpeg) and including the image size as the "length" attribute. The length attribute doesn't need to be completely accurate but it's required for the RSS to be considered valid.
Here's a helpful article that discusses this and other options.
To work with the Mailchimp RSS to email feature, they expect the image to be specified in a <media:content> element inside <item>. This is their source for the feed item's image macro in their templates.
Thus, you need to add to the declarations
xmlns:media="http://search.yahoo.com/mrss/
Then inside the <item> element add
<media:content medium="image" url="http://whatever/foo.jpg" width="300" height="201" />
Without the extra declaration, the feed is invalid since media:content is not a known element.
Inside tag ITEM
<image:image xmlns:image="http://web.resource.org/rss/1.0/modules/image/">
http://domain. com/image.jpg
< /image:image>
Inside Description Tag
<![CDATA[
Some Text..
<br/><img src='http://domain. com/image.jpg' ><br/>
More Text
]]>
Regarding the <p> tag issue, You need to encode html within the xml.
Your code would look something like this:
<description><p> Text in the tag </p></description>
Since you are using php you can use htmlentities() to encode the html tags. They look horrible in the xml but RSS readers know what to do with it.
http://php.net/manual/en/function.htmlentities.php

Resources