From 1e39b043f11d3f5374f688a32097d2b3b7b25e39 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Fri, 21 Feb 2025 22:36:53 +0100 Subject: [PATCH 1/4] Fix code callouts --- docs/testing/index.md | 17 ++++++++++++++++- src/Elastic.Markdown/Assets/markdown/code.css | 9 +++++++-- .../Myst/CodeBlocks/EnhancedCodeBlockParser.cs | 6 +++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/docs/testing/index.md b/docs/testing/index.md index 3265aea28..70db6f925 100644 --- a/docs/testing/index.md +++ b/docs/testing/index.md @@ -30,4 +30,19 @@ The files in this directory are used for testing purposes. Do not edit these fil { "key": "value" } - ``` \ No newline at end of file + ``` + + +```yaml +xpack: + security: + authc: + realms: + active_directory: + my_ad: + order: 0 + domain_name: example.com <1> + url: ldaps://dc1.ad.example.com:3269, ldaps://dc2.ad.example.com:3269 <2> + load_balance: + type: "round_robin" <3> +``` diff --git a/src/Elastic.Markdown/Assets/markdown/code.css b/src/Elastic.Markdown/Assets/markdown/code.css index b01ef22dd..9f63b2a23 100644 --- a/src/Elastic.Markdown/Assets/markdown/code.css +++ b/src/Elastic.Markdown/Assets/markdown/code.css @@ -27,7 +27,8 @@ } } - pre code .code-callout .hljs-number { + pre code .code-callout { + @apply ml-2; transform: translateY(-1px); user-select: none; } @@ -47,8 +48,12 @@ left: calc(-1 * var(--spacing) * 6); } } + + pre code .code-callout .hljs-number { + @apply text-white!; + } - pre code .code-callout .hljs-number, + pre code .code-callout, ol.code-callouts li::before { @apply text-xs! text-white! diff --git a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs index cb69b373d..abc6885ef 100644 --- a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs +++ b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs @@ -238,7 +238,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat private static CallOut? ParseMagicCallout(ValueMatch match, ref ReadOnlySpan span, ref int callOutIndex, int originatingLine) { - var startIndex = Math.Max(span.LastIndexOf("//"), span.LastIndexOf('#')); + var startIndex = Math.Max(span.LastIndexOf(" // "), span.LastIndexOf('#')); if (startIndex <= 0) return null; @@ -248,7 +248,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat return new CallOut { Index = callOutIndex, - Text = callout.TrimStart('/').TrimStart('#').TrimStart().ToString(), + Text = callout.TrimStart().TrimStart('/').TrimStart('#').TrimStart().ToString(), InlineCodeAnnotation = true, SliceStart = startIndex, Line = originatingLine, @@ -257,7 +257,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat private static List ParseClassicCallOuts(ValueMatch match, ref ReadOnlySpan span, ref int callOutIndex, int originatingLine) { - var indexOfLastComment = Math.Max(span.LastIndexOf('#'), span.LastIndexOf("//")); + var indexOfLastComment = Math.Max(span.LastIndexOf('#'), span.LastIndexOf(" // ")); var startIndex = span.LastIndexOf('<'); if (startIndex <= 0) return []; From 7a18a3dc95ac79b42600f4ee385fecfead011ef0 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Fri, 21 Feb 2025 22:38:35 +0100 Subject: [PATCH 2/4] cleanup --- docs/testing/index.md | 15 --------------- src/Elastic.Markdown/Assets/markdown/code.css | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/docs/testing/index.md b/docs/testing/index.md index 70db6f925..d17fecb60 100644 --- a/docs/testing/index.md +++ b/docs/testing/index.md @@ -31,18 +31,3 @@ The files in this directory are used for testing purposes. Do not edit these fil "key": "value" } ``` - - -```yaml -xpack: - security: - authc: - realms: - active_directory: - my_ad: - order: 0 - domain_name: example.com <1> - url: ldaps://dc1.ad.example.com:3269, ldaps://dc2.ad.example.com:3269 <2> - load_balance: - type: "round_robin" <3> -``` diff --git a/src/Elastic.Markdown/Assets/markdown/code.css b/src/Elastic.Markdown/Assets/markdown/code.css index 9f63b2a23..dfd0bbd46 100644 --- a/src/Elastic.Markdown/Assets/markdown/code.css +++ b/src/Elastic.Markdown/Assets/markdown/code.css @@ -28,7 +28,7 @@ } pre code .code-callout { - @apply ml-2; + @apply ml-1; transform: translateY(-1px); user-select: none; } From d5dbe8c5de8c1da513b1d473741e76e61b341899 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Fri, 21 Feb 2025 23:22:20 +0100 Subject: [PATCH 3/4] Do the same for the # comment char --- .../Myst/CodeBlocks/EnhancedCodeBlockParser.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs index abc6885ef..18b2c4069 100644 --- a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs +++ b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs @@ -238,7 +238,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat private static CallOut? ParseMagicCallout(ValueMatch match, ref ReadOnlySpan span, ref int callOutIndex, int originatingLine) { - var startIndex = Math.Max(span.LastIndexOf(" // "), span.LastIndexOf('#')); + var startIndex = Math.Max(span.LastIndexOf(" // "), span.LastIndexOf(" # ")); if (startIndex <= 0) return null; @@ -248,7 +248,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat return new CallOut { Index = callOutIndex, - Text = callout.TrimStart().TrimStart('/').TrimStart('#').TrimStart().ToString(), + Text = callout.TrimStart().TrimStart('/').TrimStart(" # ").TrimStart().ToString(), InlineCodeAnnotation = true, SliceStart = startIndex, Line = originatingLine, @@ -257,7 +257,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat private static List ParseClassicCallOuts(ValueMatch match, ref ReadOnlySpan span, ref int callOutIndex, int originatingLine) { - var indexOfLastComment = Math.Max(span.LastIndexOf('#'), span.LastIndexOf(" // ")); + var indexOfLastComment = Math.Max(span.LastIndexOf(" # "), span.LastIndexOf(" // ")); var startIndex = span.LastIndexOf('<'); if (startIndex <= 0) return []; From 2d3b1379e626b3640829f0ae3d91667005b4ffdc Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Fri, 21 Feb 2025 23:22:57 +0100 Subject: [PATCH 4/4] Revert --- src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs index 18b2c4069..82e376420 100644 --- a/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs +++ b/src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockParser.cs @@ -248,7 +248,7 @@ private static List EnumerateAnnotations(Regex.ValueMatchEnumerator mat return new CallOut { Index = callOutIndex, - Text = callout.TrimStart().TrimStart('/').TrimStart(" # ").TrimStart().ToString(), + Text = callout.TrimStart().TrimStart('/').TrimStart('#').TrimStart().ToString(), InlineCodeAnnotation = true, SliceStart = startIndex, Line = originatingLine,