Text rendering method and device, computer equipment, readable storage medium and program product

By parsing the target structured document to generate style instructions and then rendering them, the limitations of rendering controls are solved, the rendering effect of complex styles is improved, and it is suitable for more application scenarios.

CN120911418APending Publication Date: 2025-11-07SUZHOU LANGDONG NET TEC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511040147.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

In existing technologies, rendering controls only support rendering plain text, resulting in limited rendering effects that cannot meet the needs of practical applications.

Method used

By acquiring the target structured document, parsing the document to obtain the target text and style rules, generating style instructions based on the attributes of the style rules, and rendering them using the corresponding components, including rendering global and differential style attributes, and merging the initial rendered text to obtain the target rendered text.

Benefits of technology

It enables the rendering of complex styles despite the limitations of the rendering component, improves the rendering effect, is suitable for more application scenarios, and has lower requirements for the rendering component.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120911418A_ABST
    Figure CN120911418A_ABST
Patent Text Reader

Abstract

The invention relates to a text rendering method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: acquiring a target structured document, and analyzing the target structured document to obtain a target text and at least one sample rule matched with the target text; according to the style attribute of the style rule, determining a style instruction corresponding to the style rule, the style attribute including at least one of a global style attribute and a difference style attribute; and rendering the target text by using components corresponding to the style instruction to obtain initial rendered texts, and merging the initial rendered texts to obtain a target rendered text. The method can improve the rendering effect and save resources.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a text rendering method and device, a computer device, a computer readable storage medium, and a computer program product. BACKGROUND

[0002] In the scenarios of rich text display editing, cross-platform adaptation, dynamic style modification, etc., the text needs to be rendered according to the actual scenario to meet the individual needs.

[0003] In the related art, the text can be rendered by a rendering control to obtain the rendered text. However, in some application systems, the rendering control only supports rendering of ordinary text, the rendering function is relatively limited, the rendering effect is poor, and the actual application needs cannot be met. SUMMARY

[0004] Therefore, it is necessary to provide a text rendering method and device, a computer device, a computer readable storage medium, and a computer program product capable of improving the rendering effect.

[0005] In a first aspect, the present application provides a text rendering method, comprising:

[0006] obtaining a target structured document, and parsing the target structured document to obtain a target text and at least one style rule matched with the target text;

[0007] determining a style instruction corresponding to the style rule according to a style attribute of the style rule, the style attribute comprising at least one of a global style attribute and a differential style attribute;

[0008] rendering the target text by using a component corresponding to the style instruction to obtain an initial rendered text, and merging the initial rendered text to obtain a target rendered text.

[0009] In one embodiment, the parsing of the target structured document to obtain a target text and at least one style rule matched with the target text comprises:

[0010] parsing the target structured document to extract a style label and text data corresponding to the style label in the target structured document;

[0011] generating a target text and a style rule matched with the target text according to the style label and the text data.

[0012] In one embodiment, the determination of a style instruction corresponding to the style rule according to a style attribute of the style rule comprises:

[0013] generating a normalized style feature vector corresponding to the style rule;

[0014] mapping the normalized style feature vector into a style instruction according to a style attribute of the style rule.

[0015] In one of the embodiments, the mapping the normalized style feature vector into a style instruction according to a style attribute of the style rule comprises:

[0016] in a case where the style attribute of the style rule is a global style attribute, mapping the normalized style feature vector into a global style instruction resolvable by a global rendering component based on a resolution manner corresponding to the global rendering component; and / or,

[0017] in a case where the style attribute of the style rule is a differential style attribute, mapping the normalized style feature vector into a differential style instruction resolvable by a target differential rendering component based on a resolution manner corresponding to the target differential rendering component.

[0018] In one of the embodiments, the resolving the target structured document to obtain a target text and at least one style rule matched with the target text comprises:

[0019] resolving the target structured document to obtain a target text and at least one candidate style rule matched with the target text;

[0020] determining a weight score of the candidate style rule according to style information corresponding to the candidate style rule;

[0021] determining a style rule matched with the target text from the candidate style rules according to the weight score.

[0022] In one of the embodiments, the determining a weight score of the candidate style rule according to style information corresponding to the candidate style rule comprises:

