Rich text data transmission method, electronic device and program product

By generating and transmitting structured rendering information, the problem of inconsistent rich text rendering caused by differences in the receiving end's support for Markdown format is solved, ensuring the accurate rendering of rich text data on different receiving ends.

CN120547231APending Publication Date: 2025-08-26KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510661315.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

Due to the different degree of support for Markdown format by different receivers, the default format of the receiver conflicts with the Markdown format used by the transmitter, resulting in the receiver's unmet text rendering based on Markdown format text.

Method used

By obtaining the plain text and rendering information of the rich text data to be transmitted, structured rendering information is generated, and plain text and structured rendering information are transmitted to the receiving end to ensure that the receiver can correctly parse and render the rich text.

Benefits of technology

The consistent analysis and presentation of rich text data on different receiving ends is realized, and the rendering does not meet expectations caused by differences in the support of Markdown format.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120547231A_ABST
    Figure CN120547231A_ABST
Patent Text Reader

Abstract

The invention provides a rich text data transmission method, electronic equipment and a program product. The rich text data transmission method comprises the steps of obtaining a plain text and rendering information of the plain text included in to-be-transmitted rich text data; obtaining rendering description data of the rendering information based on the plain text; generating structured rendering information based on the rendering description data; and transmitting the plain text and the structured rendering information to a receiving end to execute transmission of the rich text data to be transmitted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to technical fields such as communications, and in particular to a rich text data transmission method, electronic device, storage medium, and program product. Background Art

[0002] In today's highly developed era of digital information exchange, information transmission is ubiquitous. Whether in daily communications, document editing and sharing, web browsing, or mobile application interaction, accurate and efficient information transmission is crucial. Rich text data transmission plays a crucial role in these information transmission scenarios and is widely used in email, social media, e-books, document editing, and web pages.

[0003] In the prior art, after collecting rich text data including plain text and rendering information of the plain text, the sender usually embeds Markdown format tags corresponding to the rendering information in the plain text, obtains the Markdown format text, and sends the Markdown format text to the receiver, thereby realizing the transmission of rich text data.

[0004] However, since different receiving ends support the Markdown format to varying degrees, the receiving end's default format may conflict with the Markdown format used by the sending end, resulting in the receiving end not presenting rich text based on Markdown format text as expected. Summary of the Invention

[0005] The present disclosure provides a rich text data transmission method, electronic device, storage medium, and program product.

[0006] According to one aspect of the present disclosure, a method for transmitting rich text data is provided, comprising: Obtaining the plain text included in the rich text data to be transmitted and rendering information of the plain text; Acquire rendering description data of the rendering information based on the plain text; generating structured rendering information based on the rendering description data; The plain text and the structured rendering information are transmitted to a receiving end to perform transmission of the rich text data to be transmitted.

[0007] According to at least one embodiment of the rich text data transmission method of the present disclosure, the obtaining of rendering description data of the rendering information based on the plain text includes: Determining whether the rendering information includes rendering information of a non-text element; If not included, the rendering description data of the rendering information is obtained based on the plain text.

[0008] According to at least one embodiment of the rich text data transmission method of the present disclosure, if the rendering information includes rendering information of a non-text element, the acquiring rendering description data of the rendering information based on the plain text further includes: Obtaining the element tag and element position corresponding to the rendering information of the non-text element; embedding the element mark in the plain text according to the element position to obtain a marked text; Rendering description data of the rendering information is obtained based on the markup text.

[0009] According to the rich text data transmission method of at least one embodiment of the present disclosure, obtaining the element tag and element position corresponding to the rendering information of the non-text element includes: Obtaining an element type according to rendering information of the non-text element; The element tag is obtained according to the element type.

[0010] According to the rich text data transmission method of at least one embodiment of the present disclosure, the rendering description data includes: a starting rendering position, a rendering length, and a rendering style; When the rendering information includes rendering information related to a hyperlink, the rendering description data further includes: interactivity information and a link target of the hyperlink.

[0011] According to the rich text data transmission method of at least one embodiment of the present disclosure, the plain text and the structured rendering information are used to enable the receiving end to render the plain text based on the structured rendering information to obtain rich text.

[0012] According to at least one embodiment of the rich text data transmission method of the present disclosure, the obtaining of rendering description data of the rendering information based on the plain text includes: Verifying the plain text and / or the rendering information to obtain a verification result; When the verification result is verification passed, rendering description data of the rendering information is obtained based on the plain text.

[0013] According to at least one embodiment of the rich text data transmission method of the present disclosure, the transmitting of the plain text and the structured rendering information to the receiving end to perform the transmission of the rich text data to be transmitted includes: performing data transmission optimization on the plain text and the structured rendering information to obtain optimized information; The optimized information is transmitted to the receiving end to execute transmission of the rich text data to be transmitted.

[0014] According to at least one embodiment of the present disclosure, the rich text data transmission method further includes, after transmitting the plain text and the structured rendering information to the receiving end to transmit the rich text data to be transmitted: In response to the received update indication of the plain text and / or the rendering information, updating the plain text and / or the structured rendering information according to the update indication to obtain an updated plain text and / or updated structured rendering information; The updated plain text and / or updated structured rendering information is transmitted to a receiving end to execute an update on the to-be-transmitted rich text data.

