Skip to content

Commit 349aae0

Browse files
committed
Merge branch 'build-script/improved-code-blocks' into build-script/improved-syntax-colors
2 parents 9821676 + 13ead12 commit 349aae0

File tree

7 files changed

+149
-1
lines changed

7 files changed

+149
-1
lines changed

scripts/md2html/md2html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function preface(title,options) {
120120
preface += 'pre { background-color: #f6f8fa !important; }';
121121
preface += 'code { color: #c83500 } th code { color: inherit }';
122122
preface += 'a.bibref { text-decoration: underline;}';
123-
preface += fs.readFileSync(path.resolve(__dirname,'gist.css'),'utf8').split('\n').join(' ');
123+
preface += fs.readFileSync(path.resolve(__dirname,'gist.css'),'utf8').split(/\r?\n/).join(' ');
124124
preface += '</style>';
125125
preface += `<h1 id="title">${title.split('|')[0]}</h1>`;
126126
preface += `<p class="copyright">Copyright © ${options.publishDate.getFullYear()} the Linux Foundation</p>`;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html text eol=lf
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><link rel="canonical" href="https://spec.openapis.org/oas/latest.html" /><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","editors":[],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script></head><body><style>#respec-ui { visibility: hidden; }#title { color: #578000; } #subtitle { color: #578000; }.dt-published { color: #578000; } .dt-published::before { content: "Published "; }h1,h2,h3,h4,h5,h6 { color: #578000; font-weight: normal; font-style: normal; }a[href] { color: #45512c; }body:not(.toc-inline) #toc h2 { color: #45512c; }table { display: block; width: 100%; overflow: auto; }table th { font-weight: 600; }table th, table td { padding: 6px 13px; border: 1px solid #dfe2e5; }table tr { background-color: #fff; border-top: 1px solid #c6cbd1; }table tr:nth-child(2n) { background-color: #f6f8fa; }pre { background-color: #f6f8fa !important; }code { color: #c83500 } th code { color: inherit }a.bibref { text-decoration: underline;}/** * GitHub Gist Theme * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro */ .hljs { display: block; background: white; padding: 0.5em; color: #333333; overflow-x: auto; } .hljs-comment, .hljs-meta { color: #969896; } .hljs-string, .hljs-variable, .hljs-template-variable, .hljs-strong, .hljs-emphasis, .hljs-quote { color: #df5000; } .hljs-number { color: #008080; } .hljs-keyword, .hljs-selector-tag, .hljs-type { color: #a71d5d; } .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-attribute { color: #0086b3; } .hljs-section, .hljs-name { color: #63a35c; } .hljs-tag { color: #333333; } .hljs-title, .hljs-attr, .hljs-selector-id, .hljs-selector-class, .hljs-selector-attr, .hljs-selector-pseudo { color: #795da3; } .hljs-addition { color: #55a532; background-color: #eaffea; } .hljs-deletion { color: #bd2c00; background-color: #ffecec; } .hljs-link { text-decoration: underline; } </style><h1 id="title">OpenAPI Specification v30.0.1 </h1><p class="copyright">Copyright © 3001 the Linux Foundation</p><section class="notoc" id="abstract"><h2>What is the OpenAPI Specification?</h2>The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.</section><section class="override" id="sotd" data-max-toc="0"><h2>Status of This Document</h2>The source-of-truth for the specification is the GitHub markdown file referenced above.</section>
2+
<section><h1>Heading 1</h1>
3+
<p>Text for first chapter</p>
4+
<section class="override" id="conformance"><h2>Version 30.0.1</h2>
5+
<p>This is the conformance section</p>
6+
</section></section><section><h1>Heading 2</h1>
7+
<p>Text for first section</p>
8+
<section><h2>Heading 3</h2>
9+
<p>Text for first subsection</p>
10+
<pre class="nohighlight" tabindex="0"><code><span class="hljs-punctuation">{</span>
11+
<span class="hljs-attr">&quot;foo&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span>
12+
<span class="hljs-punctuation">}</span>
13+
</code></pre>
14+
<pre class="nohighlight" tabindex="0"><code>text/plain
15+
</code></pre>
16+
<pre class="highlight " tabindex="0"><code>no language
17+
</code></pre>
18+
<table>
19+
<thead>
20+
<tr>
21+
<th>Version</th>
22+
<th>Date</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
<tr>
27+
<td>30.0.1</td>
28+
<td>3001-04-01</td>
29+
</tr>
30+
</tbody>
31+
</table>
32+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Heading 1
2+
3+
Text for first chapter
4+
5+
## Version 30.0.1
6+
7+
This is the conformance section
8+
9+
## Heading 2
10+
11+
Text for first section
12+
13+
### Heading 3
14+
15+
Text for first subsection
16+
17+
```json
18+
{
19+
"foo": true
20+
}
21+
```
22+
23+
```text
24+
text/plain
25+
```
26+
27+
```
28+
no language
29+
```
30+
31+
Version | Date
32+
--------|-----------
33+
30.0.1 | 3001-04-01
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>OpenAPI Specification v30.0.1 | Introduction, Definitions, &amp; More</title><meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs."><link rel="canonical" href="https://spec.openapis.org/oas/latest.html" /><script src="../js/respec-w3c.js" class="remove"></script><script class="remove">var respecConfig = {"specStatus":"base","latestVersion":"https://spec.openapis.org/oas/latest.html","editors":[],"formerEditors":[],"publishDate":"3001-04-01T00:00:00.000Z","subtitle":"Version 30.0.1","edDraftURI":"https://github.com/OAI/OpenAPI-Specification/","shortName":"OAS","historyURI":null,"lint":false,"logos":[{"src":"https://raw.githubusercontent.com/OAI/OpenAPI-Style-Guide/master/graphics/bitmap/OpenAPI_Logo_Pantone.png","alt":"OpenAPI Initiative","height":48,"url":"https://openapis.org/"}],"otherLinks":[{"key":"Participate","data":[{"value":"GitHub OAI/OpenAPI-Specification","href":"https://github.com/OAI/OpenAPI-Specification/"},{"value":"File a bug","href":"https://github.com/OAI/OpenAPI-Specification/issues"},{"value":"Commit history","href":"https://github.com/OAI/OpenAPI-Specification/commits/main/versions/30.0.1.md"},{"value":"Pull requests","href":"https://github.com/OAI/OpenAPI-Specification/pulls"}]}]};</script></head><body><style>#respec-ui { visibility: hidden; }#title { color: #578000; } #subtitle { color: #578000; }.dt-published { color: #578000; } .dt-published::before { content: "Published "; }h1,h2,h3,h4,h5,h6 { color: #578000; font-weight: normal; font-style: normal; }a[href] { color: #45512c; }body:not(.toc-inline) #toc h2 { color: #45512c; }table { display: block; width: 100%; overflow: auto; }table th { font-weight: 600; }table th, table td { padding: 6px 13px; border: 1px solid #dfe2e5; }table tr { background-color: #fff; border-top: 1px solid #c6cbd1; }table tr:nth-child(2n) { background-color: #f6f8fa; }pre { background-color: #f6f8fa !important; }code { color: #c83500 } th code { color: inherit }a.bibref { text-decoration: underline;}/** * GitHub Gist Theme * Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro */ .hljs { display: block; background: white; padding: 0.5em; color: #333333; overflow-x: auto; } .hljs-comment, .hljs-meta { color: #969896; } .hljs-string, .hljs-variable, .hljs-template-variable, .hljs-strong, .hljs-emphasis, .hljs-quote { color: #df5000; } .hljs-number { color: #008080; } .hljs-keyword, .hljs-selector-tag, .hljs-type { color: #a71d5d; } .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-attribute { color: #0086b3; } .hljs-section, .hljs-name { color: #63a35c; } .hljs-tag { color: #333333; } .hljs-title, .hljs-attr, .hljs-selector-id, .hljs-selector-class, .hljs-selector-attr, .hljs-selector-pseudo { color: #795da3; } .hljs-addition { color: #55a532; background-color: #eaffea; } .hljs-deletion { color: #bd2c00; background-color: #ffecec; } .hljs-link { text-decoration: underline; } </style><h1 id="title">OpenAPI Specification v30.0.1 </h1><p class="copyright">Copyright © 3001 the Linux Foundation</p><section class="notoc" id="abstract"><h2>What is the OpenAPI Specification?</h2>The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.</section><section class="override" id="sotd" data-max-toc="0"><h2>Status of This Document</h2>The source-of-truth for the specification is the GitHub markdown file referenced above.</section>
2+
<section><h1>Heading 1</h1>
3+
<p>Text for first chapter</p>
4+
<section class="override" id="conformance"><h2>Version 30.0.1</h2>
5+
<p>This is the conformance section</p>
6+
</section></section><section><h1>Heading 2</h1>
7+
<p>Text for first section</p>
8+
<section><h2>Heading 3</h2>
9+
<p>Text for first subsection</p>
10+
<table>
11+
<thead>
12+
<tr>
13+
<th>Version</th>
14+
<th>Date</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
<tr>
19+
<td>30.0.1</td>
20+
<td>3001-04-01</td>
21+
</tr>
22+
</tbody>
23+
</table>
24+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Heading 1
2+
3+
Text for first chapter
4+
5+
### Version 30.0.1
6+
7+
This is the conformance section
8+
9+
## Heading 2
10+
11+
Text for first section
12+
13+
### Heading 3
14+
15+
Text for first subsection
16+
17+
18+
Version | Date
19+
--------|-----------
20+
30.0.1 | 3001-04-01

tests/md2html/md2html.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { readdirSync, readFileSync } from "node:fs";
2+
import { exec } from "node:child_process";
3+
import { resolve } from "node:path";
4+
import { describe, test, expect } from "vitest";
5+
import assert from "node:assert";
6+
7+
const folder = "./tests/md2html/fixtures/";
8+
describe("v3.0 - Validate examples", async () => {
9+
readdirSync(folder, { withFileTypes: true })
10+
.filter((entry) => entry.isFile() && /\.md$/.test(entry.name))
11+
.forEach((entry) => {
12+
test(entry.name, async () => {
13+
const expected = readFileSync(
14+
folder + entry.name.replace(".md", ".html"),
15+
"utf8",
16+
);
17+
const output = await md2html([entry.name], folder);
18+
expect(output.stdout).to.equal(expected);
19+
});
20+
});
21+
});
22+
23+
function md2html(args, cwd) {
24+
return new Promise((res) => {
25+
exec(
26+
`node ${resolve("./scripts/md2html/md2html.js")} ${args.join(" ")}`,
27+
{ cwd },
28+
(error, stdout, stderr) => {
29+
res({
30+
code: error?.code || 0,
31+
error,
32+
stdout,
33+
stderr,
34+
});
35+
},
36+
);
37+
});
38+
}

0 commit comments

Comments
 (0)