[0023] determining an element score corresponding to the candidate style rule according to an element type corresponding to the candidate style rule; determining an inheritance level score corresponding to the candidate style rule according to source information corresponding to the candidate style rule; determining a specificity score corresponding to the candidate style rule according to a selector type corresponding to the candidate style rule; determining a declaration order score corresponding to the candidate style rule according to a declaration time corresponding to the candidate style rule;

[0024] determining the weight score of the candidate style rule based on the element score, the inheritance level score, the specificity score and the declaration order score.

[0025] In a second aspect, the present application provides a text rendering device, comprising:

[0026] an obtaining module, configured to obtain a target structured document, and parse the target structured document to obtain a target text and at least one style rule matched with the target text;

[0027] a determining module, configured to determine a style instruction corresponding to the style rule according to a style attribute of the style rule, the style attribute comprising at least one of a global style attribute and a differential style attribute;

[0028] a rendering module, configured to render the target text respectively by using a component corresponding to the style instruction to obtain an initial rendering text, and merge the initial rendering text to obtain a target rendering text.

[0029] In one of the embodiments, the obtaining module is further configured to:

[0030] parse the target structured document to extract a style label and text data corresponding to the style label in the target structured document;

[0031] generate a target text and a style rule matched with the target text according to the style label and the text data.

[0032] In one of the embodiments, the determining module is further configured to:

[0033] generate a standardized style feature vector corresponding to the style rule;

[0034] map the standardized style feature vector to a style instruction according to the style attribute of the style rule.

[0035] In one of the embodiments, the determining module is further configured to:

[0036] in a case where the style attribute of the style rule is a global style attribute, map the standardized style feature vector to a global style instruction resolvable by a global rendering component based on a parsing manner corresponding to the global rendering component; and / or,

[0037] in a case where the style attribute of the style rule is a differential style attribute, map the standardized style feature vector to a differential style instruction resolvable by a target differential rendering component based on a parsing manner corresponding to the target differential rendering component.

[0038] In one of the embodiments, the obtaining module is further configured to:

[0039] parse the target structured document to obtain a target text and at least one candidate style rule matched with the target text;

[0040] determine a weight score of the candidate style rule according to the style information corresponding to the candidate style rule;

[0041] determine a style rule matched with the target text from the candidate style rules according to the weight score.

[0042] In one of embodiments, the obtaining module is further configured to:

[0043] determine an element score corresponding to the candidate style rule according to an element type corresponding to the candidate style rule; determine an inheritance level score corresponding to the candidate style rule according to source information corresponding to the candidate style rule; determine a specificity score corresponding to the candidate style rule according to a selector type corresponding to the candidate style rule; and determine a declaration order score corresponding to the candidate style rule according to a declaration time corresponding to the candidate style rule.

[0044] determine a weight score of the candidate style rule based on the element score, the inheritance level score, the specificity score and the declaration order score.

[0045] In a third aspect, the embodiments of the present disclosure further provide a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method in any of the embodiments of the present disclosure when executing the computer program.

[0046] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the method in any of the embodiments of the present disclosure.

[0047] In a fifth aspect, the embodiments of the present disclosure further provide a computer program product. The computer program product includes a computer program, and the computer program is executed by a processor to implement the steps of the method in any of the embodiments of the present disclosure.

[0048] The aforementioned text rendering method, apparatus, computer device, computer-readable storage medium, and computer program product, when performing text rendering, acquire and parse the target structured document to obtain the target text and corresponding style rules. Based on the style attributes of the style rules, corresponding style instructions are determined. Initial rendered text is obtained by rendering each text using the components corresponding to the style instructions. The initial rendered text is then merged to obtain the target rendered text, thus achieving fast and accurate text rendering and ensuring the text rendering effect. During rendering, different style instructions are determined for style rules with different style attributes, enabling the use of corresponding components for rendering. Even with limitations in the rendering functionality of the rendering components, complex text styles can be rendered by generating style instructions in a targeted manner, ensuring both global and differential style rendering, making it suitable for more application scenarios. The requirements for the rendering components are low; through the embodiments of this disclosure, complex text style rendering can be achieved using lightweight components, effectively improving the rendering effect. Attached Figure Description

[0049] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 This is a flowchart illustrating a text rendering method in one embodiment;

[0051] Figure 2 This is a flowchart illustrating the text rendering method in another embodiment;

[0052] Figure 3 This is a flowchart illustrating the text rendering method in another embodiment;

[0053] Figure 4 This is a flowchart illustrating the text rendering method in another embodiment;

[0054] Figure 5 This is a structural block diagram of a text rendering device in one embodiment;

[0055] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0056] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not used to limit the present application.

[0057] In one embodiment, as shown in Figure 1 A text rendering method is provided, and the present embodiment is exemplarily described by taking the method applied to a terminal. It should be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and can be realized through the interaction of the terminal and the server. In the present embodiment, the method includes the following steps:

[0058] In step S110, a target structured document is obtained, and the target structured document is parsed to obtain a target text and at least one style rule matched with the target text.

[0059] Exemplarily, the target structured document is obtained, wherein the target structured document can be a document corresponding to a rendering task in a current scenario. In some examples, the target structured document can be automatically obtained according to the rendering task, or can be obtained by prior configuration. In some examples, the target structured document can include an HTML (HyperText Markup Language) document.

[0060] Optionally, the target structured document is parsed to obtain the target text and the matched style rule. In some examples, a parser can be constructed by using a preset semantic analysis algorithm, and the target structured document is parsed by using the parser to obtain the target text and the corresponding style rule.

[0061] In some possible implementation manners, the parser scans the target structured document line by line, identifies and extracts style labels (such as and tagged wrapped content. For example, for Example text The parser identifies (Paragraph tag), (bold tag), and "example text" within the tag; extract the text information without all tags from the content wrapped by the tag to form the target text; the parser analyzes the style information contained in the tag (including the semantic style brought by the tag itself and the explicitly defined style attributes) to form the corresponding style rule; record the association of each target text and the corresponding style rule to form a mapping, for example, "example text" may be associated with​ a paragraph style of the label and a bold style of the label, the parser can store the association as a correspondence of "text node→[paragraph style, bold style]". In some examples, one target text can correspond to one or more style rules, which can be determined according to the target structured document in the actual application scenario.

[0062] In step S120, a style instruction corresponding to the style rule is determined according to a style attribute of the style rule, the style attribute including at least one of a global style attribute and a differential style attribute.

[0063] For example, the corresponding style instruction is determined according to the style attribute of the style rule. In some examples, the style rule can include a basic style rule applied to the entire target text, i.e., a style rule of a global style attribute; the style rule can also include a differential style rule applied to part of the content in the target text, i.e., a style rule of a local style attribute.

[0064] Optionally, different style rules can be rendered by different components, and different components can correspond to different types of style instructions. According to the style attribute of the style rule, the type of the style instruction corresponding to the style rule is determined, and the style instruction is generated.

[0065] In step S130, the target text is rendered by using the components corresponding to the style instructions respectively, to obtain initial rendering texts, and the initial rendering texts are merged to obtain a target rendering text.

[0066] For example, the target text is rendered by using the components corresponding to the style instructions. In some examples, when the style rule corresponding to the target text includes multiple style rules of different style attributes, the target text is rendered by using different components respectively to obtain multiple initial rendering texts. The initial rendering texts are merged to obtain the final target rendering text.

[0067] In the text rendering, the target structured document is obtained and parsed to obtain the target text and the corresponding style rule. According to the style attribute of the style rule, the corresponding style instruction is determined, the initial rendering text is obtained by rendering the components corresponding to the style instruction respectively, and the target rendering text is obtained by merging the initial rendering text. Therefore, the text rendering is quickly and accurately realized, and the text rendering effect is ensured. In the rendering, different style instructions are determined for different style attributes of the style rule, so that the corresponding components can be used for rendering. In the case of limited rendering function of the rendering component, the rendering of the complex style of the text is realized by generating the style instruction in a targeted manner, the global style rendering and the differential style rendering are ensured to be realized, and more application scenarios are applicable. The requirement for the component required for rendering is low. According to the embodiment of the present disclosure, the complex style rendering of the text can be realized by using a lightweight component, and the rendering effect is effectively improved.

[0068] In one embodiment, as shown in Figure 2 The parsing of the target structured document obtains the target text and at least one style rule matched with the target text.

[0069] In step S111, the target structured document is parsed to extract the style label in the target structured document and the text data corresponding to the style label.

[0070] In step S112, the target text and the style rule matched with the target text are generated according to the style label and the text data.

[0071] For example, when determining the target text and the style rule, the target structured document is parsed to extract the style label in the target structured text and the text data corresponding to the style label. In some examples, the target structured document usually includes two parts of content. One part is pure text data, that is, the actual literal content in the document, such as paragraph text, title text, etc. The other part is the associated style rule, wherein the style rule can be defined by a style label or a cascading style sheet, including but not limited to style information such as font size, color, bold, indentation, etc. The style label and the corresponding text data can be obtained by semantic parsing.

[0072] Optionally, the target text is obtained according to the text data, the corresponding style rule is obtained according to the style label, and the target text and the style rule matched with the target text are generated based on the corresponding relationship between the text data and the style label.

[0073] The embodiment of the present disclosure analyzes a target structured document, extracts style tags and text data, generates target text and style rules, and uses a semantic analysis method to quickly and accurately extract style tags and text data from the target structured document, and then generate target text and style rules, thereby improving text rendering efficiency, ensuring the accuracy of the generated target text and style rules, and improving rendering effect.

[0074] In one embodiment, as shown in Figure 3 The method comprises the following steps:

[0075] S121, generating a standardized style feature vector corresponding to the style rule;

[0076] S122, according to the style attribute of the style rule, mapping the standardized style feature vector into a style instruction.

[0077] Exemplarily, according to the style rule, a standardized style feature vector corresponding to the style rule is generated. In some examples, the style attributes of different units are converted into a unified unit (such as converting em, rem, % and the like into px), all color representations (such as red, #FF0000, rgb(255,0,0)) are uniformly converted into ARGB (Alpha Red Green Blue, Alpha channel + red green blue color model) format (such as #FFFF0000), font names are mapped to standard fonts supported by the system (such as mapping "Microsoft YaHei" to "sans-serif"), redundant units are removed (such as font-size: 16px→16), and are normalized to integers or floating-point numbers; text style dimension information, layout attribute dimension information, spacing attribute dimension information, and special effect dimension information are extracted from the preprocessed style rule; the extracted information is converted into a fixed-length numerical vector, each dimension corresponds to a position in the vector; each dimension in the vector is normalized to ensure that all values are within a unified range (such as [0,1]), wherein the value of the data attribute is mapped to [0,1] through linear scaling (such as value / max_value); the value of the enumeration attribute is converted into a binary vector using One-Hot Encoding (such as alignment left=1,0,0; center=0,1,0; right=0,0,1); for undefined style attributes, use default values to fill in special values (such as -1) in the vector; and generate a standardized style feature vector.

[0078] Optionally, based on the style attributes corresponding to the style rules, the corresponding style instruction type is determined, and the standardized style feature vector is mapped to the style instruction corresponding to that style instruction type.

[0079] In this embodiment, a standardized style feature vector is generated according to style rules and mapped to style instructions. This enables the style rules to be quickly and accurately converted into style instructions that the component can process. Based on style attributes, the mapping is implemented to convert different style attributes into different style instructions. Text rendering can also be achieved in complex style scenarios, making it suitable for more application scenarios.

[0080] In one embodiment, mapping the standardized style feature vector to style instructions based on the style attributes of the style rules includes:

[0081] When the style attribute of the style rule is a global style attribute, based on the parsing method corresponding to the global rendering component, the standardized style feature vector is mapped to a global style instruction that the global rendering component can parse; and / or,

[0082] When the style attribute of the style rule is a differential style attribute, the standardized style feature vector is mapped to a differential style instruction that can be parsed by the target differential rendering component based on the parsing method corresponding to the target differential rendering component.

[0083] For example, when the style attribute of a style rule is a global style, the corresponding style instruction type is determined based on the parsing method of the global rendering component, and the standardized style feature vector is mapped to a global style instruction that the global rendering component can parse. In some examples, the style instruction type corresponding to the style rule of a global style may include a global style instruction, and the interface parameters corresponding to the global style instruction match the global rendering component.

[0084] Optionally, when the style attribute of the style rule is a difference style attribute, the corresponding style instruction type is determined based on the parsing method of the target difference rendering component, and the standardized style feature vector is mapped to a difference style instruction that the target difference rendering component can parse. In some examples, the style instruction type corresponding to the style rule of the difference style may include a difference style instruction, and the interface parameters corresponding to the difference style instruction match the target difference rendering component. In some examples, the target difference rendering component may be a sub-component nested within a global rendering component, which can be used to implement local rendering within text.

[0085] In this embodiment, global style attributes and differential style attributes are mapped to corresponding style instructions respectively. Style instructions are mapped in a targeted manner for different style rules. Even in the case of lightweight components, style instructions can be quickly and accurately identified and text rendered.

[0086] In an embodiment, the parsing the target structured document to obtain a target text and at least one style rule matched with the target text comprises:

[0087] parsing the target structured document to obtain a target text and at least one candidate style rule matched with the target text;

[0088] determining a weight score of the candidate style rule according to style information corresponding to the candidate style rule;

[0089] determining a style rule matched with the target text from the candidate style rules according to the weight score.

[0090] Exemplarily, style conflict detection and merging is performed through style weight calculation. A target structured text is parsed to obtain a candidate style rule matched with a target text, and the candidate style rule can include one or more. A weight score of the candidate style rule is determined according to style information corresponding to the candidate style rule, and the weight score can be determined after weighting based on scores in different dimensions. The weight score can be determined according to an actual application scenario.

[0091] Optionally, a style rule matched with the target text is determined based on the weight score. In some examples, the higher the weight score is, the higher the priority of the corresponding candidate style rule is. In the case of conflict between the candidate style rules, the candidate style rule with the higher weight score is determined as the style rule corresponding to the target text.

[0092] In the embodiments of the present disclosure, the weight score is determined based on the style information, and the style rules are screened, so that redundant style rules can be quickly and accurately screened out, the accuracy and reliability of the finally obtained style rules are ensured, the text rendering effect is improved, the problem of rendering failure caused by style conflicts or repetition is avoided, and the present disclosure is suitable for more application scenarios.

[0093] In an embodiment, the determining the weight score of the candidate style rule according to the style information corresponding to the candidate style rule comprises:

[0094] determining an element score corresponding to the candidate style rule according to an element type corresponding to the candidate style rule; determining an inheritance level score corresponding to the candidate style rule according to source information corresponding to the candidate style rule; determining a specificity score corresponding to the candidate style rule according to a selector type corresponding to the candidate style rule; and determining a declaration order score corresponding to the candidate style rule according to a declaration time corresponding to the candidate style rule;

[0095] Based on the element score, the inheritance hierarchy score, the specificity score, and the declaration order score, a weight score of the candidate style rule is determined.

[0096] For example, an element score is assigned based on the element type associated with the style rule (e.g., block-level elements 、 with inline elements , a weight difference, the core content element weight is higher than the auxiliary element); determining an inheritance level score based on source information corresponding to the candidate rule, wherein a directly applied style weight is higher than an inherited style, for example, a parent node sets "color:black", but the current node directly sets "color:red", then the "red" weight is higher; determining a specificity score according to a selector type, in some examples, for a style rule defined by a CSS (Cascading Style Sheets) selector, a specificity score is assigned according to the selector type, for example, an ID selector #id> a class selector.class> an element selector p> a wildcard, the higher the specificity, the higher the specificity score; determining a declaration order score based on a declaration time corresponding to the candidate style rule, wherein the style rules are sorted according to the declaration time, and the style rule declared later has a higher weight than the style rule declared earlier.

[0097] Optionally, the weight score of the candidate style rule is determined according to the element score, the inheritance level score, the specificity score and the declaration order score. In some possible implementations, a weight coefficient is set for each of the four dimensions, and the weighted weight score is calculated for the candidate style rules in conflict. Among the candidate style rules in conflict, the style rule with the highest weight score is determined as the final effective style, that is, the style rule corresponding to the target text, and the remaining conflicting styles are discarded.

[0098] In some examples, the effective style retained after the conflict is processed is combined with the non-conflicting candidate style rules of the target text to form all the style rules corresponding to the target text.

[0099] The embodiments of the present disclosure determine scores in multiple dimensions based on the element type, the source information, the selector type and the specificity score, and finally obtain the weight score, which further improves the accuracy and reliability of the weight score, ensures the accuracy of the selected style rules, improves the text rendering effect, reduces the data processing workload during text rendering, and improves the text rendering efficiency.

[0100] Figure 4 To show a flowchart of a text rendering according to an example embodiment, refer to Figure 4 As shown, the target structured document can include an HTML (HyperText Markup Language) document, and when text rendering is performed, an HTML tag parser is constructed, the HTML document is decoupled into a pure text data set (i.e., target text) and an associated style rule set (i.e., corresponding style rules) through semantic analysis, and a one-to-many mapping relationship between a text node and a style rule is established; a style optimization processor is designed, and the following operations are performed on the style rule set: a) style conflict detection and merging through style weight calculation and cascade rules, b) generation of a standardized style feature vector, and establishment of a one-to-one correspondence between a text node and a style feature; a dynamic style mapping engine is created, the standardized style feature vector is converted into a style instruction set of a target platform based on style specifications of a cross-platform UI (User Interface) framework, and the following mapping relationships are achieved: a) mapping of a common style attribute (i.e., global style) to a platform basic text Text component (i.e., global rendering component), b) mapping of a differential style attribute to a platform Span component (i.e., target differential rendering component); rendering is achieved, and the same source style Span component is instantiated and reused based on a batch processing mechanism of style similarity.

