Edits TOm

This commit is contained in:
Tom van Woudenberg 2025-03-04 07:50:01 +01:00
parent 97a8274eb0
commit 0bdb1d31a1
11 changed files with 109 additions and 99 deletions

View file

@ -0,0 +1,66 @@
# Exercise 7: File Structure (Markdown)
In this exercise you will learn how to structure your chapters.
::::::{topic} Exercise objective
Can you structure your page with a title and (sub)sections?
::::::
```{tip}
More useful Markdown syntax is explained in the [MyST cheat sheet](https://jupyterbook.org/en/stable/reference/cheatsheet.html).
```
1. Let's add a new file by going to a directory of your choice within `/book` and make sure you're in the correct branch.. When you've arrived there, click `Add file` - {octicon}`plus;1em`.
2. Name your file and end it with the file extension `.md` (e.g. `my_new_file.md`), your filename preferable shouldn't include spaces.
3. Now let's create the structure of your chapter. You need to start with a title on the top of this page. The title is always defined in one of the first lines of the file after the hashtag `#`. So your file should look like:
```md
# Chapter title
```
4. Now let's add some more text and subsections as needed. You're only allowed to use one chapter title `#`, but there's no limit for the amount of sections, subsections, etc:
```md
# Chapter Title
text
## Section Title 1
text
## Section Title 2
text
### Subsection Title 1
text
### Subsection Title 2
text
#### Heading
##### Smaller Heading
###### Smallest Heading
```
5. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button.
6. Add a commit message.
7. Now let's add your new file tot the table of contents, as explained in [](../exercises/002.md).
8. To see you changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? Soon, there'll be exercising on doing this locally which prevents you from waiting).
9. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page.
```{admonition} Check your understanding
:class: note
Before moving on to the next exercise, make sure you understand the following:
- What is the correct way to define a title in a Markdown file?
- How many chapter titles (`#`) are allowed in a single Markdown file?
- What file type are you using?
```

View file

@ -0,0 +1,62 @@
# Exercise 8: Add visual media
To help you illustrate your content, it can be useful to add some type of visual media such as figures or gifs. If you want to add a figure/gif to you book, you can refer to the URL to that image directly. This is quite handy but it does carry the risk that this figure file will no longer be visible if the location is changed, or if the website is down. Therefore, sometimes it can be better to add the source directly to the book (if done on small scale).
::::::{topic} Exercise objective
Can you add figures to your page?
::::::
```{note}
Unless you are using a file format like `*.svg`, the raw contents of a visual media file typically are not human-readable or have a binary file format. This is not an ideal file type to use with Git. When just beginning to learn about all the tools associated with a TeachBook, we recommend you keep things simple and do whatever is easiest for you. Note, however, that as your book grows, especially if you use a lot of non-svg images, you may want to find a different way to store them (guidance will be provided on this soon in the TeachBooks Manual---stay tuned!).
```
1. You will first need to upload your media to the repository. Navigate to the folder called figures (`book/figures`) and make sure you are in the right branch. On the right top, click on `Add file` - {octicon}`upload;1em` `Upload new file`. Note that you can store your files in another folder within the book directory too. However it's good practice to store figures in a separate folder (eventually per chapter).
2. Choose the visual media you want to upload. Remember its file name, including its file extension as you will need it later.
3. Commit your changes.
4. Now let's add the figure to a chapter. Navigate to the file you want to work in (for example `book/some_content/overview.md`) and make sure you're in the same branch as where you've added your figure.
5. Copy this syntax and adjust the file name, width, alignment and caption (for more options see the [MyST documentation](https://myst-parser.readthedocs.io/en/latest/syntax/images_and_figures.html#block-level-images)):
````md
```{figure} figures/<new_figure>.png
:width: 80%
:align: center
<caption text>
```
````
```{Warning}
Make sure the file extension of your figure is correct because markdown differentiates capital letters!
```
```{Warning}
If your figure is in a different directory than your chapter, you'll need to refer it using relative parts. If your figure is in a subdirectory of the directory of the chapter, go deeper with `subdirectory/` (e.g. `figures/<figure in figures-subdirectory>.png`). If your figure is in another directory, move upwards with `../` (e.g. `../../figure/<figure in figures-subdirectory which is located two folder above the current page>` )
```
6. To link and display an online figure, you can use the same `{figure}` directive. Just past in the :
````md
```{figure} https://town-n-country-living.com/wp-content/uploads/2023/06/craftsman-exterior.jpg
:width: 80%
:align: center
<caption>
```
````
6. When you are ready, commit your changes to the repository by clicking on the green `Commit changes` button.
7. Add a commit message.
8. To see you changes, go to {octicon}`play;1em` `Actions` - The most recent workflow run `overview.md / the commit message of the commit you just made` - Wait for it to finish - In the summary, click on the link of your book shown in the table `Branches deployed` and under `Primary book at root` (getting bored of waiting? There'll be exercising on doing this locally which prevents you from waiting)
9. Do you see your change? If you don't see it click `CTRL`+`F5`/`Control`+`F5`to refresh the page.

View file

@ -0,0 +1,45 @@
# Exercise 9: Referencing using target headers
It can be really useful to refer to a specific section in your book while working in a different file. Referencing can be done using target headers such as:
```
(<title>)=
```
1. Navigate to the file you want to work in (for example `book/some_content/overview.md`) and make sure you're in the correct branch.
2. Identify the section you want to reference and name it between brackets for example `exercise_1`.
```
(exercise_1)=
# Exercise 1: First file edit
Let's start with the most basic edit: add some text to a file and see that the website is updated...
```
3. There are three types of referencing:
* You can use the standard title text which will be the title after the target header
My favourite exercise was {ref}`exercise_1`.
```
My favourite exercise was {ref}`exercise_1`.
```
* You can also specify the title text of the target header (aka specify what the link will say):
My favourite exercise was {ref}`the first one <exercise_1>`.
```
My favourite exercise was {ref}`the first one <exercise_1>`.
```
* You can also use Markdown syntax, then the title text is also fully customizable.
My favourite exercise was [this one](exercise_1).
```
My favourite exercise was [this one](exercise_1).
```