Rich text rendering method, device, electronic device and storage medium

By converting the original rich text information into text fields with preset hierarchical structures, and using recursive parsers and dynamic rendering components, the problem of unfriendly user interaction and oversized size of existing rich-text components is solved, and flexible, lightweight and configurable rich text rendering effects are achieved.

CN113761871BActive Publication Date: 2025-04-15BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110144657.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-02
Publication Date
2025-04-15
Estimated Expiration
2041-02-02

AI Technical Summary

Technical Problem

The user interaction of the existing rich-text components is unfriendly and does not support events. Some rich text tags cannot be parsed, and the tag information in rich text cannot be configurable, resulting in the rendering component being too large and inflexible.

Method used

Rich text tags are obtained by converting the original rich text information into text fields with a preset hierarchical structure and recursively parsing the text fields using a pre-built recursive parser. Based on the configuration rules of these tags, the corresponding rendering components are dynamically loaded for rendering.

Benefits of technology

It realizes flexible, lightweight and configurable rich text rendering, supports scalability and event processing of rich text tags, reduces the size of rendering components and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113761871B_ABST
    Figure CN113761871B_ABST
Patent Text Reader

Abstract

The present disclosure provides a rich text rendering method, comprising: converting original rich text information into a text field with a preset hierarchical structure. Then, using a pre-built parser to recursively parse the text field to obtain a rich text tag, wherein the text field includes hierarchically nested rich text tags. Finally, based on the configuration rules of the rich text tags, the original rich text information is rendered. The present disclosure also provides a rich text rendering device, an electronic device, and a computer-readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a rich text rendering method, device, electronic device, and storage medium. Background Art

[0002] Rich Text Format (RTF), also known as Rich Text Format, is a cross-platform document format developed by Microsoft. It is a text and graphic document format that can be transmitted and viewed between different devices, different operating systems and different applications. Generally, when the WeChat front-end interface displays rich text information to users, the original rich text code is generally rendered through the official rich-text component.

[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the related art: the rich-text component is not user-friendly, does not support events, and some rich text tags cannot be parsed, and it is also impossible to configurably parse the tag information in the rich text. When faced with complex tag information contained in rich text, it is necessary to use a parsing language containing a large number of templates for iterative parsing, which makes the rendering component too large and inflexible. Summary of the invention

[0004] In view of this, the present disclosure provides a flexible, lightweight and configurable rich text rendering method and device.

[0005] One aspect of the present disclosure provides a rich text rendering method, including: converting original rich text information into a text field with a preset hierarchical structure; recursively parsing the text field using a pre-built parser to obtain a rich text tag; and rendering the original rich text information based on a configuration rule of the rich text tag.

[0006] According to an embodiment of the present disclosure, the parser is a recursive traversal component with a Tree structure.

[0007] According to an embodiment of the present disclosure, the method of recursively parsing the text field using a pre-built parser to obtain a rich text tag includes: using the traversal component to recursively traverse each level of the text field to obtain the rich text tags contained in each level of the text field; wherein the text field includes hierarchically nested rich text tags.

[0008] According to an embodiment of the present disclosure, rendering the original rich text information based on the configuration rules of the rich text tag includes: in response to an instruction configured by a user, loading a rendering component corresponding to the instruction; and using the rendering component to render the original rich text information based on the configuration rules of the rich text tag.

[0009] According to an embodiment of the present disclosure, the rendering component includes a text component, a picture component and a video component.

[0010] According to an embodiment of the present disclosure, the conversion of original rich text information into a text field with a preset hierarchical structure includes: converting the original rich text information into stack data; distributing the stack data into different types of node data; parsing the node data to obtain attributes and events contained in the node data; and converting the attributes and the events into a text field with a preset hierarchical structure.

[0011] According to an embodiment of the present disclosure, the types of the node data include a text node type and an element node type.

[0012] Another aspect of the present disclosure provides a rich text rendering device, including: a conversion module, which converts original rich text information into a text field with a preset hierarchical structure; a parsing module, which uses a pre-built parser to recursively parse the text field to obtain a rich text tag; and a rendering module, which renders the original rich text information based on the configuration rules of the rich text tag.

[0013] Another aspect of the present disclosure provides an electronic device, comprising one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above claims.

[0014] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.

[0015] According to the embodiments of the present disclosure, because a technical means of utilizing a recursive traversal component to parse a text field with a hierarchical structure is adopted, the technical problem of inflexible parsing solutions in the prior art and excessive size of the parsing component caused by calling a large number of hierarchical relationships and templates to parse rich text information is at least partially overcome, thereby achieving the technical effect of supporting configurable, extensible, and flexible rich text rendering of rich text tags and simple and convenient access. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0017] Figure 1 An exemplary system architecture to which the method and apparatus for rich text rendering of the present disclosure can be applied is schematically shown;

