added include template for images and refined documentation for alerts and callouts include templates

This commit is contained in:
tomjohnson1492
2016-06-06 10:00:01 -07:00
parent 2647ab54d7
commit 06673e2de9
5 changed files with 99 additions and 98 deletions

1
_includes/image.html Normal file
View File

@ -0,0 +1 @@
<figure>{% if {{include.url}} %}<a class="no_icon" target="_blank" href="{{include.url}}">{% endif %}<img class="docimage" src="{{site.baseurl | prepend: site.url}}/images/{{include.file}}" alt="{{include.alt}}" {% if {{include.max-width}} %}style="max-width: {{include.max-width}}px"{% endif %} />{% if {{include.url}} %}</a>{% endif %}{% if {{include.caption}} %}<figcaption>{{include.caption}}</figcaption></figure>{% endif %}

View File

@ -0,0 +1 @@
<img class="inline" src="{{site.image_path}}/{{include.file}}{% if site.target == "hippo" %}._TTH_{% endif %}.{{include.type}}" alt="{{include.alt}}" />

View File

@ -935,7 +935,8 @@ a[href^="http://"]:after, a[href^="https://"]:after {
/* Strip the outbound icon when this class is present */ /* Strip the outbound icon when this class is present */
a[href].noCrossRef::after, a[href].noCrossRef::after,
a.no_icon:after { a.no_icon:after
{
content:"" !important; content:"" !important;
padding-left: 0; padding-left: 0;
} }
@ -1136,3 +1137,20 @@ div.box.box1 {
word-wrap: break-word; /* Internet Explorer 5.5+ */ word-wrap: break-word; /* Internet Explorer 5.5+ */
font-size: 14px; font-size: 14px;
} }
/*
* Let's target IE to respect aspect ratios and sizes for img tags containing SVG files
*
* [1] IE9
* [2] IE10+
*/
/* 1 */
.ie9 img[src$=".svg"] {
width: 100%;
}
/* 2 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
img[src$=".svg"] {
width: 100%;
}
}

View File

@ -13,7 +13,7 @@ Alerts are little warnings, info, or other messages that you have called out in
## Alerts ## Alerts
You can insert an alert by using any of the following code. Similar to [inserting images]({{site.data.urls.mydoc_images.url}}), you insert alerts through various includes that have been developed. These includes provide templates through which you pass parameters to easily populate the right HTML code.
``` ```
{%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %}{% endraw%} {%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %}{% endraw%}
@ -23,7 +23,13 @@ Here's the result:
{% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %} {% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %}
If you need multiple paragraphs, enter `<br/><br/>` tags, like this: With alerts, there's just one include property:
| Property | description |
|-------|--------|
| content | The content for the alert. |
If you need multiple paragraphs, enter `<br/><br/>` tags. This is because block level tags aren't allowed here, as Kramdown is processing the content as Markdown despite the fact that the content is surrounded by HTML tags. Here's an example with a break:
``` ```
{%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph. <br/><br/> Now I'm typing on a new line." %}{% endraw%} {%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph. <br/><br/> Now I'm typing on a new line." %}{% endraw%}
@ -52,10 +58,8 @@ They function the same except they have a different color, icon, and alert word.
{% include important.html content="This is my important info." %} {% include important.html content="This is my important info." %}
These alerts leverage includes stored in the \_include folder. The `content` option is a parameter that you pass to the include. In the include, the parameter is passed like this: These alerts leverage includes stored in the \_include folder. The `content` option is a parameter that you pass to the include. In the include, the parameter is passed like this:
``` ```
{% raw %}<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> {{include.content}}{% endraw %}</div> {% raw %}<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> {{include.content}}{% endraw %}</div>
``` ```
@ -76,26 +80,14 @@ Here's the result:
{% include callout.html content="This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs." type="primary" %} {% include callout.html content="This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs." type="primary" %}
To include paragraph breaks, use `<br/><br/>` inside the callout: The available properties for callouts are as follows:
``` | Property | description |
{% raw %}{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %} {% endraw %} |-------|--------|
``` | content | The content for the callout. |
| type | The style for the callout. Options are `danger`, `default`, `primary`, `success`, `info`, and `warning`.|
Here's the result: The types just define the color of the left border. Each of these callout types get inserted as a class name in the callout template. These class names correspond with styles in Bootstrap. These classes are common Bootstrap class names whose style attributes differ depending on your Bootstrap theme and style definitions.
{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %}
The type options are as follows:
* `danger`
* `default`
* `primary`
* `success`
* `info`
* `warning`
These types just define the color of the left border. Each of these callout types get inserted as a class name in the callout template. These class names correspond with styles in Bootstrap. These classes are common Bootstrap class names whose style attributes differ depending on your Bootstrap theme and style definitions.
Here's an example of each different type of callout: Here's an example of each different type of callout:
@ -113,9 +105,19 @@ Here's an example of each different type of callout:
Now that in contrast to alerts, callouts don't include the alert word (note, tip, warning, or important). Now that in contrast to alerts, callouts don't include the alert word (note, tip, warning, or important).
To include paragraph breaks, use `<br/><br/>` inside the callout:
```
{% raw %}{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %} {% endraw %}
```
Here's the result:
{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %}
## Markdown inside of callouts and alerts ## Markdown inside of callouts and alerts
You can use Markdown inside of callouts and alerts, even though this content actually gets inserted inside of HTML in the include. This is one of the advantages of Kramdown Markdown. The include template has an attribute of `markdown="span"` that allows for the processer to parse Markdown inside of HTML. You can use Markdown inside of callouts and alerts, even though this content actually gets inserted inside of HTML in the include. This is one of the advantages of kramdown Markdown. The include template has an attribute of `markdown="span"` that allows for the processor to parse Markdown inside of HTML.
## Validity checking ## Validity checking
@ -132,4 +134,3 @@ In this case, the quotation marks aren't set correctly. I forgot the closing quo
## Blast a warning to users on every page ## Blast a warning to users on every page
If you want to blast a warning to users on every page, add the alert or callout to the \_layouts/page.html page right below the frontmatter. Every page using the page layout (all, by defaut) will show this message. If you want to blast a warning to users on every page, add the alert or callout to the \_layouts/page.html page right below the frontmatter. Every page using the page layout (all, by defaut) will show this message.

View File

@ -3,93 +3,73 @@ title: Images
tags: [formatting] tags: [formatting]
keywords: images, screenshots, vectors, svg, markdown syntax keywords: images, screenshots, vectors, svg, markdown syntax
last_updated: March 20, 2016 last_updated: March 20, 2016
summary: "You embed images using traditional HTML or Markdown syntax for images. Unlike pages, you can store images in subfolders (in this theme). This is because when pages reference the images, the references are always as subpaths, never requiring the reference to move up directories." summary: "Store images in the images folder and use the image.html include to insert images. This include has several options, including figcaptions, that extract the content from the formatting."
sidebar: mydoc_sidebar sidebar: mydoc_sidebar
permalink: /mydoc_images/ permalink: /mydoc_images/
--- ---
You embed an image the same way you embed other files or assets: you put the file into a folder, and then link to that file. ## Image Include Template
Put images inside the `images` folder in your root directory. You can create subdirectories inside this directory. Although you could use Markdown syntax for images, the HTML syntax is probably easier: Instead of using Markdown or HMTL syntax directly in your page for images, the syntax for images has been extracted out into an image include that allows you to pass the parameters you need. Include the image.html like this:
```liquid
{% raw %} {% raw %}
```html {% include image.html file="jekyll.png" url="http://jekyllrb.com" alt="Jekyll" caption="This is a sample caption" %"}
<img title="my sample page" src="{{ "/images/jekyll.png" | prepend: site.baseurl }}" />
```
{% endraw %} {% endraw %}
And the result:
<img title="my sample image" src="{{ "/images/jekyll.png" | prepend: site.baseurl }}">
Here's the same Markdown syntax:
{% raw %}
``` ```
![My sample page]({{ "/images/jekyll.png" | prepend: site.baseurl }})
```
{% endraw %}
And the result: The available include properties are as follows:
![My sample page]({{ "/images/jekyll.png" | prepend: site.baseurl }}) | Property | description |
|-------|--------|
| file | The name of the file. Store it in the /images folder. |
| url | Whether to link the image to a URL |
| alt | Alternative image text for accessibility and SEO |
| caption | A caption for the image |
| max-width | a maximum width for the image (in pixels). Just specify the number, not px.|
{{site.data.alerts.tip}} I recommend storing this format into a shortcut editor such as aText. This way when you want to insert an image, just type something like jimg and the shortcut editor will automatically type the code.{{site.data.alerts.end}} The properties of the include get populated into the image.html template.
## Figure captions
If you want to add a figure caption, you can do so using standard `figure` HTML tags:
{% raw %}
```html
<figure><img title="my sample page" src="{{ "/images/jekyll.png" | prepend: site.baseurl }}" /><figcaption>Your caption</figcaption></figure>
```
{% endraw %}
Here's the result: Here's the result:
<img title="my sample page" src="{{ "/images/jekyll.png" | prepend: site.baseurl }}" /> {% include image.html file="jekyll.png" url="http://jekyllrb.com" alt="Jekyll" caption="This is a sample caption" %}
<figcaption>Your caption</figcaption></figure>
## SVG Images ## SVG Images
You can also embed SVG graphics. If you use SVG, you need to use the HTML syntax so that you can define a width/container for the graphic. Here's a sample embed: You can also embed SVG graphics. If you use SVG, you need to use the HTML syntax so that you can define a width/container for the graphic. Here's a sample embed:
```html ```liquid
<img src="{{ "/images/helpapi.svg" | prepend: site.baseurl }}" style="max-width: 600px;" /> {% raw %}{% include image.html file="helpapi.svg" url="http://idratherbewriting.com/documentation-theme-jekyll/mydoc_help_api/" alt="Building a Help API" caption="A help API provides a JSON file at a web URL with content that can be pulled into different targets" max-width="600" %}{% endraw %}
``` ```
Here's the result: Here's the result:
<img src="{{ "/images/helpapi.svg" | prepend: site.baseurl }}" style="max-width: 600px;" />
SVG images will expand to the size of their container, so you have to specify it here. The previous syntax isn't well supported in IE, so you would be better off using the `object` element like this: {% include image.html file="helpapi.svg" url="http://idratherbewriting.com/documentation-theme-jekyll/mydoc_help_api/" alt="Building a Help API" caption="A help API provides a JSON file at a web URL with content that can be pulled into different targets" max-width="600" %}
{% raw %} The stylesheet even handles SVG display in IE 9 and earlier through the following style (based on this [gist](https://gist.github.com/larrybotha/7881691)):
```html
<div style="max-width:600px;"><object type="image/svg+xml" data="{{ "/images/helpapi.svg" | prepend: site.baseurl }}">Your browser does not support SVG</object> ```css
</div> /*
* Let's target IE to respect aspect ratios and sizes for img tags containing SVG files
*
* [1] IE9
* [2] IE10+
*/
/* 1 */
.ie9 img[src$=".svg"] {
width: 100%;
}
/* 2 */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
img[src$=".svg"] {
width: 100%;
}
}
``` ```
{% endraw %}
Here's the same code with `figure` elements:
{% raw %}
```html
<div style="max-width:600px;"><figure><object type="image/svg+xml" data="{{ "/images/helpapi.svg" | prepend: site.baseurl }}">Your browser does not support SVG</object><figcaption>This is your caption</figcaption></figure>
</div>
```
{% endraw %}
And the result:
<div style="max-width:400px;"><figure><object type="image/svg+xml" data="{{ "/images/helpapi.svg" | prepend: site.baseurl }}">Your browser does not support SVG</object><figcaption>This is your caption</figcaption></figure></div>
Also, if you're working with SVG graphics, note that Firefox does not support SVG fonts. In Illustrator, when you do a Save As with your AI file and choose SVG, to preserve your fonts, in the Font section, select "Convert to outline" as the Type (don't choose SVG in the Font section). Also, if you're working with SVG graphics, note that Firefox does not support SVG fonts. In Illustrator, when you do a Save As with your AI file and choose SVG, to preserve your fonts, in the Font section, select "Convert to outline" as the Type (don't choose SVG in the Font section).
Also, remove the check box for "Use textpath element for text on a path". And select "Embed" rather than "Link." The following screenshot shows the settings I use. Your graphics will look great in Firefox. Also, remove the check box for "Use textpath element for text on a path". And select "Embed" rather than "Link." The following screenshot shows the settings I use. Your graphics will look great in Firefox.
![Essential options for SVG with Illustrator]({{ "/images/illustratoroptions.png" | prepend: site.baseurl }}) ![Essential options for SVG with Illustrator]({{ "/images/illustratoroptions.png" | prepend: site.baseurl }})