AI conversation page display method and system based on markdown format text streaming

By using an incremental Markdown abstract syntax tree construction and local update strategy, the problem of unstable display of streaming Markdown text in AI dialogue systems was solved, achieving a real-time and stable interface display effect.

CN122195551APending Publication Date: 2026-06-12XIAMEN LEELEN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610120405.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-28
Publication Date
2026-06-12

AI Technical Summary

Technical Problem

Existing AI dialogue systems cannot achieve real-time, stable, and accurate parsing and display when streaming Markdown text, resulting in problems such as frequent interface refreshes and layout flickering.

Method used

It adopts an incremental Markdown abstract syntax tree construction and maintenance mechanism, detects unclosed structures, uses preset completion rules and predictive closure algorithms for temporary completion, and introduces a virtual end marker mechanism. Combined with a local update strategy, it achieves real-time and stable display of streaming transmission.

Benefits of technology

Significantly reduces computational overhead, improves response efficiency, ensures real-time readability and interface stability, reduces interface flickering and jitter, and provides smooth rendering effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122195551A_ABST
    Figure CN122195551A_ABST
Patent Text Reader

Abstract

The application discloses an AI conversation page display method and system based on Markdown format text stream transmission, relates to the field of computer data processing, and receives a text stream by a client, converts the text stream into incremental Markdown structure units, merges the incremental Markdown structure units into an incremental Markdown abstract syntax tree, and only updates affected nodes. The system detects unclosed Markdown structures, temporarily completes the unclosed Markdown structures according to preset completion rules or a prediction closing algorithm, and inserts a virtual end marker when a condition is met, so that a temporary closing boundary is provided at the syntax tree level. Finally, differences between the front and rear incremental Markdown abstract syntax trees are calculated, and only interface nodes that have changed are locally updated. The method effectively avoids frequent interface refreshing and layout jittering while maintaining the real-time nature of streaming transmission, and significantly improves the rendering stability and user experience of an AI conversation page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer data processing, specifically to an AI dialogue page display method and system based on Markdown format text stream transmission. Background Technology

[0002] With the widespread deployment of large-scale language models on mobile terminals and web applications, natural language-based human-computer interaction has become the mainstream form of intelligent applications. To improve the fluency and real-time performance of dialogue, existing AI dialogue systems generally adopt text streaming technology. This technology pushes the text content generated by the model to the client in incremental data (such as token streams) through the server, and the client displays it synchronously during the reception process, thereby significantly reducing user waiting time and optimizing the interactive experience.

[0003] To further enhance the readability and structured presentation of AI responses, servers typically output text in Markdown format. As a lightweight markup language, Markdown uses concise syntax to clearly define the document's hierarchy and format, facilitating the rendering of well-formatted visuals on the client side.

[0004] At the implementation level, the server typically uses technologies such as server-sent events, WebSocket, or HTTP-based long connections to continuously send text streams to the client. After receiving the streaming data, the client needs to complete three key steps: appending the arriving text fragments to the current conversation message; parsing the accumulated text using Markdown to convert it into structured display nodes; and finally mapping the parsing results to specific user interface elements and rendering them.

[0005] However, traditional Markdown parsing and rendering schemes typically rely on a fundamental premise: that the text content to be processed is complete and intact. This approach assumes that the entire Markdown text is acquired at the start of parsing, followed by a one-time syntax analysis and format conversion, and then the final rendered result. This "complete first, then parsed" approach performs well in static content processing but is not suitable for the streaming characteristics of AI dialogue scenarios.

[0006] During streaming, Markdown text arrives at the client in fragmented, incremental chunks. This means that at any given moment, the client may only possess a portion of the content, and its Markdown syntax structure is often in an unclosed or incomplete state. For example, a code block might only receive the start marker "``" but lack the end marker; bold text might only have the start symbol "**" but no corresponding end symbol; a list might only receive the first item, with subsequent items yet to be transmitted. If the traditional approach is used in such cases, waiting for the text to be fully received before parsing, real-time formatting cannot be achieved, thus losing the core advantage of streaming. If, in pursuit of real-time performance, all existing content is completely re-parsed and rendered after each incremental text reception, it introduces enormous computational overhead and easily leads to frequent interface refreshes, layout flickering, and formatting jitter, severely impacting the stability of the user experience.

