<CH.Section>
Sometimes it is useful to reference code from a section of text. Since the code may be below or above the text, we need to wrap the text and the code inside an element: <CH.Section>
.
With the <CH.Section>
component you can reference code in two ways:
Inline code
With Code Hike, you have two options to render inline code:
- You can use the standard markdown syntax where you wrap the code in backticks:
`var x = 10`
, which won't be syntax-highlighted. - Or use a special syntax where you wrap the code with underscores and backticks:
_`var x = 10`_
, which will be syntax-highlighted asvar x = 10
.
Usually, the syntax depends on the context and the language. If you use the special inline code inside a <CH.Section>
component, Code Hike will copy the highlighting from the code to the text:
Code mentions
Code mentions are a way to link code and text. We borrow the link syntax from markdown to create hoverable links to the code. It's easier to show than to explain:
The syntax is the same as a markdown link, but instead of an URL, you use focus://
as the protocol, and then pass a focus string.
Code mentions are useful when you have more than one file. To specify the file, you prepend the name before the focus string and separate them with a #
: