Rich text rendering method, device, terminal equipment and computer storage medium
By dividing rich text content and using different view components, the problem of skipping non-text content in rich text rendering in Android system is solved, achieving faster rendering speed and better page display effect.
Patent Information
- Application Number
- CN201910220204.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-03-22
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2039-03-22
AI Technical Summary
When rendering rich text in HTML format in Android system, non-text content such as pictures, videos or tables is skipped by default, resulting in rendering failure. The existing technology renders the rendering process slower through WebView rendering, affecting the page display speed.
By dividing rich text content, multiple text blocks are determined and carried by different view components, each text block is rendered as a separate module, and then the rendering result is encapsulated to achieve rendering.
Improve rendering speed, avoid the problem of slow rendering speed caused by using WebView to render all content, and improve page display speed.
Smart Images

Figure CN111724453B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a rich text rendering method, apparatus, terminal equipment and computer storage medium. Background Art
[0002] Usually, when rendering rich text in HTML format in Android system, since rich text includes not only text content but also pictures, videos or tables, etc., when it is carried by view component textview, non-text content such as pictures, videos or tables will be skipped by default, resulting in failure of rendering and a space. Therefore, when rendering, most of the rich texts are carried by view component webview for rendering.
[0003] However, when using WebView for rendering, it is necessary to load page resources with rich text content, and then perform rendering processing based on the loaded page resources to obtain and output the rendering results of the rich text, which results in a slow rendering process and a slow display speed of the page. Summary of the invention
[0004] In view of this, embodiments of the present invention provide a rich text rendering method, apparatus, terminal device and computer storage medium to solve the above problems.
[0005] According to a first aspect of an embodiment of the present invention, a rich text rendering method is provided, which includes: dividing rich text content, determining multiple text blocks and view components respectively used to carry each text block, wherein the view components carrying two adjacent text blocks are different; encapsulating the multiple view components after carrying the text blocks to render the rich text content.
[0006] According to a second aspect of an embodiment of the present invention, a rich text rendering device is provided, which includes: a text block determination module, used to divide rich text content, determine multiple text blocks and view components respectively used to carry each text block, wherein the view components carrying two adjacent text blocks are different; an encapsulation module, used to encapsulate multiple view components after carrying the text blocks, so as to render the rich text content.
[0007] According to a third aspect of an embodiment of the present invention, there is provided a terminal device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the rich text rendering method as described above.
[0008] According to a fourth aspect of an embodiment of the present invention, a computer storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the rich text rendering method as described above is implemented.
[0009] According to the solution provided by an embodiment of the present invention, by dividing the rich text content, multiple text blocks and view components respectively used to carry each text block are determined, and then the multiple view components carrying the text blocks are encapsulated to render the rich text content, so that each text block can be rendered as a separate module, and then encapsulated to obtain the rendering of the rich text content after rendering, and then native components can be used to carry part of the rich text content during rendering, thereby improving the rendering speed and avoiding the problem of slow rendering speed caused by using webview to render all rich text content in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0011] Figure 1 This is a flowchart of a rich text rendering method according to the first embodiment of the present invention;
[0012] Figure 2 This is a flowchart of a rich text rendering method according to the second embodiment of the present invention;
[0013] Figure 3 This is a schematic diagram of an interface of Embodiment 2 of the present invention;
[0014] Figure 4 This is a structural block diagram of a rich text rendering device according to Embodiment 3 of the present invention;
[0015] Figure 5 This is a schematic diagram of the structure of a terminal device according to Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0016] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0017] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0018] Embodiment 1
[0019] Reference Figure 1 , shows a step flow chart of a rich text rendering method according to embodiment 1 of the present invention.
[0020] The method of this embodiment includes the following steps:
[0021] S102: Divide the rich text content to determine a plurality of text blocks and a view component for carrying each text block.
[0022] Among them, the view components that carry two adjacent text blocks are different.
[0023] In this embodiment, rich text content includes formatted text content, i.e., a string with a tag, which may include text with attribute values (the attribute values may be color, font, thickness, italic, etc.), links, images, tables, videos, etc. The rich text content may be displayed in a graphic manner, and the attributes, links, images, etc. of the text in the rich text may be identified by tags. The format of the rich text content may be HTML format, and the corresponding tags in the rich text content may be HTML tags; the format of the rich text content may also be other formats, such as doc format or wps format, which is not limited in this embodiment.
[0024] In this embodiment, the rich text content is divided to determine multiple text blocks and determine the view component used to carry each text block. For example, according to the text, video, picture, table, etc. in the rich text content, the rich text content is divided into multiple text blocks to obtain text blocks corresponding to the text, text blocks corresponding to the video or picture, text blocks corresponding to the table, etc., and it can be determined that the text component is used to carry the text block corresponding to the text, the video component is used to carry the text block corresponding to the text, the table component is used to carry the text block corresponding to the text, etc.; or, it can be divided according to the text objects in the rich text content and other objects except the text objects. The specific division method is detailed in the following embodiment, and this embodiment will not be repeated here.
[0025] In addition, since rich text content includes strings with tags, and text attribute values, links, images, etc. can all be identified by tags, when dividing rich text content, if the view components corresponding to two adjacent tags are the same, they can be grouped into one text block; if the view components corresponding to two adjacent tags are different, they can be grouped into two different text blocks, so that the view components carrying the two adjacent text blocks are different. For example, if two adjacent tags are tags used to represent text attribute values, the two tags can be grouped into a text block corresponding to one text; if two adjacent tags are a tag representing text attribute values and a tag representing a video, respectively, the tag representing the text attribute value can be grouped into the text block corresponding to the text, and the tag representing the video can be grouped into a text block corresponding to another video or picture.
[0026] S104: Encapsulate multiple view components that carry the text block to render the rich text content.
[0027] In the process of rendering rich text content, you need to call the corresponding view component, and the rich text content can be rendered by carrying the rich text content through the view component. The text, video, picture, table, etc. in the rich text content can all be carried by the corresponding view component.
[0028] In this embodiment, since the rich text content is divided into multiple text blocks in the above steps, in order to ensure the accuracy of rich text content rendering, it is necessary to encapsulate multiple view components that carry the text blocks. In addition, by encapsulating the view components, when rendering multiple text blocks, they are returned to their respective positions, thereby accurately rendering the rich text content.
[0029] The solution provided in this embodiment divides the rich text content, determines multiple text blocks and view components respectively used to carry each text block, and then encapsulates the multiple view components carrying the text blocks to render the rich text content, so that each text block can be rendered as a separate module, and then encapsulated after rendering to obtain the rendering of the rich text content, and then native components can be used to carry part of the rich text content during rendering, thereby improving the rendering speed and avoiding the problem of slow rendering speed caused by using webview to render all rich text content in the prior art.
[0030] Embodiment 2
[0031] Reference Figure 2 , shows a step flow chart of a rich text rendering method according to embodiment 2 of the present invention.
[0032] The method of this embodiment includes the following steps:
[0033] S202: Obtain rich text content.
[0034] S204: Divide the rich text content according to the correspondence between the sample tags and the view components and the tags included in the rich text content to determine a plurality of text blocks and a view component for carrying each text block.
[0035] In this embodiment, multiple view components and sample tags corresponding to each view component may be predetermined. For example, the view component may include a text component textview and a webpage component webview. The sample tags corresponding to the text component textview may include: br, p, div, strong, big, etc. These sample tags are used to define the attributes of the text and the line breaks between texts, etc.; the sample tags corresponding to the webpage component webview may include all sample tags except the sample tags corresponding to the text component textview, such as table, video, gif, svg, etc.; or, the view component may include multiple native components, such as a text component textview, a video component videoview, a table component tableview, etc. The sample tags corresponding to the text component textview may include text-type tags such as br, p, div, strong, big, etc., the sample tags corresponding to the video component videoview may include video image-type tags, such as video, etc., and the sample tags corresponding to the table component tableview may include table-type tags, such as table, etc.
[0036] In this embodiment, after determining the correspondence between sample tags and view components, the rich text content can be divided according to the tags included in the rich text content, thereby accurately dividing the rich text content into multiple text blocks and accurately determining the view component that carries each text block.
[0037] When performing the specific division, the sample labels corresponding to the respective view components can be searched in the labels included in the rich text content according to the correspondence between the sample labels and the view components; the rich text content can be divided according to the search results to determine multiple text blocks and view components respectively used to carry each text block.
[0038] If it is determined according to the search result that the rich text content includes sample tags corresponding to multiple view components, the rich text content is divided according to the sample tags corresponding to the respective view components to determine multiple text blocks, and the view component carrying the text block is determined according to the correspondence between the view component and the sample tags. Specifically, the rich text content corresponding to the sample tag corresponding to a view component can be extracted as one or more text blocks, and the rich text content can be divided into multiple text blocks after one or more extractions.
[0039] If it is determined according to the search result that the rich text content only includes a sample tag corresponding to a view component, then the operation of dividing the rich text is terminated, and all the rich text content can be directly carried by the view component.
[0040] The specific view components and the division of text blocks are described in detail below.
[0041] On the one hand, if the view component includes a text component and a web page component, the step of dividing the rich text content, determining a plurality of text blocks and a view component for carrying each text block includes:
[0042] Determine the text objects in the rich text content that are of the type that the text component can carry, or determine the non-text objects in the rich text content that are of the type that the web page component can carry; divide the rich text object into multiple text blocks according to the result of the determination, and determine that the view component that carries the text block where the text object is located is a text component, and the view component that carries the text block where the non-text object is located is a web page component. The specific method for determining the text object can be implemented by the above-mentioned method for searching for tags in rich text objects.
[0043] For example, if the rich text content is a string in HTML format, it is as follows:
[0044]
[0045]
[0046]
[0047] Among them, the view components used to render the above rich text content include the text component textview and the webpage component webview. The tag table in the above rich text content is the sample tag corresponding to webview, and the rest are the sample tags corresponding to textview. When dividing according to the tags in the rich text content, you can find the sample tag table corresponding to webview in the tags included in the rich text content, and determine the start of the table tag and the end The corresponding subscript index value is used to extract the content corresponding to the table tag as a text block. The content before and after the table tag is taken as a text block respectively, thereby dividing the entire rich text content into three text blocks, which are referred to as text block A, text block B, and text block C in order.
[0048] When determining the subscript index value of the table tag, if the above rich text content is named htmlString, you can use startIndex = htmlString.indexOf(' ') Find and obtain The corresponding subscript index value can be obtained by endIndex = htmlString.indexOf(' ') to find the corresponding subscript index value.
[0049] Sure The corresponding subscript index value startlndex and After reading the corresponding subscript index value endIndex, we can determine that text block A is htmlString.subString(0, startIndex); text block B is htmlString.subString(startlndex, endIndex); and text block C is htmlString.subString(endIndex, htmlString.length). Among them, 0 indicates the starting position of the string htmlString, and htmlString.length indicates the ending position of the string htmlString.
[0050] The text block B obtained by extracting the text content corresponding to the Table tag includes:
[0051]
[0052]
[0053] After the division is completed, the view component used to carry the text block can be determined at the same time as the text block is determined, that is, text block B is carried by the view component webview, and text block A and text block C are carried by the view component textview. Specifically, textView.setTextView (the content of text block A) textView.setTextView (the content of text block C), and webView.loadDataWithBaseURL (the content of text block B, "text / html", "utf-8",) where "text / html" means that the page content is set to html, and "utf-8" means that the encoding format is utf-8. Thus, the corresponding text blocks are carried by each view component.
[0054] On the other hand, if the view components are all native components, that is, the view components include text components, video components, table components, etc., then the division of the rich text content and the determination of multiple text blocks and the view components used to carry each text block include: determining the rich text objects in the rich text content that are of a type that can be carried by each native component; dividing the rich text content according to the determined results, and determining that the view components of the rich text objects that are of a type that can be carried by each native component are each native component.
[0055] The method for specifically determining the rich text objects in the rich text content that are of the type that can be carried by each native component can be implemented by the above-mentioned method of searching for labels in the rich text objects, that is, searching for sample labels corresponding to each native component in the rich text content, thereby determining the rich text objects in the rich text content that are of the type that can be carried by each native component. After determination, each text block can be carried by each native component respectively. The specific method of carrying can refer to the above-mentioned content of carrying text blocks by text components and web page components, and this embodiment will not be repeated here.
[0056] Of course, in other implementations of this embodiment, the view component may also include others, the text blocks may also be divided by other methods, and the specific implementation of carrying each text block by the view component may also be adaptively changed, which is not limited in this embodiment.
[0057] S206. Encapsulate multiple view components that carry the text blocks according to the positional relationship of the multiple text blocks to render the rich text content.
[0058] In this embodiment, taking the above rich text content as an example, when dividing the text blocks, the above rich text content is divided into three text blocks: text block A, text block B, and text block C. According to the rich text content, the position relationship of the three text blocks is a linear position relationship from top to bottom. Therefore, when encapsulating, the three view components behind the three text blocks can be limited and encapsulated in sequence. Specifically, the following code can be used to uniformly linearly encapsulate the three Views (two TextViews and one webView) into a LinearLayout:
[0059] LinearLayout.setOrientation(VERTICAL) / / Vertical layout
[0060] LinearLayout.addView(TextView)LinearLayout.addView(WebView)LinearLayout.addView(TextView)
[0061] Among them, the first textview is used to carry text block A, and the second textview is used to carry text block C. The interface for displaying rich text content after encapsulation is as follows Figure 3 As shown, the interface is divided into three parts, corresponding to text block A, text block B, and text block C respectively.
[0062] Of course, in this embodiment, if the positional relationship of the text blocks obtained after the division is other positional relationships, they can be encapsulated in other ways or sequences, which is not limited in this embodiment.
[0063] The solution provided in this embodiment can greatly improve the rendering speed when rendering rich text content, thereby improving the page display speed, by dividing the rich text content into multiple text blocks, and carrying each text block through multiple native components, or carrying some text blocks with native components (such as textview) and some text blocks with non-native components (such as through webview).
[0064] It should also be noted that since the H5 page includes a larger number of pages than other pages, the rendering speed of the H5 page rendered through the webview is slower than that of rendering other pages through the webview, which greatly reduces the user experience. When the H5 page is rendered through the solution provided in this embodiment, the rendering speed is greatly improved, thereby increasing the speed of page display, thereby providing a better user experience.
[0065] The rich text rendering method of this embodiment can be executed by any appropriate terminal device with data processing capability, including but not limited to: a mobile terminal (such as a tablet computer, a mobile phone, etc.) and a PC.
[0066] Embodiment 3
[0067] Reference Figure 4 , shows a structural block diagram of a rich text rendering device according to embodiment 3 of the present invention.
[0068] Figure 4 The rich text rendering apparatus shown includes: a text block determination module 302 and a packaging module 304 .
[0069] The text block determination module 302 is used to divide the rich text content, determine multiple text blocks and view components respectively used to carry each text block, wherein the view components carrying two adjacent text blocks are different.
[0070] The encapsulation module 304 is used to encapsulate multiple view components behind the text block to render the rich text content.
[0071] In an optional implementation, the text block determination module 302 is specifically used to divide the rich text content according to the correspondence between the sample tags and the view components and the tags included in the rich text content to determine multiple text blocks and view components respectively used to carry each text block.
[0072] In an optional embodiment, the view component includes a text component and a web page component, and the text block determination module 302 includes: an object determination module, used to determine the text objects in the rich text content that are of a type that the text component can carry, or to determine the non-text objects in the rich text content that are of a type that the web page component can carry; a division module, used to divide the rich text object into multiple text blocks according to the determination result, and determine that the view component that carries the text block where the text object is located is the text component, and the view component that carries the text block where the non-text object is located is the web page component.
[0073] In an optional implementation, the encapsulation module 304 is specifically configured to encapsulate multiple view components behind the text blocks according to the positional relationship of the multiple text blocks, so as to render the rich text content.
[0074] The solution provided by the embodiment of the present invention divides the rich text content, determines multiple text blocks and view components respectively used to carry each text block, and then encapsulates the multiple view components carrying the text blocks to render the rich text content, so that each text block can be rendered as a separate module, and then encapsulated after rendering to obtain the rendering of the rich text content, and then native components can be used to carry part of the rich text content during rendering, thereby improving the rendering speed and avoiding the problem of slow rendering speed caused by using webview to render all rich text content in the prior art.
[0075] Embodiment 4
[0076] A terminal device comprises: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the rich text rendering method described above.
[0077] Specifically, refer to Figure 5 , shows a schematic diagram of the structure of a terminal device according to Embodiment 4 of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the terminal device.
[0078] like Figure 5As shown, the terminal device may include: a processor (processor) 502, a communication interface (Communications Interface) 504, a memory (memory) 506, and a communication bus 508.
[0079] in:
[0080] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .
[0081] The communication interface 504 is used to communicate with other terminal devices or servers.
[0082] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above-mentioned rich text rendering method embodiment.
[0083] Specifically, the program 510 may include program codes, which include computer operation instructions.
[0084] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the terminal device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0085] The memory 506 is used to store the program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0086] Program 510 can be specifically used to enable processor 502 to perform the following operations: divide the rich text content, determine multiple text blocks and view components used to carry each text block, wherein the view components carrying two adjacent text blocks are different; encapsulate the multiple view components that carry the text blocks to render the rich text content.
[0087] In an optional embodiment, the dividing of the rich text content includes: dividing the rich text content according to the correspondence between sample tags and view components and the tags included in the rich text content to determine multiple text blocks and view components respectively used to carry each text block.
[0088] In an optional embodiment, the dividing of the rich text content according to the correspondence between the sample tags and the view components and the tags included in the rich text content includes: according to the correspondence between the sample tags and the view components, searching for sample tags corresponding to each view component respectively in the tags included in the rich text content; and dividing the rich text content according to the search results to determine multiple text blocks and view components respectively used to carry each text block.
[0089] In an optional embodiment, the rich text content is divided according to the search results to determine multiple text blocks and view components used to carry each text block, including: if it is determined according to the search results that the rich text content includes sample tags corresponding to multiple view components, the rich text content is divided according to the sample tags corresponding to each view component to determine multiple text blocks, and the view component carrying the text block is determined according to the correspondence between the view component and the sample tag.
[0090] In an optional embodiment, the rich text content is divided according to the search results to determine multiple text blocks and view components used to carry each text block, including: if it is determined according to the search results that the rich text content only includes a sample label corresponding to a view component, then the operation of dividing the rich text is terminated, and all rich text content is directly carried by the view component.
[0091] In an optional embodiment, the view component includes a text component and a web page component, and the division of the rich text content to determine multiple text blocks and a view component used to carry each text block includes: determining text objects in the rich text content that are of a type that can be carried by the text component, or determining non-text objects in the rich text content that are of a type that can be carried by the web page component; dividing the rich text object into multiple text blocks according to the determination result, and determining that the view component carrying the text block where the text object is located is a text component, and the view component carrying the text block where the non-text object is located is a web page component.
[0092] In an optional embodiment, encapsulating the multiple view components behind the text block to render the rich text content includes: encapsulating the multiple view components behind the text block according to the positional relationship of the multiple text blocks to render the rich text content.
[0093] The specific implementation of each step in program 510 can refer to the corresponding description of the corresponding steps and units in the above-mentioned rich text rendering method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiment, which will not be repeated here.
[0094] The terminal device of this embodiment divides the rich text content, determines multiple text blocks and view components for carrying each text block, and then encapsulates the multiple view components carrying the text blocks to render the rich text content, so that each text block can be rendered as a separate module, and then encapsulated to obtain the rendering of the rich text content after rendering, and then native components can be used to carry part of the rich text content during rendering, thereby improving the rendering speed and avoiding the problem of slow rendering speed caused by using webview to render all rich text content in the prior art.
[0095] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0096] The above-described method according to an embodiment of the present invention may be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code that is originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded via a network and will be stored in a local recording medium, so that the method described herein may be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor, or hardware, the rich text rendering method described herein is implemented. In addition, when a general-purpose computer accesses code for implementing the rich text rendering method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the rich text rendering method shown herein.
[0097] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0098] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A rich text rendering method, characterized in that: include: The rich text content is divided to determine a plurality of text blocks and a view component for carrying each text block, wherein the view components carrying two adjacent text blocks are different, and the rich text content includes text content with a format, and the text content with a format is a string with a tag; Encapsulate multiple view components that carry the text block to render the rich text content; The division of rich text content includes: According to the correspondence between the sample tags and the view components and the tags included in the rich text content, the rich text content is divided to determine a plurality of text blocks and a view component for carrying each text block.
2. The method according to claim 1, characterized in that: The dividing of the rich text content according to the correspondence between the sample tags and the view components and the tags included in the rich text content includes: According to the correspondence between the sample tags and the view components, searching for the sample tags corresponding to the respective view components in the tags included in the rich text content; The rich text content is divided according to the search result to determine multiple text blocks and view components respectively used to carry each text block.
3. The method according to claim 2, characterized in that The method of dividing the rich text content according to the search result to determine a plurality of text blocks and view components for carrying each text block respectively includes: If it is determined according to the search results that the rich text content includes sample tags corresponding to multiple view components, the rich text content is divided according to the sample tags corresponding to the respective view components to determine multiple text blocks, and the view component carrying the text block is determined according to the correspondence between the view component and the sample tag.
4. The method according to claim 2, characterized in that: The method of dividing the rich text content according to the search results to determine multiple text blocks and view components used to carry each text block includes: if it is determined according to the search results that the rich text content only includes a sample label corresponding to one view component, then the operation of dividing the rich text is terminated, and all rich text content is directly carried by the view component.
5. The method according to claim 1, characterized in that The view component includes a text component and a web page component, and the division of the rich text content to determine a plurality of text blocks and the view components used to carry each text block respectively include: Determine a text object in the rich text content that is a type that the text component can carry, or determine a non-text object in the rich text content that is a type that the web page component can carry; According to the determination result, the rich text object is divided into a plurality of text blocks, and the view component carrying the text block where the text object is located is determined to be a text component, and the view component carrying the text block where the non-text object is located is determined to be a web page component.
6. The method according to claim 1, characterized in that The encapsulating the multiple view components behind the text block to render the rich text content includes: encapsulating the multiple view components behind the text block according to the positional relationship of the multiple text blocks to render the rich text content.
7. A rich text rendering device, characterized in that: include: A text block determination module, used to divide the rich text content, determine multiple text blocks and view components respectively used to carry each text block, wherein the view components carrying two adjacent text blocks are different, and the rich text content includes text content with format, and the text content with format is a string with a tag; An encapsulation module, used to encapsulate multiple view components behind the text block to render the rich text content; The division of rich text content includes: According to the correspondence between the sample tags and the view components and the tags included in the rich text content, the rich text content is divided to determine a plurality of text blocks and a view component for carrying each text block.
8. The device according to claim 7, characterized in that The text block determination module is specifically used to divide the rich text content according to the correspondence between the sample tags and the view components and the tags included in the rich text content to determine multiple text blocks and view components respectively used to carry each text block.
9. The device according to claim 7, characterized in that The view component includes a text component and a web page component, and the text block determination module includes: An object determination module, used to determine a text object in the rich text content that is a type that the text component can carry, or to determine a non-text object in the rich text content that is a type that the web page component can carry; A division module is used to divide the rich text object into multiple text blocks according to the determination result, and determine that the view component carrying the text block where the text object is located is a text component, and the view component carrying the text block where the non-text object is located is a web page component.
10. The device according to claim 7, characterized in that The encapsulation module is specifically used to encapsulate multiple view components behind the text blocks according to the positional relationship of the multiple text blocks, so as to render the rich text content.
11. A terminal device, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the rich text rendering method according to any one of claims 1 to 6.
12. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the rich text rendering method according to any one of claims 1 to 6 is implemented.