[0018] Figure 2 A flowchart of a rich text rendering method according to an embodiment of the present disclosure is schematically shown;

[0019] Figure 3 The schematic diagram of the structure of the parser according to the embodiment of the present disclosure is shown;

[0020] Figure 4A A flowchart of a method for obtaining a text field according to an embodiment of the present disclosure is schematically shown;

[0021] Figure 4B A flowchart of a method for rendering rich text information according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 5 A block diagram of a rich text rendering device according to an embodiment of the present disclosure is schematically shown;

[0023] Fig. 6A A block diagram of a conversion module according to an embodiment of the present disclosure is schematically shown;

[0024] Figure 6B A block diagram schematically shows a rendering module according to an embodiment of the present disclosure; and

[0025] Figure 7 A block diagram of an electronic device suitable for a rich text rendering apparatus according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0026] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0027] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "include", "comprising", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0028] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0029] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted as the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted as the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0030] The embodiments of the present disclosure provide a method and device for rich text rendering. The method includes a process of parsing the original rich text and a process of rendering the rich text. In the process of parsing the original rich text, the original rich text information is converted into a text field with a preset hierarchical structure, and the text field is recursively parsed using a pre-built parser to obtain a rich text tag. After parsing the original rich text, the original rich text information is rendered based on the configuration rules of the rich text tag.

[0031] Figure 1 The exemplary system architecture 100 to which the rich text rendering method and apparatus according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0032] like Figure 1As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0033] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).

[0034] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0035] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0036] It should be noted that the rich text rendering method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the rich text rendering device provided in the embodiment of the present disclosure can generally be set in the server 105. The rich text rendering method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the rich text rendering device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Alternatively, the rich text rendering method provided in the embodiment of the present disclosure can also be executed by the terminal devices 101, 102, or 103, or can also be executed by other terminal devices different from the terminal devices 101, 102, or 103. Accordingly, the rich text rendering apparatus provided in the embodiments of the present disclosure may also be disposed in the terminal device 101 , 102 , or 103 , or in other terminal devices different from the terminal device 101 , 102 , or 103 .

[0037] For example, the original rich text information to be rendered may be originally stored in any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), or stored in an external storage device and may be imported into the terminal device 101. Then, the terminal device 101 may locally execute the rich text rendering method provided by the embodiment of the present disclosure, or send the original rich text information to be rendered to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the original rich text information to be rendered may execute the rich text rendering method provided by the embodiment of the present disclosure.

[0038] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0039] Figure 2 The flowchart of the rich text rendering method according to an embodiment of the present disclosure is schematically shown.

[0040] like Figure 2 As shown, the method includes operations S201 to S203.

[0041] In operation S201 , original rich text information is converted into a text field having a preset hierarchical structure.

[0042] In operation S202, a pre-built parser is used to recursively parse the text field to obtain a rich text tag.

[0043] In operation S203, the original rich text information is rendered based on the configuration rule of the rich text tag.

[0044] In the disclosed embodiment, the parser is a recursive traversal component with a Tree structure. For a rich text field with a hierarchical structure, the rich text field includes hierarchically nested rich text tags. The traversal component is used to recursively traverse the field. The traversal component is used to recursively traverse each level of the text field to obtain the rich text tags contained in each level of the text field.

[0045] Figure 3 The schematic diagram of the structure of the parser according to the embodiment of the present disclosure is shown. Figure 3 As shown in the figure, the parser is a tree component, and its structure is to call the tree component in the tree component to form a recursive traversal component with a tree structure. The traversal component is used to recursively traverse and parse the rich text field containing hierarchical nested rich text tags, avoiding the need to process a large number of hierarchical relationships and templates during the parsing process, freeing up storage space.

[0046] The specific implementation method of the reference method for the Tree component is <trees nodes=″{{nodes}}″ / >. Among them, the binding of events and attributes is omitted in this parser, avoiding the problems of template hierarchy and size, reducing the volume of the rendering device containing this parsing, and enabling flexible application.

[0047] Before parsing the rich text tags, it also includes configuring the rich text tags that need to be supported. The specific configuration method is

[0048]

[0049] Among them, require: true indicates that the rich text tag needs to be parsed, click: true indicates that a click event needs to be added, and class indicates the name of the style to be externally loaded.