[0101] In some examples, the conflict processing adopts a multi-dimensional priority algorithm, contains a four-tuple evaluation model of element weight, inheritance level, selector specificity and declaration order, and determines the final effective style through linear weighting calculation. In some examples, the dynamic style mapping engine contains a bidirectional binding module, supports dynamic modification of the mapped style through a reactive programming interface, and the modification operations include: a) real-time addition, deletion and modification operations of style attributes, b) dynamic mounting and unloading of event listeners.

[0102] Through the embodiment, intelligent parsing of HTML text to component-parsable instructions is achieved, and pure text content and associated style attributes are accurately extracted; a style optimization algorithm is adopted, and rendering performance is significantly improved through extraction and deduplication processing; dynamic interaction capability is supported, complete style management and event processing APIs (Application Programming Interface) are provided in addition to basic rendering; and an efficient rendering scheme is achieved based on a lightweight Text control.

[0103] It should be understood that although the steps in the flowcharts involved in the embodiments described above are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the embodiments described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of the steps or stages is not necessarily sequential, but can be alternately or alternately executed with at least part of other steps or steps or stages in other steps.

[0104] Based on the same inventive concept, the embodiments of the present application also provide a text rendering device for implementing the above-mentioned text rendering method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more text rendering device embodiments provided below can refer to the limitations of the text rendering method in the above text, which will not be repeated here.

