Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the embodiments of the present disclosure will be described in further detail below with reference to the accompanying drawings.
The embodiment of the disclosure provides a rich text data processing method, a rich text data processing device, electronic equipment and a computer storage medium, which aim to solve the technical problems in the prior art.
The following describes in detail, with specific embodiments, a technical solution of an embodiment of the present disclosure and how the technical solution of the embodiment of the present disclosure solves the foregoing technical problems. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
One embodiment of the present disclosure provides a rich text data processing method that is performed by a terminal, which may be a desktop device or a mobile terminal. As shown in fig. 1, the method includes:
step S110, obtaining the rich text data to be displayed.
Specifically, an application program (e.g., applet) of the terminal may acquire the rich text data to be presented from the corresponding server, wherein the application program may acquire the rich text data to be presented from the server by sending an acquisition request to the server, and the application program may also receive the rich text data to be presented issued by the server at predetermined time intervals (e.g., 30 ms, 1 second, 1 minute, etc.).
Hereinafter, an application program will be specifically described by taking an applet as an example. The applet is an application which can be used without downloading and installing, and the application realizes the dream of 'tentacle' of the application, and a user can open the application by sweeping or searching. The concept of 'run out and walk' is also embodied, and the user does not need to care whether to install too many applications. Applications will be ubiquitous, available at any time, but without installation and uninstallation.
Specifically, the rich text data to be presented is rich text data generated based on a rich text editor draft. Js, draft. Js is a front-end rich text framework based on compact, which is a JavaScript library for building a user interface.
Step S120, performing hypertext markup language character string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, and generating a hypertext markup language character string of a corresponding type.
Specifically, after the applet obtains the rich text data to be displayed, the applet can implement classification of the rich text data to be displayed according to a type field (for example, a type field) in the rich text data to be displayed, obtain the rich text data of a corresponding type, and perform HTML (Hypertext Markup Language ) string conversion on the classified rich text data (i.e., the rich text data of the corresponding type) to generate an HTML string of the corresponding type.
If the type field of the rich text data to be displayed includes an a type field, a B type field and a C type field, the hypertext markup language HTML string conversion may be performed on the rich text data to be displayed according to the a type field, the B type field and the C type field of the rich text data to be displayed, so as to obtain a corresponding HTML string.
Step S130, analyzing the hypertext markup language character string to generate corresponding document object model nodes.
Specifically, after generating an HTML (hypertext markup language) string, the generated HTML string may be parsed to generate a corresponding hypertext markup language (DOM, document Object Model) node. Wherein, DOM node means that each component in XML (extensible markup language) document is a node, the whole document is a document node, and each XML label is an element node.
Step S140, presenting the document object model node based on a predetermined template to present the rich text data to be presented.
Specifically, after the corresponding DOM node is generated, the generated corresponding DOM node may be exposed based on a predetermined template of the applet, so as to realize the exposure of the rich text data to be exposed.
According to the method for processing the rich text data, the rich text data to be displayed is subjected to hypertext markup language character string conversion according to the type field of the rich text data to be displayed, the generated hypertext markup language character string of the corresponding type is analyzed, the corresponding document object model node is generated, the document object model node is displayed based on the preset template, the rich text data to be displayed is displayed, the corresponding conversion processing and the analysis processing can be performed on the rich text data at the applet end, the processed rich text data is accurately displayed, the support of the applet end on the rich text data is realized, and the applet end and the PC end can synchronously display the rich text data.
In one possible implementation manner, according to the type field of the rich text data to be displayed, performing hypertext markup language HTML string conversion on the rich text data to be displayed, the following operation steps may be performed:
Dividing the rich text data to be displayed into rich text data fragments of corresponding types according to the type field;
the rich text data fragment is converted into an HTML string.
Specifically, in the process of performing hypertext markup language HTML string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, the rich text data to be displayed may be divided into rich text data segments of corresponding types according to the type field (e.g., type field) of the rich text data to be displayed. If the type field of the rich text data to be displayed is an a type field, a B type field and a C type field, the rich text data to be displayed can be divided into corresponding types of rich text data fragments according to the a type field, the B type field and the C type field, so as to obtain a type rich text data fragment, a type rich text data fragment and a type C rich text data fragment.
Specifically, after obtaining the rich text data fragment of type a, the rich text data fragment of type B and the rich text data fragment of type C, the obtained rich text data fragment may be converted into an HTML string, that is, the rich text data fragment of type a is subjected to HTML string conversion to generate an HTML string of type a, the rich text data fragment of type B is subjected to HTML string conversion to generate an HTML string of type B, and the rich text data fragment of type C is subjected to HTML string conversion to generate an HTML string of type C.
It should be noted that the above-mentioned type a field, type B field and type C field are only exemplary, and in practical application, more types of fields or fewer types of fields may be used, which is not limited in the embodiment of the present application.
In an alternative, the type a field, the type B field, and the type C field may be respectively specified object prompt information, a uniform resource locator URL, and text content, where the types include at least one of the following: specifying object prompt information; a uniform resource locator URL; text content. The specific object prompt information can be @ someone, the URL can be a hyperlink address, the text content can be common text except special content such as pictures, emoticons, @ symbols and hyperlink addresses, and the common text can be Chinese characters, numbers, corresponding foreign letters or foreign words and the like.
In an alternative, after obtaining the corresponding type of rich text data fragment, the corresponding type of rich text data fragment may be respectively converted into corresponding HTML strings, wherein in the process of converting the rich text data fragment into the HTML strings, at least one of the following operations may be performed:
(1) A first predetermined HTML tag string, such as a < P > tag, is generated from the rich text data segment of the text content, and the < P > tag is in the form of a string, i.e., a first predetermined HTML tag string, which is a < P > tag, is generated from the plain text.
(2) And generating a second preset HTML tag character string from the rich text data fragment of the appointed object prompt information, and taking the associated operation information of the appointed object prompt information as function information of the second preset HTML tag character string. Wherein the second predetermined HTML tag string may be a < a > tag string, i.e., the < a > tag is in the form of a string. If the specified object prompt information is "@ Zhang San", generating a < a > tag from the rich text data fragment corresponding to "@ Zhang San", and simultaneously, clicking operation information of the association operation corresponding to "@ Zhang Sano, for example, checking a personal first page of Zhang Sano, for example, checking a friend circle of Zhang Sano, for example, checking operation information of other relevant dynamic information of Zhang Sano and the like, as function information of the < a > tag, namely, binding the association operation information of" @ Zhang Sano with a character string of the < a > tag.
(3) And generating a second preset HTML tag character string from the rich text data fragment of the URL, and taking the URL as attribute information of the second preset HTML tag character string. Wherein the second predetermined HTML tag string may be a < a > tag string. If the URL is https:// www.w3school.com.cn/HTML, the HTML tag string of the < a > tag can be generated by the rich text data fragment corresponding to https:// www.w3school.com.cn/HTML, and the https:// www.w3school.com.cn/HTML is taken as attribute information of the < a > tag.
In an alternative scheme, after the rich text data fragment is converted into the HTML string, the HTML string can be subjected to an escape process according to a first predetermined data format of the applet, so as to obtain the HTML string in the first predetermined data format, that is, the HTML string is escape into a data format which can be processed by the applet, so that further processing of the HTML string is facilitated.
After the HTML string is converted into the data format that can be processed by the applet, the HTML string in the first predetermined data format needs to be analyzed when the HTML string is analyzed, that is, the HTML string analyzed by the applet is the HTML string in the data format that can be processed by the applet.
In one alternative, the HTML string may be traversed in parsing the HTML string to generate the corresponding DOM node, mapping the different HTML tags to specific tags that can be displayed on the applet.
As one example, an HTML string may be traversed if detected with' < -! -starting, marking the HTML string as a section of comment node; if an HTML string is detected to start with '<', it is marked as a start tag, and if an HTML string is detected to start with '<', it is marked as an end tag. The starting label and the ending label are paired into corresponding DOM nodes, namely, the starting label and the ending label paired with the starting label are determined, and the corresponding DOM nodes are generated according to the starting label and the ending label.
In one application scenario, the following operations may be performed: analyzing the HTML character string of the type A to generate a DOM node of the HTML character string of the type A, analyzing the HTML character string of the type B to generate a DOM node of the HTML character string of the type B, analyzing the HTML character string of the type C to generate a DOM node of the HTML character string of the type C.
Specifically, after generating the corresponding DOM node according to the start tag and the end tag, the correspondingly generated DOM node may be exposed based on a predetermined template of the applet, so as to expose the rich text data to be exposed. In practical application, the applet can circularly display the correspondingly generated DOM nodes based on the preset template, so that all the rich text data to be displayed are displayed.
In one possible implementation, the applet may also obtain text information of the text information to be generated and generate the text information rich text data based on the rich text editor framework draft.
If the user T and the user P perform information interaction through the applet, the applet installed at the terminal of the user T may acquire text information of the rich text data to be generated, which is input by the user T, and generate corresponding rich text data based on the draft. Js, and send the generated rich text data to a server corresponding to the applet, so that the server caches the rich text data. Meanwhile, the applet installed at the terminal of the user P may request the server to obtain the rich text data sent by the user T through the applet, so as to display the rich text data, and of course, after the server receives the rich text data sent by the user T through the applet, the server may also actively send the rich text data to the applet installed at the terminal of the user P, so as to display the rich text data.
Specifically, in the process of generating rich text data of text information based on the draft. Js, the applet can determine at least one type of text association information of specified object prompt information (for example @ someone), URL (hyperlink address) and text content included in the text information according to the regular expression; and then analyzing the text associated information, and splicing the analysis result according to a second preset data format of the draft. Js to generate rich text data of the text information.
Specifically, when the type is the specified object prompt information, the text associated information comprises the identification information of the specified object, the text information of the specified object prompt information, the text length of the text information of the specified object prompt information and the text initial offset position of the text information of the specified object prompt information; when the type is URL, the text associated information comprises text information of the URL, text length of the text information of the URL and text initial offset position of the text information of the URL; when the type is text content, the text-related information includes text information of the text content, a text length of the text information of the text content, and a text start offset position of the text information of the text content.
In an application scenario, different types of text data segments can be stored in an array, and additional information needed by each type is placed in an entity map (EntityMap), wherein for the type of the specified object prompt information, the corresponding additional information can be the identification information of the specified object, the text length of the text information of the specified object prompt information and the text start offset position of the text information of the specified object prompt information; for this type of URL, the corresponding additional information may be the text length of the text information of the URL and the text start offset position of the text information of the URL; for this type of text content, the corresponding additional information may be the text length of the text content and the text start offset position of the text content.
Specifically, after the text associated information is obtained, the text associated information can be analyzed, and the analysis result is spliced according to a second preset data format of draft. Js, so that rich text data of the text information are generated. In the splicing process, the analysis result is spliced according to a second preset data format of the draft. Js based on the sequence of at least one item of text information of the appointed object prompt information, the text information of the URL and the text information of the text content included in the text information. The second predetermined data format may be a JSON (JavaScript Object Notation, JS object profile) data format.
By the method, the synchronous display of the rich text data based on the draft. Js by the applet end and the PC end can be realized, and the rich text data of the appointed object prompt information and the URL type can be edited in the realization applet.
Fig. 2 is a schematic structural diagram of a rich text data processing apparatus according to another embodiment of the disclosure, and as shown in fig. 2, the apparatus 20 may include an obtaining module 21, a converting module 22, a processing module 23, and a displaying module 24, where:
an acquisition module 21, configured to acquire rich text data to be displayed;
the conversion module 22 is configured to perform hypertext markup language string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, so as to generate a hypertext markup language string of a corresponding type;
the processing module 23 is used for analyzing the hypertext markup language character string and generating corresponding document object model nodes;
a presentation module 24 for presenting the document object model nodes based on a predetermined template to present the rich text data to be presented.
Fig. 3 is a detailed structural schematic diagram of a rich text data processing apparatus according to another embodiment of the disclosure, as shown in fig. 3, the apparatus 30 may include an obtaining module 31, a converting module 32, a processing module 33, a displaying module 34, an escape module 35, and a generating module 36, where the obtaining module 31 in fig. 3 performs the same function as the obtaining module 21 in fig. 2, the converting module 32 in fig. 3 performs the same function as the converting module 22 in fig. 2, the processing module 33 in fig. 3 performs the same function as the processing module 23 in fig. 2, and the displaying module 34 in fig. 3 performs the same function as the displaying module 24 in fig. 2, which is not repeated herein. The rich text data processing apparatus shown in fig. 3 will be described in detail as follows:
The conversion module 32 is specifically configured to:
dividing the rich text data to be displayed into rich text data fragments of corresponding types according to the type field;
the rich text data fragment is converted into a hypertext markup language string.
In one possible implementation, the types include at least one of:
specifying object prompt information; a uniform resource locator; text content.
In one possible implementation, the conversion module 32, when converting the rich text data fragment into a hypertext markup language string, performs at least one of:
generating a first preset hypertext markup language tag character string from the rich text data segment of the text content;
generating a second preset hypertext markup language tag character string from the rich text data fragment of the specified object prompt information, and taking the associated operation information of the specified object prompt information as function information of the second preset hypertext markup language tag character string;
and generating a second preset hypertext markup language tag character string by using the rich text data fragment of the uniform resource locator, and taking the uniform resource locator as attribute information of the second preset hypertext markup language tag character string.
In one possible implementation, further comprising an escape module 35, wherein:
An escape module 35, configured to perform an escape process on the hypertext markup language string according to the first predetermined data format, so as to obtain the hypertext markup language string in the first predetermined data format;
the processing module 33 is specifically configured to parse the hypertext markup language string in the first predetermined data format when parsing the hypertext markup language string.
In one possible implementation, the processing module 33 is specifically configured to, when generating the corresponding document object model node:
traversing the hypertext tag language character string, and determining a start tag and an end tag matched with the start tag;
and generating corresponding document object model nodes according to the start label and the end label.
In one possible implementation, the apparatus further includes a generation module 36, wherein:
the generating module 36 is configured to obtain text information of the text information to be generated, generate the text information rich text data based on the rich text editor framework, and send the text information rich text data to a corresponding server.
In one possible implementation, the generation module 36 is specifically configured to, when generating rich text data of text information based on a rich text editor framework:
determining at least one type of text associated information of specified object prompt information, uniform resource locators and text contents included in the text information according to the regular expression:
Analyzing the text associated information, and splicing analysis results according to a second preset data format of the rich text editor framework to generate rich text data of the text information.
In one possible implementation, when the type is the specified object prompt information, the text associated information includes identification information of the specified object, text information of the specified object prompt information, text length of the text information of the specified object prompt information, and a text start offset position of the text information of the specified object prompt information;
when the type is the uniform resource locator, the text associated information comprises text information of the uniform resource locator, text length of the text information of the uniform resource locator and text initial offset position of the text information of the uniform resource locator;
when the type is text content, the text-related information includes text information of the text content, a text length of the text information of the text content, and a text start offset position of the text information of the text content.
According to the device provided by the embodiment of the disclosure, the hypertext markup language character string is converted according to the type field of the rich text data to be displayed, the generated hypertext markup language character string of the corresponding type is analyzed, the corresponding document object model node is generated, and the document object model node is displayed based on the preset template to display the rich text data to be displayed, so that the corresponding conversion processing and analysis processing can be performed on the rich text data at the applet end, the processed rich text data can be correctly displayed, the support of the applet end on the rich text data is realized, and the applet end and the PC end can synchronously display the rich text data.
It should be noted that, the embodiments of the present disclosure are apparatus item embodiments corresponding to the above-mentioned method item embodiments, and the embodiments of the present disclosure may be implemented in cooperation with the above-mentioned method item embodiments. The related technical details mentioned in the above method embodiments are still valid in the embodiments of the present disclosure, and are not repeated here for reducing repetition. Accordingly, the related technical details mentioned in the embodiments of the present disclosure may also be applied in the above-described method item embodiments.
Referring now to fig. 4, a schematic diagram of an electronic device 400 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 4 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
The electronic device comprises a memory and a processor, wherein the processor may be referred to as the processing means 401 described below, the memory comprising at least one of Read Only Memory (ROM) 402, random Access Memory (RAM) 403 and storage means 408 described below, as follows:
As shown in fig. 4, the electronic device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401, which may perform various suitable actions and processes according to a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage means 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other by a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
In general, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 shows an electronic device 400 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communications device 409, or from storage 408, or from ROM 402. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 401.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring rich text data to be displayed;
performing hypertext tag language character string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, and generating a hypertext tag language character string of a corresponding type;
analyzing the hypertext markup language character string to generate corresponding document object model nodes;
the document object model nodes are presented based on a predetermined template to present rich text data to be presented.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the module or the unit is not limited to the unit itself in some cases, for example, the acquiring module may also be described as "a module for acquiring at least one event processing manner corresponding to a predetermined live event when the occurrence of the predetermined live event is detected".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a rich text data processing method including:
acquiring rich text data to be displayed;
performing hypertext tag language character string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, and generating a hypertext tag language character string of a corresponding type;
analyzing the hypertext markup language character string to generate corresponding document object model nodes;
the document object model nodes are presented based on a predetermined template to present rich text data to be presented.
In one possible implementation manner, performing hypertext markup language character string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, including:
dividing the rich text data to be displayed into rich text data fragments of corresponding types according to the type field;
the rich text data fragment is converted into a hypertext markup language string.
In one possible implementation, the types include at least one of:
specifying object prompt information; a uniform resource locator; text content.
In one possible implementation, converting the rich text data fragment into a hypertext markup language string includes at least one of:
Generating a first preset hypertext markup language tag character string from the rich text data segment of the text content;
generating a second preset hypertext markup language tag character string from the rich text data fragment of the specified object prompt information, and taking the associated operation information of the specified object prompt information as function information of the second preset hypertext markup language tag character string;
and generating a second preset hypertext markup language tag character string by using the rich text data fragment of the uniform resource locator, and taking the uniform resource locator as attribute information of the second preset hypertext markup language tag character string.
In one possible implementation, after converting the rich text data fragment into the hypertext markup language string, further comprising:
according to the first preset data format, carrying out escape processing on the hypertext markup language character string to obtain the hypertext markup language character string in the first preset data format;
parsing a hypertext markup language string, comprising:
the hypertext markup language string in the first predetermined data format is parsed.
In one possible implementation, generating a corresponding document object model node includes:
traversing the hypertext tag language character string, and determining a start tag and an end tag matched with the start tag;
And generating corresponding document object model nodes according to the start label and the end label.
In one possible implementation, the method further includes:
and acquiring text information of the text information to be generated, generating the rich text data of the text information based on the rich text editor framework, and sending the rich text data to a corresponding server.
In one possible implementation, generating rich text data of text information based on a rich text editor framework includes:
determining at least one type of text associated information of specified object prompt information, uniform resource locators and text contents included in the text information according to the regular expression:
analyzing the text associated information, and splicing analysis results according to a second preset data format of the rich text editor framework to generate rich text data of the text information.
In one possible implementation, when the type is the specified object prompt information, the text associated information includes identification information of the specified object, text information of the specified object prompt information, text length of the text information of the specified object prompt information, and a text start offset position of the text information of the specified object prompt information;
When the type is the uniform resource locator, the text associated information comprises text information of the uniform resource locator, text length of the text information of the uniform resource locator and text initial offset position of the text information of the uniform resource locator;
when the type is text content, the text-related information includes text information of the text content, a text length of the text information of the text content, and a text start offset position of the text information of the text content.
According to one or more embodiments of the present disclosure, there is provided a rich text data processing apparatus including:
the acquisition module is used for acquiring the rich text data to be displayed;
the conversion module is used for carrying out hypertext markup language character string conversion on the rich text data to be displayed according to the type field of the rich text data to be displayed, and generating a hypertext markup language character string of a corresponding type;
the processing module is used for analyzing the hypertext markup language character strings and generating corresponding document object model nodes;
and the display module is used for displaying the document object model nodes based on a preset template so as to display the rich text data to be displayed.
In one possible implementation, the conversion module is specifically configured to:
Dividing the rich text data to be displayed into rich text data fragments of corresponding types according to the type field;
the rich text data fragment is converted into a hypertext markup language string.
In one possible implementation, the types include at least one of:
specifying object prompt information; a uniform resource locator; text content.
In one possible implementation, the conversion module, when converting the rich text data fragment into the hypertext markup language string, performs at least one of:
generating a first preset hypertext markup language tag character string from the rich text data segment of the text content;
generating a second preset hypertext markup language tag character string from the rich text data fragment of the specified object prompt information, and taking the associated operation information of the specified object prompt information as function information of the second preset hypertext markup language tag character string;
and generating a second preset hypertext markup language tag character string by using the rich text data fragment of the uniform resource locator, and taking the uniform resource locator as attribute information of the second preset hypertext markup language tag character string.
In one possible implementation, the method further includes an escape module:
The escape module is used for performing escape processing on the hypertext markup language character string according to a first preset data format to obtain the hypertext markup language character string in the first preset data format;
the processing module is specifically configured to parse the hypertext markup language string in the first predetermined data format when parsing the hypertext markup language string.
In one possible implementation manner, the processing module is specifically configured to, when generating the corresponding document object model node:
traversing the hypertext tag language character string, and determining a start tag and an end tag matched with the start tag;
and generating corresponding document object model nodes according to the start label and the end label.
In one possible implementation, the apparatus further includes a generation module;
the generation module is used for acquiring text information of the text information to be generated, generating the text information rich text data based on the rich text editor framework and sending the text information rich text data to the corresponding server.
In one possible implementation manner, the generating module is specifically configured to, when generating rich text data of text information based on a rich text editor framework:
determining at least one type of text associated information of specified object prompt information, uniform resource locators and text contents included in the text information according to the regular expression:
Analyzing the text associated information, and splicing analysis results according to a second preset data format of the rich text editor framework to generate rich text data of the text information.
In one possible implementation, when the type is the specified object prompt information, the text associated information includes identification information of the specified object, text information of the specified object prompt information, text length of the text information of the specified object prompt information, and a text start offset position of the text information of the specified object prompt information;
when the type is the uniform resource locator, the text associated information comprises text information of the uniform resource locator, text length of the text information of the uniform resource locator and text initial offset position of the text information of the uniform resource locator;
when the type is text content, the text-related information includes text information of the text content, a text length of the text information of the text content, and a text start offset position of the text information of the text content.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.