[0007] Therefore, in the specific scenario of AI dialogue, how to design a method that can parse and display Markdown text that arrives in streams and whose structure may not be complete has become a practical problem that urgently needs to be solved in the current technology field. Summary of the Invention

[0008] The purpose of this invention is to provide an AI dialogue page display method and system based on Markdown format text stream transmission, which aims to overcome the above-mentioned problems existing in the prior art.

[0009] To achieve the objective, the present invention provides the following technical solution: A method for displaying an AI dialogue page based on Markdown format text stream transmission, the method comprising the following steps: Step S1: The client receives the Markdown text stream output by the server and stores the newly added text fragments into the stream buffer; Step S2: Parse the newly added text fragment using Markdown syntax and convert it into an incremental Markdown structure unit; Step S3: Merge the incremental Markdown structural unit with the existing structural unit to construct and maintain the incremental Markdown abstract syntax tree; Step S4: Detect whether there is an unclosed Markdown structure in the incremental Markdown abstract syntax tree; Step S5: If there is an unclosed Markdown structure, it is temporarily completed according to the preset completion rules or the prediction closure algorithm, and a virtual end mark is inserted when the preset trigger condition is met to provide a temporary structure closure boundary, and the completed incremental Markdown abstract syntax tree is generated. Step S6: Using the completed incremental Markdown abstract syntax tree as the target state, calculate the difference between it and the previously rendered incremental Markdown abstract syntax tree, generate corresponding user interface node update instructions, and only perform partial updates on the nodes that have changed to complete the page display.

[0010] Furthermore, in step S3, constructing and maintaining the incremental Markdown abstract syntax tree specifically includes: updating only the local nodes affected by the newly added text fragments, while leaving the unaffected nodes unchanged.

[0011] Furthermore, in step S4, detecting unclosed Markdown structures specifically includes: Identify whether a multi-line code block contains only a start marker and no end marker; Identify whether inline emphasis contains only a start marker and no end marker; Identify whether inline code contains only a start backtick and no end backtick; Identify whether the list structure contains only the first item and no subsequent items.

[0012] Furthermore, the detection of unclosed Markdown structures in step S4 is achieved by traversing the nodes of the incremental Markdown abstract syntax tree; and determining the completeness of the corresponding Markdown syntax structure based on the node's type label and structural attributes.

[0013] Furthermore, in step S5, temporarily completing the unclosed Markdown structure according to the preset completion rules specifically includes: if the unclosed structure is a multi-line code block, a virtual end marker is temporarily added to the end of the current code block, and the code block is rendered as a complete structure; if the unclosed structure is inline emphasis or inline code, the current text is visually displayed as a closed structure; if the unclosed structure is a list, the received list items are rendered in a normalized manner, and the unreached list items are not displayed in advance; if a real end marker is received subsequently, the virtual end marker is replaced with a real end marker.

[0014] Furthermore, the prediction closure algorithm in step S5 is triggered to execute when at least one of the following conditions is met: (1) No new text fragments were received within the preset time window; (2) No new Markdown structure start tags were introduced in the continuously received text segments; (3) The nesting depth or text span of an unclosed structure exceeds a preset threshold; The prediction closure algorithm is based on the currently received text sequence and the incremental Markdown abstract syntax tree state. It enumerates and evaluates multiple closure schemes, and selects the closure scheme with the lowest overall interface stability cost as the prediction result for completion.

[0015] Furthermore, the triggering conditions for inserting the virtual end marker in step S5 include at least one of the following: (1) The streaming output enters a silent state within a preset time; (2) The currently received text sequence shows a tendency to end semantically; (3) The predictive closure algorithm cannot generate a better structural closure scheme in the current context; When a real text fragment or real end marker is subsequently received, if it does not conform to the boundary assumed by the virtual end marker, the previously inserted virtual end marker and its corresponding temporary structure are removed or replaced, and incremental parsing continues from the corresponding position.

[0016] Furthermore, the local update in step S6 specifically includes: dividing the nodes of the incremental Markdown abstract syntax tree into structural nodes and content nodes; wherein, structural nodes correspond to container units that determine the document flow layout, and content nodes correspond to the specific content and inline styles inside the structural nodes; when an update occurs, the smallest affected structural node is first located, and the update scope is restricted to that node and its subtrees.