[0105] In one exemplary embodiment, as shown in Figure 5 A text rendering device 500 is provided, comprising:

[0106] The acquisition module 510 is configured to acquire a target structured document, and parse the target structured document to obtain a target text and at least one style rule matched with the target text;

[0107] The determination module 520 is configured to determine a style instruction corresponding to the style rule according to a style attribute of the style rule, the style attribute including at least one of a global style attribute and a differential style attribute;

[0108] The rendering module 530 is configured to render the target text respectively by using components corresponding to the style instruction to obtain initial rendering text, and merge the initial rendering text to obtain target rendering text.

[0109] In one embodiment, the acquisition module is further configured to:

[0110] Parse the target structured document to extract a style label and text data corresponding to the style label in the target structured document;

[0111] Generate a target text and a style rule matched with the target text according to the style label and the text data.

[0112] In one embodiment, the determination module is further configured to:

[0113] generate a normalized style feature vector corresponding to the style rule;

[0114] map the normalized style feature vector into a style instruction according to a style attribute of the style rule.

[0115] In one of the embodiments, the determining module is further configured to:

[0116] in a case where the style attribute of the style rule is a global style attribute, map the normalized style feature vector into a global style instruction resolvable by a global rendering component based on a resolution manner corresponding to the global rendering component; and / or,