[0050] Through the embodiments of the present disclosure, a recursive traversal component with a tree structure is used to traverse and parse rich text tags with hierarchical nesting. A large number of templates are not used for iterative parsing in the syntax parsing solution, releasing storage space. As a result, the volume of the entire rendering device is lighter and more controllable, and it is more suitable for use in the development of small-volume programs such as WeChat mini-programs. At the same time, it supports configurable parsing of the tag information contained in the rich text information, realizes flexible and extensible rendering of the rich text information, solves problems such as unfriendly user interaction, lack of support for events, and inability to parse some rich text tags in the official components provided by developers such as WeChat, and improves the user experience.

[0051] Next, refer to Figure 4A to Figure 4B and further illustrate the Figure 2 method shown in combination with specific embodiments.

[0052] Figure 4A A flowchart of a method for obtaining a text field according to an embodiment of the present disclosure is schematically shown.

[0053] As Figure 4A shown, converting the original rich text information into a text field with a preset hierarchical structure includes operations S301 to S304.

[0054] In operation S301, the original rich text information is converted into stack data.

[0055] In operation S302, the stack data is distributed into different types of node data.

[0056] In operation S303, the node data is parsed to obtain the attributes and events contained in the node data.

[0057] In operation S304, attributes and events are converted into text fields with a preset hierarchical structure.

[0058] In the embodiments of the present disclosure, for different development requirements of developers, the original rich text information is converted into text fields with corresponding hierarchical structures. Taking the development of WeChat mini programs as an example, the original rich text information is converted into a hierarchical structure supported by WeChat by modifying the JavaScript library.

[0059] Specifically, by identifying the start tag "< / " and end tag " / >" contained in the rich text information, the content contained in the original rich text information is sequentially converted into stack data, and then according to the configuration requirements, the stack data is distributed into different types of node data. The types of node data include text node types and element node types. Among them, if it is element node data, the attributes and events contained in the data need to be parsed, and finally the attributes and events are converted into text fields with a hierarchical structure supported by WeChat.

[0060] Figure 4B A flowchart of a method for rendering rich text information according to an embodiment of the present disclosure is schematically shown.

[0061] As Figure 4B shown, based on the configuration rules of rich text tags, rendering the original rich text information includes operations S401 to S402.

[0062] In operation S401, in response to an instruction configured by the user, a rendering component corresponding to the instruction is loaded.

[0063] In operation S402, the original rich text information is rendered using the rendering component based on the configuration rules of rich text tags.

[0064] In the embodiments of the present disclosure, to further reduce the volume of the rendering device, according to the instructions configured by the user, the rendering components can be dynamically assembled and loaded at runtime to perform the rendering operation, so as to realize "thinning" the mini program in a configurable manner. Common rendering components include text components, image components, audio components, and video components, etc. For example, the instruction information configured by the user is that the user only needs to render text and images. Therefore, before performing the rendering operation, only the corresponding text component and image component need to be loaded. If the original rich text information contains video information, the video information will be blocked and no longer displayed to the user.

[0065] Using a rendering component corresponding to the instruction configured by the user, the rich text information is rendered according to the configuration rules of rich text tags. For example, common rich text tags include 、 、 、 、 <video> 、 、 、 <h1>-< / h1> < / video> <h6> Etc. Specific location, The configuration rules define the partitions or sections in the document, which are used to divide the document into independent and different parts; The configuration rules are to define hyperlinks, which are used to link from one page to another; The configuration rule is to define an empty tag, which can be used to indicate the beginning of a new line of content; The configuration rules are to link images from web pages, <video>The configuration rules are to define video, The configuration rules are used to combine inline elements in a document; The configuration rule is to define the paragraph; <h1>-< / h1> <h6> The configuration rule is to define the title,< / h6> <h1> Define the largest title,< / h1> <h6>Defines the smallest title.

[0066] Let's explain this in detail with an example.

[0067]

[0068] Among them, "color: #00FF00" is the color number, and the tag contained in the above rich text means to render the following document content in green. In the specific document content, "This is a heade" is rendered as a level 3 title style, and "This is a paragraph" is rendered as a new paragraph. Tags The tags are nested in< / h6> <h3>< / h3> and tags .

[0069] Through the embodiments of the present disclosure, the corresponding rendering components are dynamically loaded on demand according to the configuration requirements of the user, and the rich text information is rendered, so that the configuration of the rendering process is simple, scalable, lightweight and flexible.

[0070] < / video> Figure 5 A block diagram of a rich text rendering device according to an embodiment of the present disclosure is schematically shown.

[0071] like Figure 5 As shown, the rich text rendering apparatus 500 includes a conversion module 510 , a parsing module 520 and a rendering module 530 .

[0072] A conversion module 510 converts the original rich text information into a text field with a preset hierarchical structure;

[0073] The parsing module 520 uses a pre-built parser to recursively parse the text field to obtain a rich text tag;