[0017] Compared with the prior art, the present invention has the following advantages: Firstly, by constructing and maintaining an incremental Markdown abstract syntax tree, only local nodes affected by newly added text are updated each time, avoiding full parsing and rendering, significantly reducing computational overhead and improving response efficiency.

[0018] Secondly, an unclosed structure detection mechanism is introduced, which can identify incomplete structures such as multi-line code blocks, inline emphasis, inline code, and lists in real time, providing an accurate basis for subsequent intelligent completion.

[0019] Third, the system uses preset completion rules and predictive closure algorithms to temporarily complete unclosed structures, and combines a virtual end marker mechanism to provide temporary closure boundaries, so that the visually complete layout effect can still be presented during streaming transmission, enhancing real-time readability.

[0020] Fourth, when the streaming output is silent or the semantics end, a virtual end marker is actively inserted to achieve phased structural closure. When the real content is received, the marker can be flexibly replaced or removed to ensure that the parsing result is consistent with the real content.

[0021] Fifth, by using a difference comparison method, only the nodes that have changed in the completed incremental Markdown abstract syntax tree are updated locally, minimizing DOM operations and layout rearrangement, effectively preventing interface flickering and jumping, and ensuring a smooth and stable rendering process.

[0022] Sixth, the incremental Markdown abstract syntax tree nodes are divided into structure nodes and content nodes, and the smallest affected structure node is located during the update, limiting the scope of change to its subtree, thereby further improving update accuracy and rendering performance. Attached Figure Description

[0023] Figure 1 This is a simplified flowchart of the AI ​​dialogue page display method based on Markdown format text stream transmission according to the present invention.

[0024] Figure 2 This is a simplified structural block diagram of the system of the present invention. Detailed Implementation

[0025] Specific embodiments of the present invention will now be described with reference to the accompanying drawings. Many details are described below to provide a comprehensive understanding of the invention; however, those skilled in the art will be able to implement the invention without these details.

[0026] like Figure 1 and Figure 2 As shown, an AI dialogue page display method based on Markdown format text stream transmission is mainly implemented in the client, and it specifically includes the following steps: Step S1: The client receives the Markdown text stream output by the server and stores the newly added text fragments into the stream buffer.

[0027] Preferably, the aforementioned client includes mobile terminal applications running iOS or Android operating systems. The client continuously receives Markdown text stream data output by the server in a streaming manner by establishing a persistent communication link with the server. This design ensures that text content can be pushed from the server to the client in a low-latency, incremental manner, providing a data foundation for subsequent real-time parsing and rendering, while maintaining decoupling from specific client platforms and network transmission technologies.

[0028] Preferably, the aforementioned stream buffer is organized using a message-level isolation design. Specifically, the client allocates an independent buffer instance in memory for each individual AI response, storing all streaming text fragments corresponding to that response in sequence. This message-based isolation buffering mechanism ensures that the parsing, status detection, and rendering processes of each message are logically independent, avoiding interference or cross-parsing of text fragments between different responses, thus more accurately supporting incremental updates and partial rendering. When a new response begins, the client dynamically creates a corresponding new buffer; when the transmission of that response ends, its corresponding buffer can be entirely reclaimed or marked as complete. This design not only facilitates efficient resource management but also provides a convenient data structure foundation for subsequent message-level rollback, editing, or re-rendering.

[0029] Step S2: Parse the newly added text fragment using Markdown syntax and convert it into an incremental Markdown structure unit.

[0030] The Markdown syntax parsing in step S2 above refers to performing lexical analysis and structure extraction on the newly added text fragments to identify Markdown syntax elements with specific semantics. Specific identification includes, but is not limited to, the following typical structures: Heading structure: Begins with one or more hash characters, followed by a space and the text content. For example, "#text".

[0031] List structure: rows that begin with a hyphen, an asterisk, or a number followed by a period, and their nesting level is determined; for example, "-text".

[0032] Inline emphasis structure: Text segments enclosed by two consecutive asterisks or a single asterisk correspond to bold and italic styles, respectively. For example, “*text” or “**text”.

[0033] Code structure: This includes inline code snippets enclosed in backticks, and multi-line code blocks that begin with three consecutive backticks and may contain language identifiers. For example, multi-line code blocks that begin with "`code`" or "``language".

