Skip to content

Commit d3bc210

Browse files
authored
docs: Document how to include local images in exercises (#612)
Close #128
1 parent 8a2ebf0 commit d3bc210

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

demo-repository/exercises/demo/descr.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44

55
<h2>The task</h2>
6-
6+
<img src="/static/demo/files/OCaml.png" alt="OCaml" width="400px">
77
<p>
88
In this test-bed exercise you are asked to (re)implement the basic
99
integer-arithmetic functions.
90.3 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
How to include images in exercises
2+
==================================
3+
4+
## Context
5+
6+
If you create an exercise, you may want to add your own static content such as images in the exercise description (`descr.html` or `descr.md`).
7+
8+
Learn-OCaml provides this feature, so that you can either add images hosted in an external domain, or images statically served by the Learn-OCaml server itself (which can be handy for summative exams, for example, when remote resources are blocked).
9+
10+
## How-to
11+
12+
In order to include `OCaml.png` in an exercise called `demo`, you just need to:
13+
14+
1. Create a directory `<repo>/exercices/demo/subdirectory`. (The name of the `subdirectory` is free.)
15+
2. Put `OCaml.png` in there.
16+
3. In `<repo>/exercises/demo/descr.html` (resp. `<repo>/exercises/demo/descr.md`), use the following syntax:
17+
`<img src="/static/demo/subdirectory/OCaml.png" alt="fallback text">` (resp. `![fallback text](/static/demo/subdirectory/OCaml.png)`).
18+
19+
Note that we can't use relative URLs, hence the leading `/`.
20+
21+
If you want to fix the width (or height) of an image in `descr.html` or `descr.md`, you can use the usual HTML syntax:
22+
`<img src="/static/demo/subdirectory/OCaml.png" alt="fallback text" width="400px">`

0 commit comments

Comments
 (0)