[0015] According to the rich text data transmission method of at least one embodiment of the present disclosure, updating the plain text and / or structured rendering information according to the update indication includes: Obtaining an update policy related to the update instruction; The plain text and / or structured rendering information is updated according to the update instruction based on the update policy.

[0016] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the rich text data transmission method of any embodiment of the present disclosure.

[0017] According to another aspect of the present disclosure, a readable storage medium is provided, wherein the readable storage medium stores execution instructions, and when the execution instructions are executed by a processor, the execution instructions are used to implement the rich text data transmission method of any embodiment of the present disclosure.

[0018] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the rich text data transmission method according to any one of the embodiments of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0020] Figure 1 It is a schematic diagram of an application scenario of the rich text data transmission method according to an embodiment of the present disclosure.

[0021] Figure 2 This is a process of a rich text data transmission method according to an embodiment of the present disclosure. Figure 1 .

[0022] Figure 3 yes Figure 2 The process of the data acquisition method in the rich text data transmission method shown Figure 1 .

[0023] Figure 4 yes Figure 2 The process of the data acquisition method in the rich text data transmission method shown Figure 2 .

[0024] Figure 5 yes Figure 4 The flowchart of the mark acquisition method in the data acquisition method shown is shown.

[0025] Figure 6 yes Figure 2 The process of the data acquisition method in the rich text data transmission method shown Figure 3 .

[0026] Figure 7 yes Figure 2 The flowchart of the information sending method in the rich text data transmission method is shown.

[0027] Figure 8 This is a process of a rich text data transmission method according to an embodiment of the present disclosure. Figure 2 .

[0028] Figure 9 yes Figure 8 A flowchart of the information updating method in the rich text data transmission method is shown.

[0029] Figure 10 A schematic flowchart of a rich text data transmission method according to an embodiment of the present disclosure.

[0030] Figure 11 It is a schematic block diagram of the structure of a rich text data transmission device according to an embodiment of the present disclosure.

[0031] Figure 12 It is a schematic block diagram of the structure of an electronic device according to one embodiment of the present disclosure. DETAILED DESCRIPTION

[0032] The present disclosure is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are intended only to illustrate the relevant content and are not intended to limit the present disclosure. It should also be noted that, for ease of description, only the portions relevant to the present disclosure are shown in the accompanying drawings.

[0033] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0034] For example, if the sender uses the Markdown extended format that supports image size tags, custom emoticons, and other formats to format plain text, when the receiver only supports the basic Markdown format, the receiver cannot recognize the extended tags, and the image size tags may be ignored, causing the image to be displayed at its original size and possibly outside the screen; custom emoticons may be displayed as ordinary symbols, such as without color or icons, resulting in the receiver's rich text presentation based on Markdown formatted text not meeting expectations.

[0035] To this end, the present disclosure proposes a rich text data transmission method, electronic device, storage medium, and program product. The present disclosure can be implemented by rich text data transmission software installed on electronic devices such as mobile phones, tablet computers, computers, and servers.

[0036] Figure 1 The present invention illustrates an application scenario of a rich text data transmission method according to an embodiment of the present disclosure. This application scenario may include a transmitter 100 and a receiver 200. The transmitter 100 is connected to the receiver via a network. The transmitter 100 generates structured rendering information based on the rendering information and then sends the plain text and structured rendering information to the receiver 200. The receiver 200 receives the plain text and structured rendering information from the transmitter 100 and then renders the rich text based on this information.

[0037] For the convenience of description and to make the technical solutions of the specific embodiments of the present disclosure easier to understand, before describing the rich text data transmission method implemented by the present disclosure, the technical terms involved in the specific embodiments of the present disclosure are explained as follows: Plain text is a file that contains only text content and basic character encoding information. It does not contain any formatting, font, or color information, and only expresses content through basic text characters, spaces, line breaks, and other control characters.

[0038] Rich text is a type of text that contains formatting information. In addition to ordinary character content, it also includes text style, layout, images, tables, hyperlinks, colors, fonts, paragraph spacing and other information.

[0039] Rich text data refers to text data that contains not only plain text but also rendering information such as formatting information, style, structure, and multimedia elements.

[0040] Rendering information refers to the style description and formatting information required to convert plain text content into rich text content.

[0041] A hyperlink is an element created on the web or in a document that allows users to jump to another resource after clicking on it.

[0042] Figure 2FIG. 1 shows a schematic diagram of the overall process of a rich text data transmission method M100 according to an embodiment of the present disclosure. Figure 2 The rich text data transmission method shown includes steps S110 to S140. The rich text data transmission method can be executed by electronic devices such as mobile phones, computers, and servers.

[0043] Specifically, Figure 2 The rich text data transmission method shown includes: Step S110 : obtaining the plain text and the rendering information of the plain text included in the rich text data to be transmitted.

[0044] In some embodiments of the present disclosure, the plain text and rendering information obtained through step S110 may be information input by the user as needed. The plain text obtained through step S110 may only contain basic characters such as letters, numbers, and symbols, which are the most common elements in plain text; in particular, in order to better control the layout and presentation of the plain text, in addition to the above basic characters, the plain text may also include special characters such as line feed characters (such as \n or \r\n). Line feed characters are line end marks in plain text and can control how the text content is distributed between different lines. In addition to the above content, the content of the plain text may also contain other control characters, such as space characters for separating words and sentences, tab characters for controlling text indentation or alignment, and other control characters for text formatting or controlling text display (such as page feed characters / f, carriage return characters / r, etc.).