[0034] Other structured elements include: reference blocks starting with a greater than sign, separators consisting of three consecutive hyphens or asterisks, and tables consisting of vertical lines and hyphens.

[0035] The output of the Markdown syntax parsing process described above, namely the incremental Markdown structural unit, is a data object with a type identifier, text content, starting position, and possible attributes (such as heading level, list number, and code language). These incremental Markdown structural units are the basic atoms for subsequent construction and updating of the incremental Markdown abstract syntax tree (AST), ensuring efficient and accurate conversion from raw text stream to structured representation.

[0036] Step S3: Merge the incremental Markdown structural unit with the existing structural unit to construct and maintain the incremental Markdown abstract syntax tree.

[0037] In a specific embodiment of step S3, constructing and maintaining the incremental Markdown abstract syntax tree specifically includes updating only the local nodes affected by the newly added text fragments. Unaffected nodes remain unchanged, thereby reducing unnecessary re-rendering.

[0038] More specifically, the process of constructing and maintaining the incremental Markdown abstract syntax tree is implemented as a localized update mechanism based on the scope of node influence. The core of this mechanism is that when a new Markdown structural unit needs to be integrated into the existing incremental Markdown abstract syntax tree, the system first uses comparative analysis to precisely locate the smallest local subtree directly affected by the new unit in the tree structure. Update operations are limited to this local subtree, such as inserting new leaf nodes, updating the attributes of existing nodes, or adjusting the subtree structure. Simultaneously, all other nodes in the incremental Markdown abstract syntax tree outside this local subtree maintain their original state, including but not limited to their node type, content data, parent-child relationships, and corresponding rendering state in the user interface. This localized update and globally stable maintenance strategy avoids triggering the reconstruction and full rendering of the entire incremental Markdown abstract syntax tree due to the arrival of incremental text at the data structure level, thereby reducing unnecessary computation and user interface redrawing at the source. This is a key technological foundation for achieving efficient and stable streaming rendering.

[0039] Step S4: Detect whether there are any unclosed Markdown structures in the above incremental Markdown abstract syntax tree.

[0040] In a specific embodiment of step S4, the detection of unclosed structures in the incremental Markdown abstract syntax tree is achieved by traversing the nodes of the incremental Markdown abstract syntax tree; and determining the completeness of the corresponding Markdown syntax structure based on the node's type label and structural attributes.

[0041] Determining the completeness of Markdown syntax includes at least one of the following: (1) Identify whether a multi-line code block contains only a start marker and no end marker. For example, is there a case where there is only a start "```" but no matching end "```"?

[0042] (2) Identify whether inline emphasis (such as bold or italic) contains only a start mark and no end mark. For example, determine whether it contains only a start mark (such as "**" or "*") and lacks a paired end mark, resulting in the emphasis range not being closed.

[0043] (3) Identify whether the inline code contains only a start backtick and no end backtick. For example, determine whether it contains only a start backtick ("`") and no matching end backtick, so that the code snippet is not syntactically terminated.

[0044] (4) Identify whether the list structure contains only the first item and no subsequent items. For example, whether there are only the first item's child nodes and no expected subsequent items, thus making the list structure semantically incomplete.

[0045] Because the detection process is performed at the data level of the constructed incremental Markdown abstract syntax tree, focusing on the state and relationship of nodes in the incremental Markdown abstract syntax tree rather than directly performing lexical analysis on the original text, it ensures the hierarchy and accuracy of the detection and provides precise operation objects for subsequent intelligent completion.

[0046] Step S5: If there is an unclosed Markdown structure, it is temporarily completed according to the preset completion rules or the prediction closure algorithm, and a virtual end mark is inserted when the preset trigger condition is met to provide a temporary structural closure boundary, generating a completed incremental Markdown abstract syntax tree; wherein, the above virtual end mark can be replaced or removed when real content is received later.

[0047] In a specific embodiment of step S5, temporarily completing the unclosed Markdown structure according to the preset completion rules specifically includes: (1) If the unclosed structure is a multi-line code block, a virtual end marker is temporarily added to the end of the current code block, and the code block is rendered as a complete structure; (2) If the unclosed structure is inline emphasis or inline code, the current text will be displayed as a closed structure. (3) If the unclosed structure is a list, the received list items are rendered in a normalized manner, and the unreceived list items are not displayed in advance; (4) If a real end marker is received subsequently, the virtual end marker is replaced with the real end marker.

