Skip to content

Commit 680cb31

Browse files
slusarzsirainen
authored andcommitted
markdown: Add settings_text command
GitHub Issue #1008
1 parent f228ad2 commit 680cb31

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,24 @@ Links to the RFC page (external).
242242
#### Settings
243243

244244
***Syntax: `[[setting,setting_name(,args)]]`***
245+
***Syntax: `[[setting_text,setting_name(,text)]]`***
245246

246-
If args is set, it is appended to the display as a setting value. Example:
247+
For the `setting` variant, if args is set, it is appended to the display as a
248+
setting value. Example:
247249

248250
```
249251
# [[setting,foo,5]] results in:
250252
<a href="PATH_TO_FOO_SETTING">foo = 5</a>
251253
```
252254

255+
For the `setting_text` variant, if text is set, it is used as the link text.
256+
Example:
257+
258+
```
259+
# [[setting_text,foo,bar]] results in:
260+
<a href="PATH_TO_FOO_SETTING">bar</a>
261+
```
262+
253263
#### Variable
254264

255265
***Syntax: `[[variable(,section)]]`***

lib/markdown.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ function dovecot_markdown(md, opts) {
156156
case 'doveadm':
157157
case 'event':
158158
case 'setting':
159+
case 'setting_text':
159160
env.inner = parts[1]
160161
env.args = parts[2] ? parts[2] : undefined;
161162

@@ -179,16 +180,17 @@ function dovecot_markdown(md, opts) {
179180
break
180181

181182
case 'setting':
183+
case 'setting_text':
182184
/* Settings names can have brackets, so we need to unescape
183185
* input for purposes of searching settings keys. */
184-
const search_str = env.inner.replaceAll('&gt;', '<')
185-
.replaceAll('&lt;', '>')
186+
const search_str = env.inner.replaceAll('&gt;', '>')
187+
.replaceAll('&lt;', '<')
186188

187189
if (!opts.settings[search_str]) {
188190
handle_error('setting link missing: ' + env.inner)
189191
return '<code><a>'
190192
}
191-
page += 's'
193+
page = 'settings'
192194
break
193195
}
194196

@@ -334,6 +336,9 @@ function dovecot_markdown(md, opts) {
334336
case 'setting':
335337
return env.inner + (env.args ? ' = ' + env.args : '')
336338

339+
case 'setting_text':
340+
return env.args ?? env.inner
341+
337342
case 'variable':
338343
return env.inner
339344

@@ -357,6 +362,7 @@ function dovecot_markdown(md, opts) {
357362
case 'event':
358363
case 'man':
359364
case 'setting':
365+
case 'setting_text':
360366
case 'variable':
361367
return '</a></code>'
362368

0 commit comments

Comments
 (0)