[0045] The rendering information obtained through step S110 is intended to ensure that the plain text content can be correctly displayed in different devices and environments. The rendering information is a set of formatting and typesetting instructions, and the function of the instructions is to standardize the rendering effect of the plain text. Specifically, the rendering information can indicate the rendering of the entire content of the plain text, or it can indicate the rendering of part of the content of the plain text. The rendering information can not only limit some basic style attributes, such as font, color, spacing, alignment, etc.; in addition, the rendering information can also limit complex typesetting rules such as hierarchical structure, dynamic interaction (such as hyperlinks, etc.), media (such as pictures, audio, video, etc.) embedding, table embedding, etc.

[0046] This rendering information can be expressed in text form. For example, you can instruct "Render XX text with XX color highlight," "Set XX text as a hyperlink," or "Insert media after XX text." This approach ensures that plain text is accurately presented in the expected format in different environments.

[0047] Step S120: Obtain rendering description data of the rendering information based on the plain text.

[0048] In some embodiments of the present disclosure, for each specific rendering instruction in the rendering information, step S120 may respectively obtain rendering description data of the plain text content pointed to by the rendering instruction.

[0049] The rendering description data obtained through step S120 may include a starting rendering position, a rendering length, and a rendering style. These three items are the core content of the rendering description data. The starting rendering position can be used to determine from which character or position in the plain text the rendering effect should be applied; the rendering length can be used to determine the number of characters or specific text range that needs to be rendered starting from the starting rendering position; and the rendering style can be used to determine in what format the text content is displayed. Common rendering styles include bold, italic, color, font, underline, etc.

[0050] In practice, the starting rendering position and rendering length are often expressed numerically to help accurately locate characters within the plain text. Specifically, to ensure accurate character positioning, a set of clear counting rules can be predefined, and the index position of characters within the plain text can be precisely located based on these counting rules.

[0051] For example, if a rendering instruction requests that the text "Hello" be bolded, the rendering description data obtained in step S120 should be the rendering description data corresponding to "Hello." If the H character in "Hello" is at the 90th character in the plain text, the starting rendering position obtained in step S120 is "90." Since "Hello" consists of 5 characters, the rendering length obtained in step S120 is "5." Since the rendering instruction requests bolding the text, the rendering style value obtained in step S120 is "bold."

[0052] When the three core rendering description data of starting rendering position, rendering length, and rendering style alone cannot accurately describe the rendering information, the rendering description data can be further expanded. In addition to the starting rendering position, rendering length, and rendering style, the rendering description data can also include additional fields such as additional information to supplement the content of the rendering description data, enhance the integrity of the rendering description data, and enable the rendering description data to accurately describe the rendering information. For example, additional information can be used to configure data related to click behaviors, such as Uniform Resource Locators (URLs), to support interactive behaviors such as hyperlink jumps. Through such expansion, the rendering description data can more comprehensively describe the rendering information, allowing the receiving end to accurately parse and restore the rich text format.

[0053] Step S130: generating structured rendering information based on the rendering description data.

[0054] In some embodiments of the present disclosure, the rendering description data can be converted into structured information for representation through step S130 to ensure the standardization, readability and parsability of the information. Organizing the rendering description data into structured rendering information through step S130 can generate structured rendering information one by one according to the rendering description data. It is also possible to prepare a template containing rendering fields in advance, pass the rendering description data into the template as a variable, obtain the filled template, and generate structured rendering information based on the filled template. In particular, after generating the structured rendering information through step S130, the structured rendering information can also be organized into a specific data structure, such as JSON, XML and other formats, for subsequent parsing and application.

[0055] When generating structured rendering information, "start" can be used to represent the starting rendering position, "length" can be used to represent the rendering length, and "class_names" can be used to represent the rendering style, which can be a combination of styles, such as bold, underline, color, etc.

[0056] For each rendering description data, step S130 can generate corresponding structured rendering information according to different rendering description data; in particular, in order to reduce redundancy and repetition and improve information processing and transmission efficiency, step S130 can also merge the contents in the rendering description data based on the starting rendering position, rendering length and rendering style (for example, several sub-data in the rendering description data that only have different rendering styles can be merged, or several consecutive sub-data with the same rendering style in the rendering description data can be merged, etc.), and then generate corresponding structured rendering information according to each merged rendering description data.

[0057] During the process of merging rendering description data, some rendering styles may conflict with each other (for example, a text segment is required to be in both red and blue fonts), or some styles may override other styles. When merging, you can determine which styles take priority, which styles can be overwritten or merged, etc., so that the receiving end can determine the final rendering effect based on priority.

[0058] After the merge is completed, the merge result can be further optimized, such as removing duplicate rendering description data, to ensure that the final generated structured rendering information is more concise and efficient, thereby improving the speed of parsing and application.

[0059] Step S140 : transmitting the plain text and the structured rendering information to the receiving end to execute the transmission of the rich text data to be transmitted.