[0048] The virtual closing tag is a special node temporarily inserted into the incremental Markdown abstract syntax tree. It does not have any actual rendered content and is only used to mark a temporary closing boundary at the syntax tree level. During user interface rendering, this node does not generate any visible elements and does not affect layout calculations.

[0049] In a specific embodiment of step S5, the above-mentioned prediction closure algorithm predicts the closure position based on the type of the currently unclosed structure, the nesting depth, the length of the received text, and the contextual syntax rules, using rule matching and a lightweight statistical model. This prediction closure algorithm is triggered to execute when at least one of the following conditions is met: (1) No new text fragments were received within the preset time window; (2) The continuously received text segments are only punctuation marks or whitespace characters, and no new Markdown structure start mark is introduced; (3) The nesting depth or text span of the unclosed structure exceeds the preset threshold.

[0050] During the prediction closure process, the system enumerates multiple possible closure schemes for the currently unclosed structure (e.g., assuming an end marker for the currently unclosed bold structure at different positions such as after the next word, at the end of the sentence, or at the end of the paragraph). Subsequently, the system scores each closure scheme based on estimated interface stability cost indicators (e.g., how many subsequent real nodes would need to be re-parsed or moved if closure were to occur here, the size of the DOM tree changes that this update might trigger, or the area of ​​the expected layout reordering region, etc.), and finally selects the closure scheme with the lowest overall cost as the prediction result to drive subsequent local interface updates.

[0051] When a subsequent received real text fragment conflicts with the predicted closure result, the system only reconstructs the local subtree involved in the conflict, rather than rolling back the overall parsing result, thereby avoiding large-scale interface flickering.

[0052] In practical processing, the preset completion rules provide immediate and deterministic structural guarantees, while the predictive closure algorithm is activated under specific conditions to perform context-based intelligent inference and optimization of unclosed structures. The two completion strategies work together to achieve a streaming rendering effect that ranges from basic stability to intelligent optimization.

[0053] In addition, this method introduces a virtual end-of-line marker mechanism. Regardless of the completion strategy used, once the streaming output enters a silent state or the current text shows a semantic end tendency, the virtual end-of-line marker mechanism will be activated, actively inserting a virtual end-of-line marker to provide a phased closing boundary.

[0054] Specifically, the virtual end-of-time marker mechanism described above inserts a virtual end-of-time marker when any of the following preset trigger conditions are met: (1) The streaming output enters a silent state within a preset time; (2) The currently received text sequence shows a clear tendency toward semantic termination; (3) The predictive closure algorithm is unable to generate a better structural closure scheme in the current context.

[0055] When a virtual end-of-phase marker is inserted, the parsing engine treats it as a phase-end signal and performs a complete but rollback-capable incremental Markdown abstract syntax tree construction on the current content.

[0056] When a subsequent real text fragment or real end mark arrives, the system will determine whether the real output is consistent with the boundary assumed by the virtual end mark: if consistent, the current incremental Markdown abstract syntax tree state is directly confirmed; if inconsistent, the previously inserted virtual end mark and its corresponding temporary structure (e.g., virtual nodes introduced by the virtual end mark) are removed or replaced, and the real content is continued to be parsed incrementally from the corresponding position.

[0057] Step S6: Based on the completed incremental Markdown abstract syntax tree, by calculating the structural differences between it and the previously rendered incremental Markdown abstract syntax tree, determine the minimum set of user interface nodes that need to be updated, and perform local updates on these nodes to complete the page display.

[0058] In a specific embodiment of step S6, to ensure the efficiency and stability of interface updates, the system adopts a minimal difference update strategy based on node type partitioning, as follows: The system explicitly categorizes the nodes of the incremental Markdown abstract syntax tree into two types: structural nodes and content nodes. Structural nodes correspond to container units that determine the document flow layout, such as paragraphs, lists, code blocks, and quotation blocks. Changes to these nodes may trigger a layout reflow of their containing container and its sibling nodes. Content nodes correspond to the specific content and inline styles within structural nodes, such as text snippets, bold, italics, and inline code. Changes to these nodes typically only affect the rendering within their parent structural node and do not trigger higher-level layout calculations.

