@@ -21,49 +21,6 @@ namespace Elastic.Markdown.Myst.Renderers.LlmMarkdown;
2121
2222public static class LlmRenderingHelpers
2323{
24- /// <summary>
25- /// Renders content with indentation using a flexible indentation strategy
26- /// </summary>
27- /// <param name="renderer">The markdown renderer</param>
28- /// <param name="markdownObject">The markdown object to render</param>
29- /// <param name="baseIndent">Base indentation to apply</param>
30- /// <param name="lineIndentSelector">Optional function to customize indentation per line (lineIndex, lineContent) => indent</param>
31- /// <param name="preserveCodeBlockIndentation">Whether to preserve original indentation for code blocks</param>
32- public static void RenderContentWithIndentation (
33- LlmMarkdownRenderer renderer ,
34- MarkdownObject markdownObject ,
35- string baseIndent = " " ,
36- Func < int , string , string > ? lineIndentSelector = null ,
37- bool preserveCodeBlockIndentation = false )
38- {
39- var output = DocumentationObjectPoolProvider . UseLlmMarkdownRenderer ( renderer . BuildContext , markdownObject , static ( tmpRenderer , obj ) =>
40- {
41- _ = tmpRenderer . Render ( obj ) ;
42- } ) ;
43-
44- if ( string . IsNullOrEmpty ( output ) )
45- return ;
46-
47- var lines = output . Split ( '\n ' ) ;
48- for ( var i = 0 ; i < lines . Length ; i ++ )
49- {
50- var line = lines [ i ] ;
51- var indent = lineIndentSelector ? . Invoke ( i , line ) ?? baseIndent ;
52-
53- if ( i == 0 )
54- renderer . Write ( line ) ;
55- else if ( ! string . IsNullOrWhiteSpace ( line ) )
56- {
57- renderer . WriteLine ( ) ;
58- renderer . Write ( indent ) ;
59- var lineToWrite = preserveCodeBlockIndentation ? line : line . TrimStart ( ) ;
60- renderer . Write ( lineToWrite ) ;
61- }
62- else if ( i < lines . Length - 1 )
63- renderer . WriteLine ( ) ;
64- }
65- }
66-
6724 public static void RenderBlockWithIndentation ( LlmMarkdownRenderer renderer , MarkdownObject block , string indentation = " " )
6825 {
6926 var content = DocumentationObjectPoolProvider . UseLlmMarkdownRenderer ( renderer . BuildContext , block , static ( tmpRenderer , obj ) =>
0 commit comments