Skip to content

Commit 1e39b04

Browse files
committed
Fix code callouts
1 parent 8b149fc commit 1e39b04

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

docs/testing/index.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,19 @@ The files in this directory are used for testing purposes. Do not edit these fil
3030
{
3131
"key": "value"
3232
}
33-
```
33+
```
34+
35+
36+
```yaml
37+
xpack:
38+
security:
39+
authc:
40+
realms:
41+
active_directory:
42+
my_ad:
43+
order: 0
44+
domain_name: example.com <1>
45+
url: ldaps://dc1.ad.example.com:3269, ldaps://dc2.ad.example.com:3269 <2>
46+
load_balance:
47+
type: "round_robin" <3>
48+
```

src/Elastic.Markdown/Assets/markdown/code.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
}
2828
}
2929

30-
pre code .code-callout .hljs-number {
30+
pre code .code-callout {
31+
@apply ml-2;
3132
transform: translateY(-1px);
3233
user-select: none;
3334
}
@@ -47,8 +48,12 @@
4748
left: calc(-1 * var(--spacing) * 6);
4849
}
4950
}
51+
52+
pre code .code-callout .hljs-number {
53+
@apply text-white!;
54+
}
5055

51-
pre code .code-callout .hljs-number,
56+
pre code .code-callout,
5257
ol.code-callouts li::before {
5358
@apply text-xs!
5459
text-white!

src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private static List<CallOut> EnumerateAnnotations(Regex.ValueMatchEnumerator mat
238238

239239
private static CallOut? ParseMagicCallout(ValueMatch match, ref ReadOnlySpan<char> span, ref int callOutIndex, int originatingLine)
240240
{
241-
var startIndex = Math.Max(span.LastIndexOf("//"), span.LastIndexOf('#'));
241+
var startIndex = Math.Max(span.LastIndexOf(" // "), span.LastIndexOf('#'));
242242
if (startIndex <= 0)
243243
return null;
244244

@@ -248,7 +248,7 @@ private static List<CallOut> EnumerateAnnotations(Regex.ValueMatchEnumerator mat
248248
return new CallOut
249249
{
250250
Index = callOutIndex,
251-
Text = callout.TrimStart('/').TrimStart('#').TrimStart().ToString(),
251+
Text = callout.TrimStart().TrimStart('/').TrimStart('#').TrimStart().ToString(),
252252
InlineCodeAnnotation = true,
253253
SliceStart = startIndex,
254254
Line = originatingLine,
@@ -257,7 +257,7 @@ private static List<CallOut> EnumerateAnnotations(Regex.ValueMatchEnumerator mat
257257

258258
private static List<CallOut> ParseClassicCallOuts(ValueMatch match, ref ReadOnlySpan<char> span, ref int callOutIndex, int originatingLine)
259259
{
260-
var indexOfLastComment = Math.Max(span.LastIndexOf('#'), span.LastIndexOf("//"));
260+
var indexOfLastComment = Math.Max(span.LastIndexOf('#'), span.LastIndexOf(" // "));
261261
var startIndex = span.LastIndexOf('<');
262262
if (startIndex <= 0)
263263
return [];

0 commit comments

Comments
 (0)