mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-06 20:00:17 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35b311e182 | |||
| 8e058f4c7f |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix bash code blocks colouring the last letter of a word before `>` differently, as in `<name>`.
|
||||
@@ -343,6 +343,7 @@
|
||||
"patchedDependencies": {
|
||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
||||
"next@16.4.5": "patches/next@16.4.5.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
+2
-1
@@ -68,6 +68,7 @@
|
||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
||||
"@vercel/next@4.4.2": "patches/@vercel%2Fnext@4.4.2.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
"next@16.4.5": "patches/next@16.4.5.patch"
|
||||
"next@16.4.5": "patches/next@16.4.5.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,6 +709,19 @@ function joinLineContent(line: HighlightLine): string {
|
||||
return visit(line.tokens);
|
||||
}
|
||||
|
||||
it('keeps the last letter of a bash word before `>` in the same token', async () => {
|
||||
const tokenContents = async (code: string) => {
|
||||
const lines = await highlightWithInlines(singleLineBlock('bash', code));
|
||||
return lines[0]!.tokens.map((t) => (t.type === 'shiki' ? t.token.content : ''));
|
||||
};
|
||||
|
||||
const placeholder = await tokenContents('cli create --name <resource name>');
|
||||
expect(placeholder.find((c) => c.includes('nam'))).toContain('name');
|
||||
|
||||
const fdRedirect = await tokenContents('cmd 2>&1');
|
||||
expect(fdRedirect.find((c) => c.includes('2'))).toContain('2>&1');
|
||||
});
|
||||
|
||||
function singleLineBlock(syntax: string | undefined, text: string): DocumentBlockCode {
|
||||
return {
|
||||
object: 'block',
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
diff --git a/dist/shellscript.mjs b/dist/shellscript.mjs
|
||||
index ccf9c0f62f48a803f0640e758244a950f17ba53e..6956ab14623f71cf5bc88c5c6437502abba7ec0f 100644
|
||||
--- a/dist/shellscript.mjs
|
||||
+++ b/dist/shellscript.mjs
|
||||
@@ -3,3 +3,6 @@ const lang = Object.freeze(JSON.parse("{\"displayName\":\"Shell\",\"name\":\"she
|
||||
export default [
|
||||
lang
|
||||
]
|
||||
+
|
||||
+// Upstream keeps the last letter of `name>` out of the word: https://github.com/jeff-hykin/better-shell-syntax/issues/111
|
||||
+lang.repository.argument_context.patterns[0].match = '[\\t ]*+(?!\\d+>)([^\\t\\n "$\\&-);<>\\\\`|]+)';
|
||||
Reference in New Issue
Block a user