Skip to content

Commit 7c49553

Browse files
authored
feat(config): parse reference-style markdown links in descriptions (tauri-apps#1311)
1 parent 91d090b commit 7c49553

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.scripts/generate-config-doc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,23 @@ function descriptionConstructor(description, fixNewlines = false) {
157157
description = newDescription
158158
}
159159

160+
const referenceStyleLinksRegex = /(\[[A-Za-z0-9 ]+\]): (.+)/g
161+
const referenceStyleLinksMatches = referenceStyleLinksRegex.exec(description)
162+
if (referenceStyleLinksMatches) {
163+
let link = referenceStyleLinksMatches[2]
164+
// strip `<` and `>` from `<$url>`
165+
if (link.startsWith('<')) {
166+
link = link.substring(1, link.length - 1)
167+
}
168+
description = description
169+
.replace(referenceStyleLinksMatches[0], '')
170+
.replace(
171+
referenceStyleLinksMatches[1],
172+
`${referenceStyleLinksMatches[1]}(${link})`
173+
)
174+
.trim()
175+
}
176+
160177
// Fix any embedded new lines
161178
if (fixNewlines) {
162179
description = description.replaceAll('\n', '<br />')

docs/api/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Type: `object`
169169
| <div className="anchor-with-padding" id="windowconfig.titlebarstyle">`titleBarStyle`<a class="hash-link" href="#windowconfig.titlebarstyle"></a></div> | [`TitleBarStyle`](#titlebarstyle) | [view](#titlebarstyle) | The style of the macOS title bar. |
170170
| <div className="anchor-with-padding" id="windowconfig.hiddentitle">`hiddenTitle`<a class="hash-link" href="#windowconfig.hiddentitle"></a></div> | boolean | `false` | If `true`, sets the window title to be hidden on macOS. |
171171
| <div className="anchor-with-padding" id="windowconfig.acceptfirstmouse">`acceptFirstMouse`<a class="hash-link" href="#windowconfig.acceptfirstmouse"></a></div> | boolean | `false` | Whether clicking an inactive window also clicks through to the webview on macOS. |
172-
| <div className="anchor-with-padding" id="windowconfig.tabbingidentifier">`tabbingIdentifier`<a class="hash-link" href="#windowconfig.tabbingidentifier"></a></div> | string? | _null_ | Defines the window [tabbing identifier] for macOS.<br /><br />Windows with matching tabbing identifiers will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled.<br /><br />[tabbing identifier]: <https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier> |
172+
| <div className="anchor-with-padding" id="windowconfig.tabbingidentifier">`tabbingIdentifier`<a class="hash-link" href="#windowconfig.tabbingidentifier"></a></div> | string? | _null_ | Defines the window [tabbing identifier](https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier) for macOS.<br /><br />Windows with matching tabbing identifiers will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled. |
173173
| <div className="anchor-with-padding" id="windowconfig.additionalbrowserargs">`additionalBrowserArgs`<a class="hash-link" href="#windowconfig.additionalbrowserargs"></a></div> | string? | _null_ | Defines additional browser arguments on Windows. By default wry passes `--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection` so if you use this method, you also need to disable these components by yourself if you want. |
174174

175175

@@ -676,7 +676,7 @@ Can be any of the following types:
676676

677677
| Name | Type | Default | Description |
678678
| ---- | ---- | ------- | ----------- |
679-
| <div className="anchor-with-padding" id="shellallowedarg.validator">`validator`<a class="hash-link" href="#shellallowedarg.validator"></a></div> | string (required) | | [regex] validator to require passed values to conform to an expected input.<br /><br />This will require the argument value passed to this variable to match the `validator` regex before it will be executed.<br /><br />[regex]: https://docs.rs/regex/latest/regex/#syntax |
679+
| <div className="anchor-with-padding" id="shellallowedarg.validator">`validator`<a class="hash-link" href="#shellallowedarg.validator"></a></div> | string (required) | | [regex](https://docs.rs/regex/latest/regex/#syntax) validator to require passed values to conform to an expected input.<br /><br />This will require the argument value passed to this variable to match the `validator` regex before it will be executed. |
680680

681681

682682

0 commit comments

Comments
 (0)