Skip to content

Commit 25c0583

Browse files
authored
Fix truncated text in code callout (#584)
* Fix code callouts * cleanup * Do the same for the # comment char * Revert
1 parent 8b149fc commit 25c0583

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

docs/testing/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ The files in this directory are used for testing purposes. Do not edit these fil
3030
{
3131
"key": "value"
3232
}
33-
```
33+
```

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-1;
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)