[0059] After generating the completed incremental Markdown abstract syntax tree, the system does not immediately map it to a completely new user interface node tree. Instead, it employs a differentiated update strategy. The core of this strategy lies in calculating the structural differences between the completed incremental Markdown abstract syntax tree (i.e., the new tree) and the previously rendered incremental Markdown abstract syntax tree (i.e., the old tree) corresponding to the current interface, thereby accurately identifying the specific location and type of change.

[0060] Based on the above difference analysis, the system implements local updates in the following way: First, the system traces and locates the innermost structural node affected by the change. This operation makes full use of the node type classification, aiming to converge the update scope from possible, fine-grained content node changes to the smallest structural node to which it belongs and can define the layout boundary. Subsequently, the system strictly restricts all interface update operations, including the addition, deletion, and attribute modification of nodes, to the smallest structural node located here and its subtree.

[0061] For example, when only one word in a paragraph is bolded, the system identifies the difference by comparing the old and new incremental Markdown abstract syntax trees. The difference lies in the style attribute change of a content node within that paragraph. The system then locates the smallest structural node containing this content node—the node representing the entire paragraph. The update operation is limited to the user interface subtree corresponding to this paragraph node, without triggering recalculation of adjacent paragraphs or outermost containers in the layout. This, in principle, ensures the locality of updates and the stability of the layout.

[0062] Preferably, before applying the calculated differences to specific interface update instructions, the system pre-assesses the layout changes that the update may cause. For example, it estimates the height changes of affected structural nodes after the update or their positional offsets in the document flow. If the estimated layout offset exceeds a preset threshold (for example, it may cause the content in the current user viewport to jump), the system takes stability protection measures, such as delaying structural updates, splitting update steps, or prioritizing the application of content attribute updates that do not affect the layout, to ensure the stability of the user window and the continuity of interaction to the greatest extent.

[0063] Finally, the system performs precise local updates to the user interface based on the minimized set of update instructions generated by the above method, thereby completing the page display efficiently and stably.

[0064] This method, through the collaborative work of the aforementioned preset completion rules, predictive closure algorithm, virtual end-of-line marker mechanism, and refined local update strategy based on incremental Markdown abstract syntax tree, effectively achieves a balance between real-time parsing, visual stability, and efficient rendering in streaming Markdown text transmission scenarios.

[0065] This invention also discloses an AI dialogue page display system based on Markdown format text stream transmission, used to implement the above method. The system includes: The stream receiving module is used to receive the Markdown text stream output by the server and store newly added text fragments into the stream buffer.

[0066] The Markdown fragment parsing module is used to parse the newly added text fragments using Markdown syntax and convert them into incremental Markdown structural units.

[0067] The Incremental Markdown Abstract Syntax Tree Management module is used to merge the above-mentioned incremental Markdown structural units with existing structural units, and to build and maintain the incremental Markdown abstract syntax tree.

[0068] The unclosed structure detection module is used to detect whether there are unclosed Markdown structures in the above incremental Markdown abstract syntax tree.

[0069] The intelligent completion rendering module is used to temporarily complete unclosed structures according to preset completion rules or predictive closure algorithms, and insert virtual end markers when preset trigger conditions are met, generating a completed incremental Markdown abstract syntax tree.

[0070] The user interface rendering module is used to map the completed incremental Markdown abstract syntax tree to a user interface node tree, and only perform local updates on the nodes that have changed.

[0071] The above are merely specific embodiments of the present invention, but the design concept of the present invention is not limited thereto. Any non-substantial modifications made to the present invention using this concept shall be considered as infringing upon the protection scope of the present invention.

Claims

1. A method for displaying AI dialogue pages based on Markdown format text stream transmission, characterized in that: The method includes the following steps: Step S1: The client receives the Markdown text stream output by the server and stores the newly added text fragments into the stream buffer; Step S2: Parse the newly added text fragment using Markdown syntax and convert it into an incremental Markdown structure unit; Step S3: Merge the incremental Markdown structural unit with the existing structural unit to construct and maintain the incremental Markdown abstract syntax tree; Step S4: Detect whether there is an unclosed Markdown structure in the incremental Markdown abstract syntax tree; Step S5: If there is an unclosed Markdown structure, it is temporarily completed according to the preset completion rules or the prediction closure algorithm, and a virtual end mark is inserted when the preset trigger condition is met to provide a temporary structure closure boundary, and the completed incremental Markdown abstract syntax tree is generated. Step S6: Using the completed incremental Markdown abstract syntax tree as the target state, calculate the difference between it and the previously rendered incremental Markdown abstract syntax tree, generate corresponding user interface node update instructions, and only perform partial updates on the nodes that have changed to complete the page display.

2. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, In step S3, constructing and maintaining the incremental Markdown abstract syntax tree specifically includes updating only the local nodes affected by the newly added text fragments, while the unaffected nodes remain unchanged.

3. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, In step S4, detecting unclosed Markdown structures specifically includes: Identify whether a multi-line code block contains only a start marker and no end marker; Identify whether inline emphasis contains only a start marker and no end marker; Identify whether inline code contains only a start backtick and no end backtick; Identify whether the list structure contains only the first item and no subsequent items.

4. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 3, characterized in that, The detection of unclosed Markdown structures in step S4 is achieved by traversing the nodes of the incremental Markdown abstract syntax tree; and determining the completeness of the corresponding Markdown syntax structure based on the node's type label and structural attributes.

5. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, In step S5, temporarily completing the unclosed Markdown structure according to the preset completion rules specifically includes: if the unclosed structure is a multi-line code block, a virtual end marker is temporarily added to the end of the current code block, and the code block is rendered as a complete structure; if the unclosed structure is inline emphasis or inline code, the current text is visually displayed as a closed structure; if the unclosed structure is a list, the received list items are rendered in a normalized manner, and the unreached list items are not displayed in advance; if a real end marker is received later, the virtual end marker is replaced with a real end marker.

6. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, The prediction closure algorithm in step S5 is triggered to execute when at least one of the following conditions is met: (1) No new text fragments were received within the preset time window; (2) No new Markdown structure start tags were introduced in the continuously received text segments; (3) The nesting depth or text span of an unclosed structure exceeds a preset threshold; The prediction closure algorithm is based on the currently received text sequence and the incremental Markdown abstract syntax tree state. It enumerates and evaluates multiple closure schemes, and selects the closure scheme with the lowest overall interface stability cost as the prediction result for completion.

7. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, The triggering conditions for inserting the virtual end marker in step S5 include at least one of the following: (1) The streaming output enters a silent state within a preset time; (2) The currently received text sequence shows a tendency to end semantically; (3) The predictive closure algorithm cannot generate a better structural closure scheme in the current context; When a real text fragment or real end marker is subsequently received, if it does not conform to the boundary assumed by the virtual end marker, the previously inserted virtual end marker and its corresponding temporary structure are removed or replaced, and incremental parsing continues from the corresponding position.

8. The AI ​​dialogue page display method based on Markdown format text stream transmission according to claim 1, characterized in that, The local update in step S6 specifically includes: dividing the nodes of the incremental Markdown abstract syntax tree into structural nodes and content nodes; wherein, structural nodes correspond to the container units that determine the document flow layout, and content nodes correspond to the specific content and inline styles inside the structural nodes; when an update occurs, the smallest affected structural node is first located, and the update scope is restricted to that node and its subtrees.

9. An AI dialogue page display system based on Markdown format text stream transmission, characterized in that, The system is used to implement the method as described in any one of claims 1-8, the system comprising: The stream receiving module is used to receive the Markdown text stream output by the server and store newly added text fragments into the stream buffer; The Markdown fragment parsing module is used to parse the newly added text fragments using Markdown syntax and convert them into incremental Markdown structure units. The incremental Markdown abstract syntax tree management module is used to merge the incremental Markdown structural units with existing structural units, and to construct and maintain the incremental Markdown abstract syntax tree. An unclosed structure detection module is used to detect whether there are unclosed Markdown structures in the incremental Markdown abstract syntax tree; The intelligent completion rendering module is used to temporarily complete unclosed structures according to preset completion rules or predicted closure algorithms, and insert virtual end markers when preset trigger conditions are met, generating a completed incremental Markdown abstract syntax tree; The user interface rendering module is used to map the completed incremental Markdown abstract syntax tree into a user interface node tree, and only perform local updates on the nodes that have changed.