[0060] In some embodiments of the present disclosure, step S140 can transmit the plain text and structured rendering information to the receiving end via HTTP requests, WebSocket communication, or a message queue (e.g., Kafka, RabbitMQ, or ActiveMQ), ensuring that the receiving end can correctly parse and restore the rich text data to render the rich text. Different transmission methods can be adaptively adopted for different application scenarios.

[0061] The rich text data transmission method provided by the present disclosure structures the rendering description data corresponding to the rendering information and sends it to the receiving end. Because the structured rendering information clearly specifies the rendering format of the text to be rendered in the plain text, it will not be affected by the default format of different receiving ends, and can ensure that all receiving ends have consistent interpretation of the same information. This rich text data transmission method solves the problem in the prior art that due to the different levels of support for the Markdown format by different receiving ends, the default format of the receiving end may conflict with the Markdown format used by the sending end, resulting in the receiving end not performing the expected rich text presentation based on Markdown format text.

[0062] Regarding step S120, in some embodiments of the present disclosure, it may include the following: Figure 3 Steps S121 to S122 are shown.

[0063] Step S121 : determining whether the rendering information includes rendering information of non-text elements.

[0064] In some embodiments of the present disclosure, step S121 is responsible for determining whether the rendering information contains content that is not in the form of text, such as audio, video, image, table, etc. The judgment basis of this step mainly includes the following methods: based on field judgment, for example, the rendering information may contain fields such as audio, video, image or table. If these fields are detected, it can be determined that the rendering information includes rendering information of non-text elements; based on identifier judgment, for example, the image identifier is , the audio identifier is <audio>, the video identifier is <video>, the table identifier is

[0065]

[0066]

[0067] Figure 4

[0068]

[0069] <audio>When the non-text element includes a video, the element tag obtained in step S123 can be <video> When the non-text element includes a table, the element tag obtained in step S123 can be< / video> < / audio> If the rendering information includes the above identifier, it can be determined that the rendering information includes rendering information of non-text elements; based on attribute judgment, for example, audio may include attributes such as src, controls, loop, video may include attributes such as muted, poster, autoplay, images may include attributes such as src, alt, width, height, and tables may include information such as rows, cols, cell, border, etc. If the rendering information includes the above content, it can be determined that the rendering information includes rendering information of non-text elements. When it is determined through step S121 that the rendering information does not include rendering information of non-text elements, step S122 is executed. Step S122 obtains rendering description data of the rendering information based on the plain text. Regarding step S120, in some embodiments of the present disclosure, when it is determined through step S121 that the rendering information includes rendering information of non-text elements, steps S123 to S125 as shown may also be included. Step S123 obtains the element tag and element position corresponding to the rendering information of the non-text element. In some embodiments of the present disclosure, the element tags and element positions obtained in step S123 can ensure that the non-text elements are correctly mapped and restored. The element tags in step S123 can be related to the specific content of the non-text elements. For example, when the non-text elements include images, the element tags obtained in step S123 can be; when the non-text elements include audio, the element tags obtained in step S123 can be

[0070]

[0071]

[0072]

[0073]

[0074]

[0075]

[0076]

[0077]

[0078] Figure 5

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086]

[0087] Figure 6

[0088]