[0117] in a case where the style attribute of the style rule is a differential style attribute, map the normalized style feature vector into a differential style instruction resolvable by a target differential rendering component based on a resolution manner corresponding to the target differential rendering component.

[0118] In one of the embodiments, the obtaining module is further configured to:

[0119] obtain a target text and at least one candidate style rule matched with the target text by parsing the target structured document;

[0120] determine a weight score of the candidate style rule according to style information corresponding to the candidate style rule;

[0121] determine a style rule matched with the target text from the candidate style rules according to the weight score.

[0122] In one of the embodiments, the obtaining module is further configured to:

[0123] determine an element score corresponding to the candidate style rule according to an element type corresponding to the candidate style rule; determine an inheritance level score corresponding to the candidate style rule according to source information corresponding to the candidate style rule; determine a specificity score corresponding to the candidate style rule according to a selector type corresponding to the candidate style rule; and determine a declaration order score corresponding to the candidate style rule according to a declaration time corresponding to the candidate style rule;

[0124] determine a weight score of the candidate style rule based on the element score, the inheritance level score, the specificity score and the declaration order score.

[0125] The various modules in the text rendering apparatus described above can be implemented wholly or partially by software, hardware, and combinations thereof. The various modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so as to be called and executed by a processor to perform operations corresponding to the various modules.

