Skip to content

Commit

Permalink
markdown: Add settings_text command
Browse files Browse the repository at this point in the history
GitHub Issue dovecot#1008
  • Loading branch information
slusarz committed Sep 16, 2024
1 parent ad39769 commit ba77487
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,24 @@ Links to the RFC page (external).
#### Settings

***Syntax: `[[setting,setting_name(,args)]]`***
***Syntax: `[[setting_text,setting_name(,text)]]`***

If args is set, it is appended to the display as a setting value. Example:
For the `setting` variant, if args is set, it is appended to the display as a
setting value. Example:

```
# [[setting,foo,5]] results in:
<a href="PATH_TO_FOO_SETTING">foo = 5</a>
```

For the `setting_text` variant, if text is set, it is used as the link text.
Example:

```
# [[setting_text,foo,bar]] results in:
<a href="PATH_TO_FOO_SETTING">bar</a>
```

#### Variable

***Syntax: `[[variable(,section)]]`***
Expand Down
8 changes: 7 additions & 1 deletion lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function dovecot_markdown(md, opts) {
case 'doveadm':
case 'event':
case 'setting':
case 'setting_text':
env.inner = parts[1]
env.args = parts[2] ? parts[2] : undefined;

Expand All @@ -179,6 +180,7 @@ function dovecot_markdown(md, opts) {
break

case 'setting':
case 'setting_text':
/* Settings names can have brackets, so we need to unescape
* input for purposes of searching settings keys. */
const search_str = env.inner.replaceAll('&gt;', '<')
Expand All @@ -188,7 +190,7 @@ function dovecot_markdown(md, opts) {
handle_error('setting link missing: ' + env.inner)
return '<code><a>'
}
page += 's'
page = 'settings'
break
}

Expand Down Expand Up @@ -333,6 +335,9 @@ function dovecot_markdown(md, opts) {
case 'setting':
return env.inner + (env.args ? ' = ' + env.args : '')

case 'setting_text':
return env.args ?? env.inner

case 'variable':
return env.inner

Expand All @@ -356,6 +361,7 @@ function dovecot_markdown(md, opts) {
case 'event':
case 'man':
case 'setting':
case 'setting_text':
case 'variable':
return '</a></code>'

Expand Down

0 comments on commit ba77487

Please sign in to comment.