Skip to content

Commit 4c5eb11

Browse files
committed
Support quoting of .?s file ext
1 parent a6c3774 commit 4c5eb11

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

tools/dev-server/README_AUTHORS.md renamed to README_AUTHORS.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,17 @@ const i: number = 0;
109109

110110
### 3. File Extensions (`.js/.ts`)
111111

112-
When the text or a section heading mentions the name of a file that will be JavaScript or TypeScript, depending on the language, then use the file extension `.?s`. It will automatically be switched to the current language.
112+
When the text or a section heading mentions the name of a file that will be JavaScript or TypeScript, depending on the language, then use the file extension `.\?s`. It will automatically be switched to the current language.
113113

114114
Example:
115115
```md
116-
In this step you create the file `Example.controller.?s`.
116+
In this step you create the file `Example.controller.\?s`.
117117
```
118118

119-
120119
#### Resulting Appearance<span class="hidden"> in markdown view (here the extension is not replaced, the replacement only happens in the dev server and in GitHub Pages)</span>
121120

122121
In this step you create the file `Example.controller.?s`.
123122

124-
125-
126-
127123
## Converting the JS Code to TypeScript
128124

129125
TODO: tool support for this functionality does not exist yet. It can, however, already be done manually.

assets/js/custom.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ function replaceFileExtensions(lang) {
198198
}
199199

200200
node.parentNode.replaceChild(fragment, node);
201+
} else if (node.nodeValue.includes(".\\?s")) {
202+
debugger;
203+
node.nodeValue = node.nodeValue.replace(/\.\\\?s/g, ".?s");
201204
}
202205
node = nextNode;
203206
}

tools/dev-server.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ async function getTemplate() {
4040

4141
app.use("/assets", express.static(join(__dirname, "..", "assets")));
4242

43-
app.use("/assets/anchor-js", express.static(join(__dirname, "..", "node_modules", "anchor-js")));
44-
app.use("/assets/highlight.js", express.static(join(__dirname, "..", "node_modules", "@highlightjs", "cdn-assets")));
45-
app.use("/assets/github-markdown-css", express.static(join(__dirname, "..", "node_modules", "github-markdown-css")));
43+
app.use("/node_modules", express.static(join(__dirname, "..", "node_modules")));
4644

4745
app.use(async (req, res, next) => {
4846
let file, url;

tools/dev-server/ghpage-template.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>{{title}}</title>
7-
<link rel="stylesheet" href="/assets/github-markdown-css/github-markdown.css">
7+
<link rel="stylesheet" href="/node_modules/github-markdown-css/github-markdown.css">
88
<script>
99
// select the theme based on the user's preference
1010
const theme = (function () {
@@ -17,7 +17,7 @@
1717
})();
1818
const link = document.createElement("link");
1919
link.rel = "stylesheet";
20-
link.href = `/assets/highlight.js/styles/${theme}.min.css`;
20+
link.href = `/node_modules/@highlightjs/cdn-assets/styles/${theme}.min.css`;
2121
document.head.appendChild(link);
2222
2323
// patch the code blocks to be detected by the custom.js script to introduce
@@ -67,9 +67,9 @@
6767
</h1>
6868
{{{bodyContent}}}
6969
</div>
70-
<script src="/assets/highlight.js/highlight.min.js"></script>
70+
<script src="/node_modules/@highlightjs/cdn-assets/highlight.min.js"></script>
7171
<script>hljs.highlightAll();</script>
72-
<script src="/assets/anchor-js/anchor.min.js"></script>
72+
<script src="/node_modules/anchor-js/anchor.min.js"></script>
7373
<script>anchors.add();</script>
7474
</body>
7575
</html>

0 commit comments

Comments
 (0)