These are some tips for writing the Markdown for your articles.
You can use HTML in your .md
files, but it's best to avoid it when possible. If you must use HTML, you'll have to keep the HTML on a separate line from the Markdown. In fact, you'll need a blank line between every block of Markdown and every block of HTML.*
*Technically this isn't always true. Sometimes HTML can live on the same line as Markdown, but the rules for when this works are not straightforward. You're free to experiment, but it'll keep your life a lot simpler to just keep it all separate.
One common use for HTML is to get the layout you want. Usually you can do this by surrounding a bit of Markdown with a <div>
styled how you'd like:
<div class="float-right">
![alt text](./image.jpg)
</div>
If you end up with extra space around your wrapped Markdown, try adding the trim-p
class to the wrapper.
You can include images in your .md
files with Markdown syntax (![alt text](./image.jpg)
). If the image is used in multiple pages, you should put it in the static/images/
directory, then reference it with an absolute path: ![galaxy logo](/images/logos/galaxy.jpg)
.
If the image is a one-off that's only used for this page, then you can just put it right in the same directory as the index.md
file. Then reference it with a relative path: ![one-off](./oneoff.jpg)
. Note that the ./
is necessary!
It is possible sometimes to use images from directories other than the current one or static/images/
. In those situations you'd just use a relative path like ![alt text](./subdir/image.jpg)
or even ![alt text](../sibling/image.jpg)
. But this is not recommended and may not work.
This framework uses the remark-attr plugin, which allows adding attributes to Markdown images. However, it currently only works for the width
attribute. It uses this syntax: ![alt text](./image.jpg){width="50"}
(where 50
is the image width in pixels).
If you'd like to resize your image in any other way (percentages, max-width
, height
, etc), you'll need to use a <div>
wrapper. Add the class img-sizer
to the <div>
, then resize it using the style
attribute. Some CSS properties will work better than others: widths are the most reliable, max-
or min-
prefixes usually work, but heights can be tricky.
Example:
<div class="img-sizer" style="width: 40%">
![alt text](./image.jpg)
</div>
We are planning to get remark-attr
working in more situations and with more attributes so you no longer have to use the <div>
wrapper workaround.
There are several HTML classes that can be useful when trying to get your Markdown to display right. Just add the class to an HTML wrapper around the relevant Markdown.
One issue you can run into with an HTML wrapper is that the Markdown inside will get wrapped in a <p>
tag. Usually the only issue this causes is it inserts extra padding around the wrapped Markdown. Adding the trim-p
class to the HTML wrapper should remove the padding.
Another issue caused by Markdown getting wrapped in a <p>
tag is that it becomes a block element. This means it ends up on its own line and can't be used in the middle of a line of text. Add inline-p
to the wrapper to make it display inline instead.
In other situations, you could find yourself with a <div>
inside your wrapper and it's messing up your layout. If making that <div>
display inline would help, you can apply this class.
See Resizing images.
Use this in an image wrapper to set the width
CSS property of the <img>
to auto
. This can help if you're trying to get several images to line up horizontally like in /events/cofests/papercuts/.
If you find that an image you're using is smaller than the area provided for it, you can use this class to make it fill that space.
Tables in Markdown are required to have a header row, or it won't be recognized as a table. If you'd like to make a table without a header, just add an empty header and wrap it in a <div>
with the no-header
class. This will hide any header rows.
Use this class to tighten up the rows in a table. This will removing some of the padding above and below the text in each cell and between lines of text. This lets the table take up less vertical space.
Currently there is a known issue with certain special characters like &
getting backslash escaped (\&
).
One workaround is to enclose characters like this in backticks: Q&A
-> Q`&`A
If you're adding a sublist to a list, make sure to indent it four spaces:
1. Item one
2. Item two
* Subitem A
* Subitem B
3. Item three
Often, you might want to insert a hyperlink to a file so the reader can download it or view it on its own. You might just drop the file into the same directory as the Markdown file, then insert a link like [click to download](./paper.pdf)
.
But this sort of "local" link often gets broken in the build process. So it's best to place the file in a static directory: either content/images/
(for images) or content/media/
(for non-images). Then you can link to it there using an absolute link:
[click to download](/media/paper.pdf)