Skip to content

Commit

Permalink
Link-fragments-in-html-conversions (#199)
Browse files Browse the repository at this point in the history
* feat: handle RFC section links in md to html respec

* chore: markdown formatting

* chore: markdown format

* chore: fix ToC generation in respec
  • Loading branch information
frankkilcommins authored Jun 7, 2024
1 parent 6edb1ae commit 90425c0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
13 changes: 11 additions & 2 deletions scripts/md2html/md2html.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,17 @@ for (let l in lines) {
line = line.replace('https://xml2rfc.ietf.org/public/rfc/html/rfc','https://tools.ietf.org/html/rfc');
line = line.replace('.html','');
}
line = line.replace(/\]\]\(https:\/\/tools.ietf.org\/html\/rfc[0-9]{1,5}\/?(\#.*?)?\)/g,function(match,group1){
return ']]';

//handle url fragments in RFC links and construct section titles links as well as RFC links
line = line.replace(/\]\]\(https:\/\/tools.ietf.org\/html\/rfc([0-9]{1,5})(\/?\#.*?)?\)/g, function(match, rfcNumber, fragment) {
if (fragment) {
// Extract section title from the fragment
let sectionTitle = fragment.replace('#', '').replace(/-/g, ' ');
sectionTitle = sectionTitle.charAt(0).toUpperCase() + sectionTitle.slice(1); // Capitalize the first letter
return `]] [${sectionTitle}](https://tools.ietf.org/html/rfc${rfcNumber}${fragment})`;
} else {
return ']]';
}
});
}

Expand Down
43 changes: 22 additions & 21 deletions versions/1.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ An object used to describe the type and version of an expression used within a [

Defining this object gives the ability to utilize tooling compatible with older versions of either JSONPath or XPath.

##### Fixed Fields
##### Fixed Fields
Field Name | Type | Description
---|:---:|---
<a name="criterionExpressionType"></a>type | `string` | **REQUIRED**. The type of condition to be applied. The options allowed are `jsonpath` or `xpath`.
Expand Down Expand Up @@ -728,8 +728,9 @@ Field Name | Type | Description
This object MAY be extended with [Specification Extensions](#specification-extensions).

##### RequestBody Object Example
**JSON Templated Example**
```yaml

**JSON Templated Example**
```yaml
contentType: application/json
payload: |
{
Expand All @@ -741,10 +742,10 @@ This object MAY be extended with [Specification Extensions](#specification-exten
"complete": false
}
}
```
```

**JSON Object Example**
```yaml
**JSON Object Example**
```yaml
contentType: application/json
payload:
petOrder:
Expand All @@ -753,16 +754,16 @@ This object MAY be extended with [Specification Extensions](#specification-exten
quantity: $inputs.quantity
status: placed
complete: false
```
```

**Complete Runtime Expression**
```yaml
**Complete Runtime Expression**
```yaml
contentType: application/json
payload: $inputs.petOrderRequest
```
```

**XML Templated Example**
```yaml
**XML Templated Example**
```yaml
contentType: application/xml
payload: |
<petOrder>
Expand All @@ -772,10 +773,10 @@ This object MAY be extended with [Specification Extensions](#specification-exten
<status>placed</status>
<complete>false</complete>
</petOrder>
```
```

**Form Data Example**
```yaml
```yaml
contentType: application/x-www-form-urlencoded
payload:
client_id: $inputs.clientId
Expand All @@ -784,10 +785,10 @@ This object MAY be extended with [Specification Extensions](#specification-exten
client_secret: $inputs.clientSecret
code: $steps.browser-authorize.outputs.code
scope: $inputs.scope
```
```

**Form Data String Example**
```yaml
```yaml
contentType: application/x-www-form-urlencoded
payload: "client_id={$inputs.clientId}&grant_type={$inputs.grantType}&redirect_uri={$inputs.redirectUri}&client_secret={$inputs.clientSecret}&code{$steps.browser-authorize.outputs.code}&scope=$inputs.scope}"
```
Expand All @@ -807,14 +808,14 @@ This object MAY be extended with [Specification Extensions](#specification-exten

**Runtime Expression Example**
```yaml
target: /petId
value: $inputs.pet_id
target: /petId
value: $inputs.pet_id
```

**Literal Example**
```yaml
target: /quantity
value: 10
target: /quantity
value: 10
```


Expand Down Expand Up @@ -843,7 +844,7 @@ The runtime expression is defined by the following [ABNF](https://tools.ietf.org
"^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
```

##### Examples
#### Examples

Source Location | example expression | notes
---|:---|:---|
Expand Down

0 comments on commit 90425c0

Please sign in to comment.