Skip to content

Commit

Permalink
Merge pull request #1334 from mcanouil/default-bracket-inline
Browse files Browse the repository at this point in the history
docs: make bracketed inline code the default syntax
  • Loading branch information
cwickham authored Oct 23, 2024
2 parents 295c1f0 + 45d6d83 commit 4c6dfd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 4 additions & 9 deletions docs/get-started/computations/rstudio.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,10 @@ mean_hwy <- round(mean(mpg$hwy), 2)

Then, add the following markdown text to your Quarto document.

```{=html}
<div class="sourceCode">
<pre class="sourceCode markdown">
<code class="sourceCode markdown">
The average city mileage of the cars in our data is &#96;r mean_cty&#96 and the average highway mileage is &#96;r mean_hwy&#96.
</code>
</pre>
</div>
```markdown
The average city mileage of the cars in our data is `{r} mean_cty` and the average highway mileage is `{r} mean_hwy`.
```

Save your document and inspect the rendered output.

::: border
Expand Down Expand Up @@ -303,7 +298,7 @@ If you followed along step-by-step with this tutorial, you should now have a Qua
Otherwise, you can download a completed version of `computations.qmd` below.

::: {.callout-note appearance="minimal"}
<i class="bi bi-download"></i> [Download computations-complete.qmd](_computations-complete.qmd){download="computations-complete.qmd"}
`<i class="bi bi-download"></i>`{=html} [Download computations-complete.qmd](_computations-complete.qmd){download="computations-complete.qmd"}
:::

{{< include _footer.md >}}
12 changes: 7 additions & 5 deletions docs/visual-editor/technical.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,22 @@ Source code which you include in a Quarto document can either be for display onl

To display but not execute code, either use the **Insert -\> Code Block** menu item, or start a new line and type either:

1. ```` ``` ```` (for a plain code block); or
2. ```` ```<lang> ```` (where \<lang\> is a language) for a code block with syntax highlighting.
1. ` ``` ` (for a plain code block); or
2. ` ```<lang> ` (where `<lang>` is a language) for a code block with syntax highlighting.

Then press the **Enter** key. To display code inline, simply surround text with backticks (`` `code` ``), or use the **Format -\> Code** menu item.

### Code Chunks

To insert an executable code chunk, use the **Insert -\> Code Chunk** menu item, or start a new line and type:

```` ```{r} ````
` ```{r} `

Then press the **Enter** key. Note that `r` could be another language supported by knitr (e.g. `python` or `sql`) and you can also include a chunk label and other chunk options.
Then press the **Enter** key. Note that `r` could be another language supported by `knitr` (e.g., `python` or `sql`) and you can also include a chunk label and other chunk options.

To include inline R code, you just create normal inline code (e.g. by using backticks or the <kbd>⌘ D</kbd> shortcut) but preface it with `r` or `{r}`. For example, this inline code will be executed by knitr: `` `r Sys.Date()` ``. Note that when the code displays in visual mode it won't have the backticks (but they will still appear in source mode).
To include [inline R code](/docs/computations/inline-code.qmd), create normal inline code (e.g., by using backticks or the <kbd>⌘ D</kbd> shortcut) but preface it with `{r}` (or `r`). For example, to include the current date using the R function `Sys.Date()` you would use: `` `{r} Sys.Date()` ``.

Note that when the code displays in visual mode it won't have the backticks (but they will still appear in source mode).

### Running Chunks

Expand Down

0 comments on commit 4c6dfd3

Please sign in to comment.