[0074] The rendering module 530 renders the original rich text information based on the configuration rules of the rich text tag.

[0075] Through the disclosed embodiments, rich text tags are configurable, rendering functions are scalable, rendering components are flexible and lightweight, and access is simple and convenient, making them more suitable for use in small-volume program development such as WeChat applets. Most rich text tags and tag events are supported, solving problems such as unfriendly user interaction, lack of event support, and inability to parse some rich text tags in official components provided by developers such as WeChat, thereby improving the user experience.

[0076] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0077] For example, any multiple of the conversion module 510, the parsing module 520, and the rendering module 530 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the conversion module 510, the parsing module 520, and the rendering module 530 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware or in a suitable combination of any of them. Alternatively, at least one of the conversion module 510 , the parsing module 520 , and the rendering module 530 may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be performed.

[0078] Reference below Figure 6A to Figure 6B , combined with specific embodiments Figure 5 The method shown is further explained.

[0079] Fig. 6A The block diagram of the conversion module according to the embodiment of the present disclosure is schematically shown.

[0080] like Fig. 6A As shown, the conversion module 510 includes a first conversion unit 5101, which is used to convert the original rich text information into stack data. A distribution unit 5102, which is used to distribute the stack data into different types of node data. A parsing unit 5103, which is used to parse the node data to obtain the attributes and events contained in the node data. A second conversion unit 5104, which is used to convert the attributes and events into a text field with a preset hierarchical structure.

[0081] Figure 6B A block diagram of a rendering module according to an embodiment of the present disclosure is schematically shown.

[0082] like Figure 6B As shown, the rendering module 530 includes a loading unit 5301, which is used to load a rendering component corresponding to the instruction in response to the instruction configured by the user. A rendering unit 5302 is used to render the original rich text information based on the configuration rules of the rich text tag using the rendering component.

[0083] It should be noted that the rich text rendering device part in the embodiment of the present disclosure corresponds to the rich text rendering method part in the embodiment of the present disclosure. The description of the rich text rendering device part specifically refers to the rich text rendering method part, which will not be repeated here.

[0084] Figure 7 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0085] like Figure 7 As shown, the electronic device 600 according to the embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.

[0086] In RAM 603, various programs and data required for the operation of system 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other through bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0087] According to an embodiment of the present disclosure, the system 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The system 600 may further include one or more of the following components connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0088] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0089] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0090] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device.

[0091] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 602 and / or the RAM 603 described above and / or one or more memories other than the ROM 602 and the RAM 603 .

[0092] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0093] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0094] The embodiments of the present disclosure are described above. However, these embodiments are only for the purpose of illustration and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present disclosure. < / h6>

Claims

1. A rich text rendering method, comprising: Convert original rich text information into text fields with a preset hierarchical structure; Recursively parsing the text field using a pre-built parser to obtain a rich text tag; Rendering the original rich text information based on the configuration rule of the rich text tag; The converting of the original rich text information into a text field with a preset hierarchical structure includes: Convert the original rich text information into stack data; Distributing the stack data into different types of node data; Parsing the node data to obtain the attributes and events contained in the node data; The attributes and the events are converted into text fields having a preset hierarchical structure.

2. The method according to claim 1, wherein: The parser is a recursive traversal component with a Tree structure.

3. The method according to claim 2, wherein: The recursive parsing of the text field using a pre-built parser to obtain a rich text tag includes: Recursively traverse each level of the text field using the traversal component to obtain rich text tags contained in each level of the text field; The text field includes hierarchically nested rich text tags.

4. The method according to claim 1, wherein: The rendering of the original rich text information based on the configuration rule of the rich text tag includes: In response to an instruction configured by a user, loading a rendering component corresponding to the instruction; The original rich text information is rendered using the rendering component based on the configuration rule of the rich text tag.

5. The method according to claim 4, wherein: The rendering components include text components, image components and video components.

6. The method according to claim 5, wherein: The types of the node data include text node type and element node type.

7. A rich text rendering device, comprising: A conversion module converts the original rich text information into a text field with a preset hierarchical structure; A parsing module, using a pre-built parser to recursively parse the text field to obtain a rich text tag; A rendering module, which renders the original rich text information based on the configuration rules of the rich text tag; The conversion module comprises: A first conversion unit, used for converting original rich text information into stack data; A distribution unit, used for distributing the stack data into different types of node data; A parsing unit, used for parsing the node data to obtain the attributes and events contained in the node data; The second conversion unit is used to convert the attribute and the event into a text field with a preset hierarchical structure.

8. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • WeChat applet rich text conversion method based on an education system and electronic equipment

    CN109582932A