Skip to content

Commit e667dcc

Browse files
authored
docs: fix markdown links (#2154)
1 parent b102c7f commit e667dcc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

docs/3-packages/04-markdown.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Prepend `*` to a link's URI to open the link in a new tab:
197197

198198
## Adding custom features
199199

200-
`tempest/markdown` is meant to be extended. Adding custom parser rules is done in two steps: first you provide a `LexerRule`, this is a class that determines when your custom parsing logic should be triggered. Next you'll use a `Token` to render your selected Markdown code in any way you'd like.
200+
`tempest/markdown` is meant to be extended. Adding custom parser rules is done in two steps: first you provide a `Rule`, this is a class that determines when your custom parsing logic should be triggered. Next you'll use a `Token` to render your selected Markdown code in any way you'd like.
201201

202202
Let's work with an example. Say you want to add support for including custom HTML snippets. It could look something like this:
203203

@@ -207,32 +207,32 @@ Hello world
207207
{{ snippets/call-to-action.html }}
208208
```
209209

210-
The first step to adding this new feature is detecting when we run into our custom `{{ }}` syntax. This is done with a `LexerRule`. Let's call our implementation `SnippetRule`:
210+
The first step to adding this new feature is detecting when we run into our custom `{{ }}` syntax. This is done with a `Rule`. Let's call our implementation `SnippetRule`:
211211

212212
```php
213-
use Tempest\Markdown\Lexer;
213+
use Tempest\Markdown\Parser;
214214
use Tempest\Markdown\Rule;
215215
use Tempest\Markdown\Token;
216216

217217
final readonly class SnippetRule implements Rule
218218
{
219-
public function shouldLex(Lexer $lexer): bool
219+
public function shouldLex(Parser $parser): bool
220220
{
221221
// Our rule takes effect as soon as we run into `{{`
222222

223-
return $lexer->comesNext('{{', length: 2);
223+
return $parser->comesNext('{{', length: 2);
224224
}
225225

226-
public function lex(Lexer $lexer): ?Token
226+
public function lex(Parser $parser): ?Token
227227
{
228228
// We'll consume all { characters
229-
$lexer->consumeWhile('{');
229+
$parser->consumeWhile('{');
230230

231231
// Then we'll consume and store the snippet path itself until we encounter the closing } characters
232-
$snippet = $lexer->consumeUntil('}');
232+
$snippet = $parser->consumeUntil('}');
233233

234234
// Then we'll consume the closing } characters
235-
$lexer->consumeWhile('}');
235+
$parser->consumeWhile('}');
236236

237237
// Finally, we return a token with the snippet
238238
return new SnippetToken(trim($snippet));
@@ -241,7 +241,7 @@ final readonly class SnippetRule implements Rule
241241
```
242242

243243
:::info
244-
For performance reasons, it's best to explcitly add the `{:hl-property:length:}` parameter to the `{:hl-property:comesNext:}` call. It's not required, but it will make parsing faster. If possible, also try not to rely on regex within your lexer rules, as it may become a performance bottleneck.
244+
For performance reasons, it's best to explcitly add the `{:hl-property:length:}` parameter to the `{:hl-property:comesNext:}` call. It's not required, but it will make parsing faster. If possible, also try not to rely on regex within your parser rules, as it may become a performance bottleneck.
245245
:::
246246

247247
So that's our rule implementation: we consumed our custom `{{ path }}` syntax, and created a token with that path. Let's take a look at the token implementation next.
@@ -302,7 +302,7 @@ $markdown = new Markdown()->withRules(
302302
);
303303
```
304304

305-
This way you have full control over how the parser works. For more inspiration, you can look at the [rules that come built-in with the package](https://github.com/tempestphp/markdown/tree/main/src/LexerRules).
305+
This way you have full control over how the parser works. For more inspiration, you can look at the [rules that come built-in with the package](https://github.com/tempestphp/markdown/tree/main/src/Rules).
306306

307307
## Performance
308308

0 commit comments

Comments
 (0)