[0089] Etc. The element tag can be used to take up place in the plain text to ensure the presence of the non-text element in the plain text; it can also help the receiving end to parse correctly, so that the receiving end can find the corresponding non-text element according to the element tag and render it. The element position obtained by step S123 can indicate where the non-text element is located in the plain text. The element position can ensure that the position of the non-text element in the plain text is traceable, which facilitates the correct parsing and rendering by the receiving end. Through the element tag and element position, it can be ensured that no matter how the receiving end parses, the non-text element can be correctly found and rendered, ensuring that the final display rendering effect meets expectations. Step S124, embed the element tag in the plain text according to the element position to obtain the marked text. In some embodiments of the present disclosure, the corresponding element tag can be directly inserted into the element position in the plain text through step S124; through step S124, a placeholder can also be used at the element position of the plain text, and then the placeholder can be replaced with the corresponding element tag. In particular, when the non-text element corresponding to the element tag needs to occupy a separate line, a line break can also be used at the element position to separate it. By embedding element tags within plain text, the location of non-text elements can be clearly indicated within the plain text, facilitating parsing and rendering at the receiving end. Step S125: Obtain rendering description data for the rendering information based on the tagged text. In some embodiments of the present disclosure, for rendering information of text elements within the rendering information, the process of obtaining rendering description data in step S125 is the same as step S122. For rendering information of non-text elements within the rendering information, the process of obtaining rendering description data in step S125 is similar to step S122, with the difference that, in addition to the starting rendering position, rendering length, and rendering style, the obtained rendering description data may also include information related to the specific content of the non-text element, such as the resource path (URL pointing to an image, audio, video, or table file), size information (applicable to images and videos), and control properties (applicable to audio and video). Steps S121 to S125 distinguish whether the rendering information includes rendering information for non-text elements, thereby determining the subsequent rendering strategy. These steps enable more accurate parsing of rendering information for text and non-text elements, improve the accuracy and flexibility of the rendering description data, and achieve more precise rendering control. Regarding step S123, in some embodiments of the present disclosure, it may include steps S1231 to S1232 as shown. Step S1231, obtaining the element type based on the rendering information of the non-text element. In some embodiments of the present disclosure, step S1231 may obtain the element type based on the fields, identifiers or attributes included in the rendering information of the non-text element; the element type obtained by step S1231 may include image type, audio type, video type, chart type, etc. By obtaining the element type, basic support can be provided for subsequent rendering, interaction and format control, thereby improving the parsing accuracy and rendering flexibility of non-text elements.Step S1232: Obtain an element tag based on the element type. In some embodiments of the present disclosure, a type-tag mapping table may be pre-set. Step S1232 obtains the element tag based on this mapping table to ensure that non-text elements can be represented in plain text, facilitating parsing and restoration. Determining the element tag based on the element type through steps S1231 and S1232 can improve the maintainability and compatibility of the rendering process. In some embodiments of the present disclosure, when it is desired to point certain content in plain text to other digital resources (such as web pages, files, images, videos, etc.), the content can be rendered as a hyperlink using rendering information. In this case, the rendering information may include hyperlink-related rendering information. This hyperlink-related rendering information indicates how the element corresponding to the hyperlink should be presented and how it should interact with the user, ensuring that the element is correctly rendered as a hyperlink. If the rendering information obtained in step S110 includes hyperlink-related rendering information, the rendering description data obtained based on the rendering information in step S120 may include, in addition to the starting rendering position, rendering length, and rendering style, the hyperlink's interactivity information and the link target, enabling the receiving end to replicate the expected effect. Interactivity information describes how users interact with hyperlinks and triggers related redirect behaviors, such as clicks and hovers. Link targets represent the target resource they point to, such as a webpage address, file path, or image link. In addition to the aforementioned information, the acquired rendering description data may also include behavior information (used to determine how the hyperlink redirects to the target content after being triggered), state information (used to apply different styles depending on whether the hyperlink has been triggered), and other information. This process enables the rich text data transmission method to be applied to hyperlink-related rendering information. In some embodiments of the present disclosure, the plain text and structured rendering information transmitted in step S140 are used to enable the receiving end to render the plain text based on the structured rendering information to generate rich text. The receiving end can accurately reproduce the rich text based on the plain text and structured rendering information, ensuring that the same plain text and rendering information are rendered consistently across different receiving ends, and that the layout and style do not vary due to different parsers. Regarding step S120, in some embodiments of the present disclosure, steps S126 and S127 may also be included as shown. Step S126 verifies the plain text and / or rendering information to obtain a verification result. In some embodiments of the present disclosure, regarding step S126, when verifying the plain text, the purpose of the verification is to ensure the integrity, correctness, security and parsability of the plain text, and to avoid potential errors and security risks such as illegal characters, data loss or security vulnerabilities; the verification of the plain text may include multiple levels of verification to ensure that the plain text can be correctly processed and rendered.The content of this verification may include but is not limited to the following aspects: character encoding check (used to ensure that the plain text conforms to the specified character encoding, prevent character garbled characters, and avoid parsing errors due to inconsistent encoding), special character check (used to check whether it includes disallowed characters, such as NULL characters, illegal control characters, etc., to avoid illegal characters interfering with text parsing), text integrity check (used to ensure that the text is not lost or truncated, to prevent data loss during transmission), security check (used to prevent script injection or directory traversal attacks, etc., to avoid the text containing <script>标签等恶意代码)、敏感词检测(用于审核是否包括违禁词或敏感词等,以确保内容符合合规要求)、空文本检查(用于防止传输空白内容(即纯文本为空或仅包含空格、换行符),确保数据有效性)。

