Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mini typos in the docs #970

Merged
merged 21 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</h2>

Franklin is a simple **static site generator** (SSG) oriented towards technical blogging (code, maths, ...), flexibility and extensibility.
The base syntax is plain markdown with a few extensions such as the ability to define and use LaTeX-like commands in or outside of maths environments and the possibility to evaluate code blocks on the fly.
The base syntax is plain markdown with a few extensions such as the ability to define and use LaTeX-like commands in or outside of maths environments and the possibility to evaluate code blocks on the fly.

Franklin has a channel **#franklin** on the Julia slack, this is the best place to ask usage question.
Franklin has a channel **#franklin** on the Julia slack, this is the best place to ask usage questions.

**Note**: I'm looking for people with web-dev chops who would be keen to help improve and enrich the base themes available at [FranklinTemplates.jl](https://github.com/tlienart/FranklinTemplates.jl), even if you're not super confident in Julia. More generally, if you would like to work on something or fix something in either Franklin or FranklinTemplates, please reach out on Slack, I will gladly help you get started.

Expand Down Expand Up @@ -128,7 +128,7 @@ alias franklin=julia -O0 -e 'using Franklin; serve()'
While Franklin broadly supports standard Markdown there are a few things that may trip you which are either due to Franklin or due to Julia's Markdown library, here are key ones you should keep in mind:

