The invention relates to the technical field of rich
text processing display, in particular to a method for
processing rich text highlighting through
list display under a Harmony Next App, which comprises the following steps of: firstly, obtaining rich text contents containing
HTML (
Hypertext Markup Language) format tags, analyzing the rich text through
modes such as
regular expression matching, generating node data of a
tree structure, and introducing a dynamic
weight distribution algorithm to optimize tag analysis priority; and reducing redundant data by using a node similarity merging
algorithm. Based on node data, a Harmony OS native component is used for carrying out fine-grained rendering, according to
business logic or keywords input by a user,
font color attributes of a Span component are dynamically adjusted, highlight display is achieved, and a style and rendering logic are decoupled to flexibly configure a highlight strategy. According to the method, a pre-analysis and caching mechanism, lightweight rendering and other strategies are adopted to optimize the performance, and the method is suitable for various scenes such as rich text search keyword highlighting, specific field style emphasizing and multi-theme switching real-time style
adaptation.