[0126] In an exemplary embodiment, a computer device, which can be a server, has an internal structure diagram as shown in Figure 6 The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store data involved in the method described in the embodiment, such as a target structured document. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to communicate with terminals outside through a network connection. The computer program is executed by the processor to implement a text rendering method.

[0127] Those skilled in the art can understand that Figure 6 The structure shown in the above

[0128] In an embodiment, a computer device is also provided, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0129] In an embodiment, a computer readable storage medium is provided, which stores a computer program. The computer program is executed by a processor to implement the steps in the above method embodiments.

[0130] In an embodiment, a computer program product is provided, which includes a computer program. The computer program is executed by a processor to implement the steps in the above method embodiments.

[0131] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.

[0132] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments of each method. In the embodiments provided in the present application, any reference to memory, database or other medium can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.

[0133] Any technical features in the above embodiments can be combined, and for the sake of brevity, not all possible combinations are described above, however, any combination of these technical features is deemed to be within the scope of the present application.

[0134] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method of text rendering, characterized by, The method comprises: obtaining a target structured document, and parsing the target structured document to obtain target text and at least one style rule matched with the target text; determining a style instruction corresponding to the style rule according to a style attribute of the style rule, the style attribute comprising at least one of a global style attribute and a differential style attribute; rendering the target text by using a component corresponding to the style instruction to obtain initial rendered text, and merging the initial rendered text to obtain target rendered text.

2. The method of claim 1, wherein, The parsing of the target structured document to obtain target text and at least one style rule matched with the target text comprises: parsing the target structured document to extract a style label in the target structured document and text data corresponding to the style label; generating target text and a style rule matched with the target text according to the style label and the text data.

3. The method of claim 1, wherein, The determination of a style instruction corresponding to the style rule according to a style attribute of the style rule comprises: generating a standardized style feature vector corresponding to the style rule; mapping the standardized style feature vector into a style instruction according to the style attribute of the style rule.

4. The method of claim 3, wherein, The mapping of the standardized style feature vector into a style instruction according to the style attribute of the style rule comprises: in a case where the style attribute of the style rule is a global style attribute, mapping the standardized style feature vector into a global style instruction that can be parsed by a global rendering component based on a parsing manner corresponding to the global rendering component; and / or in a case where the style attribute of the style rule is a differential style attribute, mapping the standardized style feature vector into a differential style instruction that can be parsed by a target differential rendering component based on a parsing manner corresponding to the target differential rendering component.

5. The method of claim 1, wherein, The parsing of the target structured document to obtain target text and at least one style rule matched with the target text comprises: parsing the target structured document to obtain target text and at least one candidate style rule matched with the target text; determining a weight score of the candidate style rule according to style information corresponding to the candidate style rule; determining a style rule matched with the target text from the candidate style rules according to the weight score.

6. The method of claim 5, wherein, The determination of a weight score of the candidate style rule according to style information corresponding to the candidate style rule comprises: determining an element score corresponding to the candidate style rule according to an element type corresponding to the candidate style rule; determining an inheritance level score corresponding to the candidate style rule according to source information corresponding to the candidate style rule; determining a specificity score corresponding to the candidate style rule according to a selector type corresponding to the candidate style rule; and determining a declaration order score corresponding to the candidate style rule according to a declaration time corresponding to the candidate style rule; determining the weight score of the candidate style rule based on the element score, the inheritance level score, the specificity score, and the declaration order score.

7. A text rendering apparatus, characterized by comprising: The apparatus comprises: An acquisition module is configured to acquire a target structured document, and parse the target structured document to obtain a target text and at least one style rule matched with the target text; A determination module is configured to determine a style instruction corresponding to the style rule according to a style attribute of the style rule, the style attribute comprising at least one of a global style attribute and a differential style attribute; A rendering module is configured to render the target text by using a component corresponding to the style instruction to obtain initial rendering texts, and combine the initial rendering texts to obtain a target rendering text.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.