[0090] 当对渲染信息进行验证时,该验证的目的是为了确保渲染格式正确、不会造成解析错误或渲染异常;对渲染信息进行的验证可以包括但不限于以下几个方面:检查渲染信息是否包括内容、位置、样式等必要字段,检查颜色值是否符合相应的格式(如#RRGGBB、rgba(255,0,0, 1)),检查字号等的范围是否合理(如10px≤font-size≤72px,防止极端值影响渲染),检查是否存在样式冲突(避免同一区域同时应用互斥样式(如bold和normal)或重复渲染(如同一字段文字重复应用相同的样式)),检查是否存在重叠冲突(确保不同渲染样式的应用范围不互相冲突)等。

[0091] 通过步骤S126得到的验证结果为验证未通过时,可以阻止纯文本和 / 或渲染信息流转到下一步骤,控制向用户发送错误反馈信息,通过该错误反馈信息可以返回错误代码、标记错误字段帮助用户快速定位问题,通过该错误反馈信息还可以向用户提供修改建议(如调整字号、修改非法字符等),使用户对导致验证未通过的内容进行适应性修改或重新提供。通过步骤S126得到的验证结果为验证通过时,执行步骤S127。

[0092] 步骤S127,基于纯文本获取渲染信息的渲染描述数据。

[0093] 步骤S126至步骤S127在纯文本和 / 或渲染信息验证通过时获取渲染描述数据,能够防止文本丢失或渲染错误,并确保信息传输安全,防止篡改和攻击。

[0094] 关于步骤S140,在本公开的一些实施方式中,可以包括如图7所示的步骤S141至步骤S142。

[0095] 步骤S141,对纯文本和结构化渲染信息进行数据传输优化,得到优化后信息。

[0096] 在本公开的一些实施方式中,步骤S141中数据传输优化指通过技术手段提高数据传输效率和质量的过程;步骤S141旨在优化纯文本和结构化渲染信息的传输方式,提高传输效率,减少数据体积,提升网络传输性能。由于纯文本和结构化渲染信息的特点不同,步骤S141可以分别对纯文本和结构化渲染信息采用不同的方式进行数据传输优化,最终将优化结果组合得到优化后信息。对于纯文本,步骤S141可以采用文本压缩(如无损压缩法等减少文本大小,提高传输速度)、分块传输(将文本拆分为多个小块进行传输,降低内存占用)、去除冗余字符(如删除多余的空格、换行符等,减少不必要的字符)等方法进行数据传输优化;对于结构化渲染信息,步骤S141可以采用高效数据格式(如将JSON结构转换为二进制格式,缩小数据体积,提高解析速度)、去重优化(合并相同结构化渲染信息,避免重复存储相同的结构化渲染信息)、采用短字段名(如将"start”字段优化为"s”、将"length”字段优化为"l”,将"class_names”字段优化为"c”等)等方法进行数据传输优化。

[0097] 步骤S142,向接收端传输优化后信息以执行对待传输富文本数据的传输。

[0098] 通过步骤S141对纯文本和结构化渲染信息进行数据传输优化后通过步骤S142传输,能够在保证数据完整性和一致性的前提下,减少传输数据量,提高接收端的渲染和解析效率。

[0099] 进一步地,本公开提供的富文本数据传输方法,在步骤S140之后,还可以包括如图8所示的步骤S150至步骤S160。

[0100] 步骤S150,响应于接收到的纯文本和 / 或渲染信息的更新指示,根据更新指示更新纯文本和 / 或结构化渲染信息,得到更新后的纯文本和 / 或更新后的结构化渲染信息。

[0101] 在本公开的一些实施方式中,用户感觉渲染效果不符合预期,可以通过更新指示控制更新渲染信息;用户需要丰富纯文本的内容或对纯文本进行适应性调整时,可以通过更新指示控制更新纯文本。发送端接收到更新指示时,可以首先对该更新指示进行分析,获取更新指示对应的更新内容,更新内容可以包括更新某段文字内容、删除某些文本或者添加新内容,更新内容也可以包括更新某个文本片段的字体、颜色或位置等;然后根据更新内容对纯文本和 / 渲染信息进行更新,得到更新后信息;最后根据更新后信息生成更新后结构化信息。对于纯文本来说,其更新指示一般指示对纯文本进行调整,如文本的修改、替换、删除或插入等;对于渲染信息来说,其更新指示一般指示对渲染信息进行调整,如更新某个文本片段的字体、颜色或位置等。通过上述过程生成的更新后结构化信息可以为全量信息。

[0102] 特别地,为了提升富文本数据的传输效率,特别是当更新内容较少时,通过步骤S150得到的更新后结构化信息还可以为增量信息,即获取更新内容后,基于更新内容获取增量信息后根据增量信息生成更新后结构化信息。相较于全量信息,增量信息能显著减少传输的数据量。

[0103] 步骤S160,向接收端传输更新后的纯文本和 / 或更新后的结构化渲染信息以执行对待传输富文本数据的更新。

[0104] 通过步骤S150至步骤S160在发送结构化渲染信息后基于更新指示更新对应的信息,能够提高信息的一致性和完整性。

[0105] 关于步骤S150,在本公开的一些实施方式中,可以包括如图9所示的步骤S151至步骤S152。

[0106] 步骤S151,获取更新指示相关的更新策略。

[0107] 在本公开的一些实施方式中,更新指示可以指示整段替换、局部修改、内容追加、内容删除、样式更改等。对于不同的更新指示,可以设置不同的更新策略,以优化信息的处理和传输效率;例如,对于整段替换可以将更新策略设置为覆盖式更新;对于局部修改可以将更新策略设置为增量式更新;对于内容追加可以将更新策略设置为追加式更新;对于内容删除可以将更新策略设置为删除式更新等。

[0108] 步骤S152,基于更新策略根据更新指示更新纯文本和 / 或结构化渲染信息。

[0109] 步骤S151至步骤S152基于不同的更新指示精准控制更新策略,能够确保在更新过程中确保更加精准、灵活地处理和传输数据,从而进一步提升传输和解析效率,减少不必要的全量更新。

[0110] 本公开提供的富文本数据传输方法,可以用于需要跨平台、跨终端、保持格式一致性的各种领域,例如文档编辑、新闻发布、即时通讯、法律与政务、医疗与学术、电商与广告、游戏与虚拟世界、物联网与智能设备等领域。

[0111] 图10示出了基于本公开的富文本数据传输方法实现的示例性流程图。

[0112] 图10示出的流程图中,以房产估值场景为例,该富文本数据传输过程可以包括:步骤S210,获取待传输富文本数据包括的纯文本和纯文本的渲染信息。

[0113] 在本公开的一些实施方式中,通过步骤S210获取的纯文本和渲染信息可以是由用户根据需要输入的。

[0114] 在房产估值场景中,以通过步骤S210获取的纯文本内容如下为例:当前估价主要参考了以下因素:\n您的小区XX城3居室近期成交房源的情况;\n您的小区XX城及所在商圈的行情趋势;\n近一年趋势可见小区行情播报。

[0115] 上述纯文本中\n表示换行。

[0116] 通过步骤S210获取的渲染信息可以包括:将"近期成交房源”红色高亮;"您的小区XX城及所在商圈的行情趋势”下通过XX图片渲染;将"小区行情播报”设置为超链接。

[0117] 步骤S220,判断渲染信息是否包括非文本元素的渲染信息。

[0118] 在本公开的一些实施方式中,由于通过步骤S210获取的渲染信息中包括图片渲染相关的信息,而图片是非文本元素的一种,因此通过步骤S220可以确定渲染信息包括非文本元素的渲染信息。

[0119] 步骤S230,获取非文本元素的渲染信息相应的元素标记和元素位置。

[0120] 在本公开的一些实施方式中,由于非文本元素的渲染信息为图片渲染,因此通过步骤S230获取的非文本元素的渲染信息相应的元素标记可以为<image>;通过步骤S230获取的元素位置为55之后(55代表字符位置)。

[0121] 步骤S240,根据元素位置在纯文本中嵌入元素标记,得到标记文本。

[0122] 在本公开的一些实施方式,通过步骤S240嵌入元素标记后,得到的标记文本如下:当前估价主要参考了以下因素:\n您的小区XX城3居室近期成交房源的情况;\n您的小区XX城及所在商圈的行情趋势;\n<image>\n近一年趋势可见小区行情播报。

[0123] 步骤S250,基于标记文本获取渲染信息的渲染描述数据。

[0124] 在本公开的一些实施方式中,对于"将"近期成交房源”红色高亮”渲染信息,通过步骤S250获取的渲染描述数据可以包括:起始渲染位置26,渲染长度6,渲染样式redhighlight。

[0125] 对于""您的小区XX城及所在商圈的行情趋势”下通过XX图片渲染”,通过步骤S250获取的渲染描述数据可以包括:起始渲染位置56,渲染长度7,渲染样式imagereplace,附加信息http: / / XXXXX.com。

[0126] 对于"将"小区行情播报”设置为超链接”,通过步骤S250获取的渲染描述数据可以包括:起始渲染位置70,渲染长度6,渲染样式bluelink,附加信息type:click、URL:http: / / www.XXXXX.com。

[0127] 步骤S260,基于渲染描述数据生成结构化渲染信息。

[0128] 在本公开的一些实施方式中,步骤S260可以基于模板根据渲染描述数据生成结构化渲染信息,该模板可以如下:[{"start":   "length":   "class_names": }{"start":   "length":   "class_names":   "extra": }]基于上述模板生成的结构化渲染信息可以为:[{"start":26,   "length":6,   "class_names":["redhighlight"] }{"start":56,   "length":7,   "class_names":["imagereplace"]   "extra":{"http: / / XXXXX.com"} }{"start":70,   "length":6,   "class_names":["bluelink"]   "extra":{"type":"click","URL":"http: / / www.XXXXX.com"} }]步骤S270,向接收端传输纯文本和结构化渲染信息以执行对待传输富文本数据的传输。

[0129] 基于上述任一个实施方式,本公开还提供了一种富文本数据传输装置。

[0130] 图11是本公开的一个实施方式的富文本数据传输装置的结构示意框图。

[0131] 如图11所示,该富文本数据传输装置包括:信息获取模块110,用于获取待传输富文本数据包括的纯文本和纯文本的渲染信息。

[0132] 数据获取模块120,用于基于纯文本获取渲染信息的渲染描述数据。

[0133] 数据结构化模块130,用于基于渲染描述数据生成结构化渲染信息。

[0134] 信息传输模块140,用于向接收端传输纯文本和结构化渲染信息以执行对待传输富文本数据的传输。

[0135] 上述富文本数据传输装置可以是计算机软件的形式,上述富文本数据传输装置的各个模块可以通过计算机软件模块实现。

[0136] 上述装置中各个模块的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。

[0137] 本公开具体实施方式中的富文本数据传输方法的执行主体,可以是手机、计算机、服务器等电子设备。

[0138] 因此,基于上述任一个实施方式,本公开还提供了一种电子设备,该电子设备可以执行本公开上文描述的任一个实施方式的富文本数据传输方法。

[0139] 图12是本公开的一个实施方式的电子设备1000的结构示意框图。

[0140] 电子设备1000的硬件结构可以利用总线架构来实现。总线架构可以包括任何数量的互连总线和桥接器,这取决于硬件的特定应用和总体设计约束。总线1100将包括一个或多个处理器1200、存储器1300和 / 或硬件模块的各种电路连接到一起。总线1100还可以将诸如外围设备、电压调节器、功率管理电路、外部天线等的各种其他电路1400连接。

[0141] 总线1100可以是工业标准体系结构(ISA,Industry Standard Architecture)总线、外部设备互连(PCI,Peripheral Component)总线或扩展工业标准体系结构(EISA,Extended Industry Standard Component)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,该图中仅用一条连接线表示,但并不表示仅有一根总线或一种类型的总线。

[0142] 本公开还提供了一种可读存储介质,可读存储介质中存储有计算机程序,计算机程序被处理器执行时用于实现上述的方法。"可读存储介质”可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。可读存储介质的更具体的示例包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式只读存储器(CDROM)等。

[0143] 本公开还提供了一种计算机程序产品,本公开的方法可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机程序或指令。加载和执行所述计算机程序或指令时,全部或部分地执行本公开的流程或功能。

[0144] 计算机程序或指令可以存储在可读存储介质中,或者从一个可读存储介质向另一个可读存储介质传输,例如,所述计算机程序或指令可以从一个网站站点、计算机、服务器或数据中心通过有线或无线方式向另一个网站站点、计算机、服务器或数据中心进行传输。可读存储介质可以是能够存取的任何可用介质或者是集成一个或多个可用介质的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,例如,软盘、硬盘、磁带;也可以是光介质,例如,数字视频光盘;还可以是半导体介质,例如,固态硬盘。该计算机可读存储介质可以是易失性或非易失性存储介质,或可包括易失性和非易失性两种类型的存储介质。

[0145] 本领域内的技术人员应明白,本公开的实施例可提供为方法、系统、或计算机程序产品。因此,本公开可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本公开可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。

[0146] 本公开是参照根据本公开的方法、设备(系统)、和计算机程序产品的流程图和 / 或方框图来描述的。应理解可由计算机程序指令实现流程图和 / 或方框图中的每一流程和 / 或方框、以及流程图和 / 或方框图中的流程和 / 或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和 / 或方框图一个方框或多个方框中指定的功能的装置。

[0147] 这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和 / 或方框图一个方框或多个方框中指定的功能。

[0148] 这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和 / 或方框图一个方框或多个方框中指定的功能的步骤。

[0149] 在本说明书的描述中,参考术语"一个实施例 / 方式”、"一些实施例 / 方式”、"示例”、"具体示例”、或"一些示例”等的描述意指结合该实施例 / 方式或示例描述的具体特征、结构、或者特点包含于本公开的至少一个实施例 / 方式或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例 / 方式或示例。而且,描述的具体特征、结构、或者特点可以在任一个或多个实施例 / 方式或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例 / 方式或示例以及不同实施例 / 方式或示例的特征进行结合和组合。

[0150] 此外,术语"第一”、"第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有"第一”、"第二”的特征可以明示或者隐含地包括至少一个该特征。在本公开的描述中,"多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。

[0151] 本领域的技术人员应当理解,上述实施方式仅仅是为了清楚地说明本公开,而并非是对本公开的范围进行限定。对于所属领域的技术人员而言,在上述公开的基础上还可以做出其它变化或变型,并且这些变化或变型仍处于本公开的范围内。< / script> < / video> < / audio>

Claims

1. A rich text data transmission method, characterized in that: include: Obtaining the plain text included in the rich text data to be transmitted and rendering information of the plain text; Acquire rendering description data of the rendering information based on the plain text; generating structured rendering information based on the rendering description data; as well as The plain text and the structured rendering information are transmitted to a receiving end to perform transmission of the rich text data to be transmitted.

2. The rich text data transmission method according to claim 1, characterized in that: The obtaining of rendering description data of the rendering information based on the plain text includes: Determining whether the rendering information includes rendering information of a non-text element; and If not included, the rendering description data of the rendering information is obtained based on the plain text.

3. The rich text data transmission method according to claim 2, characterized in that: If the rendering information includes rendering information of a non-text element, the acquiring of rendering description data of the rendering information based on the plain text further includes: Obtaining the element tag and element position corresponding to the rendering information of the non-text element; Embed the element tag in the plain text according to the element position to obtain a marked text; and Rendering description data of the rendering information is obtained based on the markup text.

4. The rich text data transmission method according to claim 3, characterized in that: The obtaining of the element tag and element position corresponding to the rendering information of the non-text element includes: Obtaining an element type according to the rendering information of the non-text element; and The element tag is obtained according to the element type.

5. The rich text data transmission method according to claim 1, characterized in that: The rendering description data includes: starting rendering position, rendering length and rendering style; When the rendering information includes rendering information related to a hyperlink, the rendering description data further includes: interactivity information and a link target of the hyperlink.

6. The rich text data transmission method according to any one of claims 1 to 5, characterized in that: The plain text and the structured rendering information are used to enable the receiving end to render the plain text based on the structured rendering information to obtain rich text.

7. The rich text data transmission method according to any one of claims 1 to 5, characterized in that: The obtaining of rendering description data of the rendering information based on the plain text includes: Verifying the plain text and / or the rendering information to obtain a verification result; and When the verification result is verification passed, rendering description data of the rendering information is obtained based on the plain text.

8. The rich text data transmission method according to any one of claims 1 to 5, characterized in that: The transmitting the plain text and the structured rendering information to the receiving end to perform transmission of the rich text data to be transmitted includes: performing data transmission optimization on the plain text and the structured rendering information to obtain optimized information; and The optimized information is transmitted to the receiving end to execute transmission of the rich text data to be transmitted.

9. An electronic device, characterized in that: include: a memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the rich text data transmission method according to any one of claims 1 to 8.

10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the rich text data transmission method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • AI interactive element real-time rendering and back-end collaboration methods, systems, devices and program products

    CN121704839A