* when writing a list, the content of the list item **must** be on a single line (no line break)
* you can write comments with `<!-- comments -->` the comment markers `<!--` and `-->` **must** be separated by a character that is not a `-` to work properly so `<!--A-->` is ok but `<!---A--->` is not, best is to just systematically use a whitespace: `<!-- A -->`.
* you can write comments with `<!-- comments -->` the comment markers `<!--` and `-->` **must** be separated by a character that is not a `-` to work properly so `<!--A-->` is ok but `<!---A--->` is not, best is to just systematically use whitespace: `<!-- A -->`.
* be careful writing double braces, `{{...}}` has a *meaning* (html functions) this can cause issues in latex commands, if you have double braces in a latex command, **make sure to add whitespaces** for instance write `\dfrac{1}{ {101}_{2} }` instead of `\dfrac{1}{{101}_{2}}`. In general use whitespaces liberally to help the parser in math and latex commands.
* (as of `v0.7`) code blocks should be delimited with backticks `` ` `` you *can* also use indented blocks to delimit code blocks but you now have to **opt in** explicitly on pages that would use them by using `@def indented_code = true`, if you want to use that everywhere, write that in the `config.md`. Note that indented blocks are **ambiguous** with some of the other things that Franklin provides (div blocks, latex commands) and so if you use them, you are responsible for avoiding ambiguities (effectively that means _not using indentation for anything else than code_)

Expand Down
8 changes: 4 additions & 4 deletions docs/code/eval-tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ reviewed: 22/12/2019

\toc

The basic idea is to exploit the fact that the output of a Julia code block evaluated by Franklin can be re-processed as Franklin Markdow when using the `\textoutput` command; this offers a wide range of possibilities best shown through a few examples (more or less in increasing degree of sophistication).
The basic idea is to exploit the fact that the output of a Julia code block evaluated by Franklin can be re-processed as Franklin Markdown when using the `\textoutput` command; this offers a wide range of possibilities best shown through a few examples (more or less in increasing degree of sophistication).

## Generating a table

Expand Down Expand Up @@ -93,7 +93,7 @@ println("@@")

### Code

That can obtained with (see detailed explanations further below)
That can be obtained with (see detailed explanations further below)

```html
\newcommand{\circle}[1]{
Expand Down Expand Up @@ -124,7 +124,7 @@ println("@@")
The first part defines a command `\circle` which takes one argument for the fill colour and inserts SVG code for a circle with that colour.

The second part is a Julia code block which will be evaluated but not displayed on the page (since there is a `#hideall`).
The code loops over the each colour `c` and prints `\circle{c}` so that the code block effectively generates:
The code loops over each colour `c` and prints `\circle{c}` so that the code block effectively generates:

```plaintext
@@ccols \circle{pink}...\circle{yellow}@@
Expand All @@ -150,7 +150,7 @@ The last thing to do is to style the `colors` div appropriately:

You may want to have a page with responsive team cards for instance where every card would follow the same layout but the content would be different.
There are multiple ways you can do this with Franklin and a simple one below (adapted from [this tutorial](https://www.w3schools.com/howto/howto_css_team.asp)).
The advantage of doing something like this is that it can help separate the content from the layout making both arguably easier more maintainable.
The advantage of doing something like this is that it can help separate the content from the layout making both arguably easier and more maintainable.

### Preview

Expand Down
36 changes: 18 additions & 18 deletions docs/code/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ As per Common Mark specifications, you have multiple ways of inserting code:
This is some `inline code` or ``inline ` code with a tick``.
`````

**Note**: To use backslash (`\ `) at the end of inline code, you must include a trailing space to ensure the trailing tick is parsed correctly, eg `` `some code with \ ` ``. The trailing space will be trimmed in the rendered html.
**Note**: To use a backslash (`\ `) at the end of the inline code, you must include a trailing space to ensure the trailing tick is parsed correctly, eg `` `some code with \ ` ``. The trailing space will be trimmed in the rendered html.

* **code blocks**: it is recommended to use triple backticks (\`\`\`) optionally followed by a language name for highlighting like so:

Expand All @@ -45,8 +45,8 @@ This is some code:

### Evaluating code

When presenting code in a post, it's often convenient to have a way to check the code works and the output shown corresponds to the code.
In Franklin there are two approaches that help you for this:
When presenting code in a post, it's often convenient to have a way to check that the code works and that the output shown corresponds to the code.
In Franklin, there are two approaches that help you with it:

@@tlist
1. For Julia code, a **live-evaluation** of code blocks is supported,
Expand All @@ -57,11 +57,11 @@ In Franklin there are two approaches that help you for this:

## Live evaluation (Julia)

Julia code blocks can be evaluated on the fly and their output either displayed as code or re-interpreted as Markdown.
Julia code blocks can be evaluated on the fly and their output is either displayed as code or re-interpreted as Markdown.

\note{
**Evaluation time**: when a code block is created or modified and the page is saved, it will trigger a page build that will _wait_ for the evaluation of the code block to complete. So if your code block takes a long time to execute, the page will not be updated before that's done.
That being said, if you don't modify the code block, it will only be executed **once** as the output is saved to file.
That being said, if you don't modify the code block, it will only be executed **once** as the output is saved to a file.
}

Code blocks that _should not_ be evaluated should be added as per standard markdown, so for instance:
Expand All @@ -88,8 +88,8 @@ What this will do is:
1. run the code and capture its output (`STDOUT`) and write it to `/assets/[subpath]/code/output/ex1.out`
@@

The `[subpath]` here is the _exact same sub-path structure_ than to the page where the code block is inserted.
To clarify, let's say you wrote the above code-block in
The `[subpath]` here is the _exact same sub-path structure_ as the page where the code block is inserted.
To clarify, let's say you wrote the above code block in

```
/folder1/page1.md
Expand All @@ -103,7 +103,7 @@ then with the syntax above, the script will be saved in

### More on paths

There are three ways you can specify where the script corresponding to a code-block should be saved.
There are three ways you can specify where the script corresponding to a code block should be saved.

@@tlist
1. _relative to the page_: `./[p]/script` is as above, it will write the code block to `/assets/[subpath]/p/script.jl` where `subpath` corresponds to the sub-path of the page where the code block is inserted (path below `/src/`)
Expand Down Expand Up @@ -143,7 +143,7 @@ and will look like
dot(a, a) = 14
```

If you now change the vector `a` in the code block, the page will be re-compiled with the code-block re-evaluated and the new output will be shown.
If you now change the vector `a` in the code block, the page will be re-compiled with the code block re-evaluated and the new output will be shown.

If you would like the output to be re-interpeted by Franklin as text, you can use `\textoutput` instead.
Here's an example:
Expand Down Expand Up @@ -273,30 +273,30 @@ savefig(joinpath(@OUTPUT, "sinc.svg")) # hide

\fig{sinc}

**Note**: observe that here everything is done with relative paths, `pyplot1` is placed in the `/assets/` folder relatively to the path of the current page and the `\fig` since it's given a path that doesn't start with `/` or `./` will also look in that folder to try to find a figure which starts with the name `sinc`. See also [more about paths](#more_on_paths).
**Note**: observe that here everything is done with relative paths, `pyplot1` is placed in the `/assets/` folder relatively to the path of the current page and the `\fig` since it's given a path that doesn't start with `/` or `./` will also look in that folder to try to find a figure which starts with the name `sinc`. See also [more about paths](#more_on_paths).

**Note**: If you wish to use `Plots.jl` and deploy to GitHub pages, you will need to modify the `.github/workflows/Deploy.yml` by adding `env: GKSwstype: "100"` before the ` - name: Build and Deploy` line. [Here](https://github.com/storopoli/Bayesian-Julia/blob/master/.github/workflows/Deploy.yml) is an example.

### Troubleshooting

A few things can go wrong when attempting to use and evaluate code blocks.
The first thing to do if no output is shown or an error appears is to make sure that:
A few things can go wrong when attempting to use and evaluate code blocks.
The first thing to do when no output is shown or when an error appears is to make sure that:

@@tlist
1. if the code uses packages, these packages are available in the local environment,
1. the code "just works" in the REPL.
@@

If this is the case and you still have issues, then you may want to force re-evaluation of the code on the page.
If this is the case and you still have issues, then you may want to force a re-evaluation of the code on the page.
In such a case, try adding `@def reeval = true` on the page which will cause **all** code blocks on the page to be completely re-evaluated and their output re-generated.
Assuming that helped, you will then want to remove that line as otherwise that page will be fully re-evaluated _every single time the page is modified_ which will cause an unnecessary overhead.
Assuming that helped, you will then want to remove that line as otherwise that page will be fully re-evaluated _every single time the page is modified_ which will cause unnecessary overhead.

**Important note**: unless you explicitly use `@def reeval = true`, code blocks are evaluated *only* if:
@@tlist
- an earlier code block has been evaluated (in which case, since their results may depend on it, all subsequent blocks are re-evaluated),
- the content of the code block has changed.
@@
An example where this can be a bit tricky is if your code block calls a function on a file, for instance `read(file, String)`; if the underlying *file* is changed, the code block will **not** be re-evaluated (since the code doesn't change), so in such cases you will want to use a `@def reeval = true`.
An example where this can be a bit tricky is if your code block calls a function on a file, for instance `read(file, String)`; if the underlying *file* is changed, the code block will **not** be re-evaluated (since the code doesn't change), so in such cases, you will want to use a `@def reeval = true`.

## Offline evaluation (any language)

Expand All @@ -305,7 +305,7 @@ The philosophy here is:
@@tlist
* keep your code snippets in appropriate subfolders of `/assets/` where they can be run and their output can be saved, this can be compared to a `test/` folder in a Julia package,
* run some or all of the snippets (before running Franklin),
* use `\input{...}{...}` in your markdown (see below) and when the website is updated, it will plug-in the most recent parts that have been generated.
* use `\input{...}{...}` in your markdown (see below) and when the website is updated, it will plug in the most recent parts that have been generated.
@@

That way, if you modify the code, everything will be updated on the website too while ensuring that the code actually runs and generates the output you're displaying.
Expand Down Expand Up @@ -368,7 +368,7 @@ In order to insert the plain-text output of a script, you can use
\output{scripts/script1.jl}
```

This will insert the content of the file `/assets/scripts/script1.out` into a non-highlighted code-block.
This will insert the content of the file `/assets/scripts/script1.out` into a non-highlighted code block.

### Plot output

Expand All @@ -386,4 +386,4 @@ The `plot:id` option is useful if you have a script that generates several plots
### Slicing up

The structure in the `generate_results.jl` effectively means that all your code is run as one big script.
This also means that if you want to slice some of your code in several parts and show intermediate outputs (e.g. plots), you can just do that by having a `script_1_p1.jl`, `script_1_p2.jl` etc. and then just use `\input` multiple times.
This also means that if you want to slice some of your code into several parts and show intermediate outputs (e.g. plots), you can just do that by having a `script_1_p1.jl`, `script_1_p2.jl` etc. and then just use `\input` multiple times.
8 changes: 4 additions & 4 deletions docs/extras/index.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Extras

In this section of the manual, the assumption is that you already have a fairly good idea of how Franklin works so that basic explanations are skipped (refer to the rest of the manual for help).
In this section of the manual, the assumption is that you already have a fairly good idea of how Franklin works so basic explanations are skipped (refer to the rest of the manual for help).

The aim is to show how Franklin can work with other useful libraries to add functionalities to your website.
The aim is to show how Franklin can work with other useful libraries to add functionalities to your website.
See also the [demos](/demos/).

As usual, these examples are just meant to show what can be done, not the best way to do it, feel free to modify the examples at will!
Also, if you come up with other nice ways of extending Franklin, don't hesitate to make a suggestion for an example to be added here.
As usual, these examples are just meant to show what can be done, not the best way to do it, feel free to modify the examples at will!
Also, if you come up with other nice ways of extending Franklin, don't hesitate to make a suggestion for an example to be added here.

## List of examples

Expand Down
12 changes: 6 additions & 6 deletions docs/extras/literate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

See also [how to interact with literate scripts](/code/literate/).

[Literate.jl](https://github.com/fredrikekre/Literate.jl) allows to pre and post-process a script in order, for instance, to generate a notebook out of a script.
This can be convenient if you want to have a tutorial be downloadable as a standalone notebook or as a scrubbed script.
[Literate.jl](https://github.com/fredrikekre/Literate.jl) allows to pre and post-process a script in order, for instance, to generate a notebook out of a script.
This can be convenient if you want to have a tutorial downloadable as a standalone notebook or as a scrubbed script.

This page presents one way of doing this which is used in [DataScienceTutorials](https://github.com/alan-turing-institute/DataScienceTutorials.jl) and which might inspire your own approach.
This page presents one way of doing this which is used in [DataScienceTutorials](https://github.com/alan-turing-institute/DataScienceTutorials.jl) and which might inspire your own approach.

The key ingredients are:

Expand All @@ -17,13 +17,13 @@ The key ingredients are:
1. add this as a `final` hook to `publish`.
@@

In what follows, it is assumed you have your Literate scripts in a folder `/scripts/` and that you're using GitHub.
It shouldn't be hard to modify that to suit your own case.
In what follows, it is assumed you have your Literate scripts in a folder `/scripts/` and that you're using GitHub.
It shouldn't be hard to modify that to suit your own case.


## Using Literate to generate auxiliary files

Literate can manipulate scripts fairly easily, for instance to generate notebooks:
Literate can manipulate scripts fairly easily, for instance, to generate notebooks:

```julia
scripts = joinpath.("scripts", readdir("scripts"))
Expand Down
Loading