Text processing method and device, electronic equipment and storage medium

By setting pseudo-elements in the browser and merging them with text content elements, the compatibility issues of text display in different browsers are resolved, the operation process is simplified, and the user experience is improved.

CN116881592BActive Publication Date: 2026-04-24CRSC INFORMATION IND CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CRSC INFORMATION IND CO LTD
Filing Date
2023-07-12
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

When displaying text in different browsers, existing technologies require setting the display page attributes for each browser, which is cumbersome and incompatible with multiple browsers, thus reducing the user experience.

Method used

By obtaining the text content element to be processed, pseudo-elements are set based on the preset attribute information of the text parent element to match the browser attributes, and positioning tags are used to merge the pseudo-elements with the text content element to generate the target display text.

Benefits of technology

It eliminates the need to repeatedly set display page properties for different browsers, simplifying operations, improving user experience, and achieving compatible display across different browsers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116881592B_ABST
    Figure CN116881592B_ABST
Patent Text Reader

Abstract

The application discloses a text processing method and device, electronic equipment and storage medium, and relates to the technical field of text processing. The method comprises the following steps: acquiring a to-be-processed text content element; setting a pseudo element corresponding to the to-be-processed text content element based on preset attribute information of a text parent element, wherein the preset attribute information of the text parent element matches attribute information of a browser; and fusing the pseudo element corresponding to the to-be-processed text content element with the to-be-processed text content element based on a positioning label to obtain a target display text. The to-be-processed text content element can be fused with the pseudo element corresponding to the to-be-processed text content element based on the positioning label, so that the target display text can be displayed in an optimal manner, and the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text processing technology, specifically to a text processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] Displaying text in different browsers requires setting the display range for each browser. However, if the text is too long, setting the display page attributes for each browser is not only cumbersome but also incompatible with multiple browser types, thus reducing the user experience. Summary of the Invention

[0003] Therefore, this application provides a text processing method, apparatus, electronic device, and storage medium to solve the problem of how to automatically display text in different types of browsers.

[0004] In a first aspect, embodiments of this application provide a text processing method, the method comprising: obtaining a text content element to be processed; setting a pseudo-element corresponding to the text content element to be processed based on preset attribute information of a text parent element, wherein the preset attribute information of the text parent element matches the attribute information of the browser; and merging the pseudo-element corresponding to the text content element to be processed with the text content element to be processed based on a positioning tag to obtain the target display text.

[0005] Secondly, embodiments of this application provide a text processing apparatus, including: an acquisition module configured to acquire text content elements to be processed; a setting module configured to set pseudo-elements corresponding to the text content elements to be processed based on preset attribute information of the text parent element; and a fusion module configured to fuse the pseudo-elements corresponding to the text content elements to be processed with the text content elements to be processed based on positioning tags to obtain target display text.

[0006] Thirdly, embodiments of this application provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform any of the text processing methods in the embodiments of this application.

[0007] Fourthly, embodiments of this application provide a readable storage medium storing multiple instructions; these instructions are used by a processor to load and execute any one of the text processing methods in embodiments of this application.

[0008] The text processing method, apparatus, electronic device, and storage medium in this application obtain the text content element to be processed and determine the text content to be displayed; based on the attribute information of a preset text parent element, a pseudo-element corresponding to the text content element to be processed is set, wherein the attribute information of the preset text parent element matches the attribute information of the browser, so that the pseudo-element can have the attribute information of different browsers, which facilitates the subsequent fusion of different types of elements without the need to set the display page for different browsers, reducing the complexity of operation; based on the positioning tag, the pseudo-element corresponding to the text content element to be processed is merged with the text content element to be processed to obtain the target display text, so that the text content element to be processed can be merged with the pseudo-element corresponding to the text content element based on the positioning tag, thereby enabling the target display text to be displayed in an optimal way and improving the user experience. Attached Figure Description

[0009] The accompanying drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed description of exemplary embodiments with reference to the accompanying drawings, in which:

[0010] Figure 1 This is a schematic flowchart illustrating the text processing method provided in an embodiment of this application.

[0011] Figure 2 This diagram illustrates the target display text provided in an embodiment of this application.

[0012] Figure 3 This diagram illustrates the target display text provided in an embodiment of this application.

[0013] Figure 4 This diagram illustrates the target display text provided in an embodiment of this application.

[0014] Figure 5 This is a block diagram illustrating the composition of a text processing apparatus provided in an embodiment of this application.

[0015] Figure 6 This is a block diagram illustrating the composition of an electronic device provided in an embodiment of this application. Detailed Implementation

[0016] The specific embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the application. Those skilled in the art can implement this application without requiring some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.

[0017] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0018] When displaying text in different browsers, the "-webkit-line-clamp" property is usually set in the Cascading Style Sheet (CSS) to limit the number of lines that a block container may contain.

[0019] CSS is a computer language used to represent the style of documents such as Hyper Text Markup Language (HTML) or Extensible Markup Language (XML).

[0020] However, the above settings only work for browsers with a WebKit engine and are not applicable to other browsers, reducing system compatibility. Furthermore, when other browsers display text exceeding the preset length threshold, settings need to be configured for the specific page being displayed in each browser, which is not only cumbersome but also incompatible with multiple browser types simultaneously, thus degrading the user experience.

[0021] This application proposes a text processing method, apparatus, electronic device, and storage medium to solve the above-mentioned problems.

[0022] Figure 1 This diagram illustrates a flow chart of a text processing method provided in an embodiment of this application. This text processing method can be applied to a text processing device. Figure 1 As shown, it includes:

[0023] Step S101: Obtain the text content elements to be processed.

[0024] In some alternative implementations, text information can be collected from user input or read from a database; the text content elements to be processed can then be extracted from the text information.

[0025] The text information includes text content elements to be processed, determined based on display requirements and other needs. For example, the text content element to be processed might be a news article or similar information that needs to be displayed on a webpage.

[0026] Step S102: Based on the preset attribute information of the text parent element, set the pseudo element corresponding to the text content element to be processed.

[0027] The preset attributes of the parent text element match the browser's attributes. The pseudo-element corresponding to the text content element to be processed is used to add a preset symbol at a preset position on the text content element to be processed in a selector.

[0028] For example, adding a preset symbol to the first line of the text content element to be processed in a selector, or adding a preset symbol to the last line of the text content element to be processed in the selector.

[0029] Step S103: Based on the positioning tags, merge the pseudo-elements corresponding to the text content elements to be processed with the text content elements to be processed to obtain the target display text.

[0030] The positioning tag is used to locate the pseudo-element corresponding to the text content element to be processed, so as to determine the specific position of the pseudo-element corresponding to the text content element to be processed and merged into it.

[0031] For example, if the positioning label is determined to be the bottom right corner of the identification text, then while displaying the text content element to be processed, a pseudo-element (e.g., certain specific symbols that can represent the attribute information of the preset text parent element) can be displayed at the bottom right corner of the text content element to be processed.

[0032] In this embodiment, the text content element to be processed is obtained, and the text content to be displayed is determined. Based on the preset attribute information of the text parent element, a pseudo-element corresponding to the text content element to be processed is set. The preset attribute information of the text parent element matches the attribute information of the browser, so that the pseudo-element can have different browser attribute information, which facilitates the subsequent fusion of different types of elements without having to set the display page for different browsers, reducing the complexity of the operation. Based on the positioning tag, the pseudo-element corresponding to the text content element to be processed is merged with the text content element to be processed to obtain the target display text. This allows the text content element to be processed to be merged with the pseudo-element corresponding to the text content element based on the positioning tag, so that the target display text can be displayed in the optimal way, improving the user experience.

[0033] This application provides another possible implementation, wherein the positioning tag includes a tag positioned at a preset location. Step S103, which involves fusing the pseudo-element corresponding to the text content element to be processed with the text content element to be processed based on the positioning tag to obtain the target display text, can be implemented as follows: positioning the pseudo-element corresponding to the text content element to be processed at a preset location; superimposing the pseudo-element corresponding to the text content element to be processed with the processed text content element to generate the target display text.

[0034] The length of the text content element being processed is unknown, while the height of the text content element being processed can be preset.

[0035] By positioning the pseudo-element corresponding to the text content element to be processed in a preset position (such as the bottom right corner of the entire text), it is easy to overlay the pseudo-element corresponding to the text content element to be processed on top of the text content element to be processed when the pseudo-element corresponding to the text content element to be processed and the text content element to be processed are superimposed, so as to adapt to the display page size in different browsers.

[0036] In some optional implementations, the preset attribute information of the text parent element includes at least one of the following: preset display height, preset line height information, relative positioning information, and preset hidden area information.

[0037] Among them, relative positioning information is used to represent the display position information of the preset text in the browser, and preset hidden area information represents the area information used to hide overflow text. Overflow text is the text in the text content element to be processed that exceeds the display area range of the preset text.

[0038] For example, if the preset text display area is 3*10 (line height * number of characters per line), and the text content element to be displayed is 5*20, then the corresponding overflow text is the remaining text content obtained by subtracting 3*10 from 5*20.

[0039] By storing overflowing text in a preset hidden area using preset hidden area information, the final displayed text can conform to the requirements of the preset text parent element (e.g., the size of the preset text display area of ​​a certain browser), flexibly adapting to the display areas of different browsers and improving the user experience.

[0040] In some optional implementations, the preset attribute information of the text element further includes: preset background information; the setting of the pseudo-element corresponding to the text content element to be processed based on the preset attribute information of the text parent element in step S102 can be implemented in the following way:

[0041] Based on preset line height information, determine the line height of the pseudo-element corresponding to the text content element to be processed; based on preset background information, determine the background information of the pseudo-element corresponding to the text content element to be processed.

[0042] The preset line height information can also be used to determine the maximum height of the target displayed text, for example, setting the maximum height to 3 times the preset line height.

[0043] Preset background information can represent background color, background image, and other information. For example, the background information of the pseudo-element corresponding to the text content element to be processed can be set to a white background color so that the text content element to be processed can be clearly displayed.

[0044] In some optional implementations, the preset attribute information of the text element also includes: preset character width information; the setting of the pseudo element corresponding to the text content element to be processed based on the preset attribute information of the text parent element in step S102 can be implemented in the following way: determine the display width of the pseudo element corresponding to the text content element to be processed based on the preset character width information.

[0045] For example, if the preset character width information includes the preset character display width (e.g., 3mm, 5mm, etc.), then it can be determined that the display width of the pseudo-element corresponding to the text content element to be processed is 3mm, or an integer multiple of 3mm, etc.

[0046] Based on different preset character display widths, the display width of the pseudo-elements corresponding to the text elements to be processed can be flexibly and dynamically set so that the text content elements to be processed can flexibly adapt to the display areas of different browsers.

[0047] In some alternative implementations, the target displayed text includes: text in the text content element to be processed that matches the display area range of the preset text, and preset hidden area information.

[0048] For example, the preset hidden area information includes hidden symbols represented by ellipses (such as “…”), multiple commas (such as “,,,,,”), and multiple periods (such as “…”).

[0049] For example, if the text element to be processed is "The theme-based education campaign was conducted in two phases from top to bottom starting at the end of May last year and has now basically concluded. The entire theme-based education campaign achieved its expected goals and yielded significant results; organizations at all levels, the general public, and cadres have deeply studied and practiced it," then different target display texts will be obtained for different browsers.

[0050] Figure 2 This diagram illustrates the target text display provided in an embodiment of this application. Figure 2As shown, the target text displays three lines of text, along with ellipses "..." to indicate other undisplayed text. Furthermore, the background color of the target text is white.

[0051] Figure 3 This diagram illustrates the target text display provided in an embodiment of this application. Figure 3 As shown, the target text is displayed against a white background, showing two lines of text, as well as ellipses “…” to indicate other undisplayed text.

[0052] Figure 4 This diagram illustrates the target text display provided in an embodiment of this application. Figure 4 As shown, the target text displays three lines of text, along with an ellipsis "..." to indicate other undisplayed text. Furthermore, it can also display half of the undisplayed text, such as "ear". Its display method is the same as described above. Figure 2 and Figure 3 The display method is completely different.

[0053] By displaying text to different targets, it is possible to adapt to the display area requirements of different browsers, allowing the text content elements to be processed to flexibly adapt to various browsers and improve the user experience.

[0054] In some optional implementations, the pseudo-element corresponding to the text content element to be processed can be set in the pseudo-element selector. The text content element in the pseudo-element selector can be positioned. When the space in the pseudo-element selector is insufficient to display the text content element to be processed, preset hidden area information (such as ellipses "...") can be used to represent overflowing text.

[0055] With the above settings, there is no need to set different page attributes for different browsers, or to determine the target display text based on the number of characters contained in the text content element to be processed. This simplifies the display operation of the text content element to be processed, and enables the target display text to be displayed in the best way, thereby improving the user experience.

[0056] Figure 5 This diagram illustrates the composition of a text processing apparatus provided in an embodiment of this application. Figure 5 As shown, the text processing device 500 includes, but is not limited to, the following modules:

[0057] The acquisition module 501 is configured to acquire text content elements to be processed.

[0058] Module 502 is configured to set the pseudo-element corresponding to the text content element to be processed based on the preset attribute information of the text parent element.

[0059] The fusion module 503 is configured to merge the pseudo-elements corresponding to the text content elements to be processed with the text content elements to be processed based on the positioning tags, so as to obtain the target display text.

[0060] It should be noted that the text processing device in this embodiment can execute any of the text processing methods in this application embodiment, which will not be described in detail here.

[0061] In this embodiment, the acquisition module acquires the text content element to be processed, clarifying the text content to be displayed. The setting module sets a pseudo-element corresponding to the text content element based on preset attribute information of the parent text element. The preset attribute information of the parent text element matches the browser's attribute information, allowing the pseudo-element to possess different browser attribute information. This facilitates the subsequent fusion of different types of elements without requiring separate display page settings for different browsers, reducing operational complexity. The fusion module, based on positioning tags, merges the pseudo-element corresponding to the text content element with the text content element to obtain the target display text. This ensures that the text content element can be merged with its corresponding pseudo-element based on positioning tags, allowing the target display text to be displayed in an optimal manner, improving the user experience.

[0062] It is worth mentioning that all modules involved in this embodiment are logical modules. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. Furthermore, to highlight the innovative aspects of this application, this embodiment does not introduce units that are not closely related to solving the technical problem proposed in this application; however, this does not mean that other units are absent from this embodiment.

[0063] Figure 6 This is a block diagram illustrating the composition of an electronic device provided in an embodiment of this application.

[0064] like Figure 6 As shown, the computing device 600 includes an input device 601, an input interface 602, a central processing unit 603, a memory 604, an output interface 605, and an output device 606. The input interface 602, central processing unit 603, memory 604, and output interface 605 are interconnected via a bus 610. The input device 601 and output device 606 are connected to the bus 610 via the input interface 602 and output interface 605, respectively, and are thus connected to other components of the electronic device 600.

[0065] Specifically, input device 601 receives input information from the outside and transmits the input information to central processing unit 603 through input interface 602; central processing unit 603 processes the input information based on computer-executable instructions stored in memory 604 to generate output information, temporarily or permanently stores the output information in memory 604, and then transmits the output information to output device 606 through output interface 605; output device 606 outputs the output information to the outside of computing device 600 for user use.

[0066] In one embodiment, Figure 6 The electronic device 600 shown can be implemented as a network device, which may include: a memory configured to store a program; and a processor configured to run the program stored in the memory to perform any of the text processing methods described in the above embodiments.

[0067] According to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network, and / or installed from a removable storage medium.

[0068] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0069] It is understood that the above embodiments are merely exemplary implementations used to illustrate the principles of this application, and this application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of this application, and these modifications and improvements are also considered to be within the scope of protection of this application.

Claims

1. A text processing method, characterized in that, The method includes: Get the text content element to be processed; Based on the preset attribute information of the text parent element, the pseudo element corresponding to the text content element to be processed is set, and the preset attribute information of the text parent element matches the attribute information of the browser. Based on the positioning tags, the pseudo-elements corresponding to the text content elements to be processed are merged with the text content elements to be processed to obtain the target display text; The positioning tag includes: a tag that positions the location to a preset location; The step of fusing the pseudo-element corresponding to the text content element to be processed with the text content element to obtain the target display text based on the positioning tag includes: Position the pseudo-element corresponding to the text content element to be processed to the preset position; The pseudo-element corresponding to the text content element to be processed and the text content element to be processed are superimposed to generate the target display text; The preset attribute information of the text parent element includes: preset line height information and preset background information; The step of setting the pseudo-element corresponding to the text content element to be processed based on the preset attribute information of the text parent element includes: determining the line height of the pseudo-element corresponding to the text content element to be processed based on the preset line height information; and determining the background information of the pseudo-element corresponding to the text content element to be processed based on the preset background information.

2. The method according to claim 1, characterized in that, The preset attribute information of the text parent element also includes at least one of the following: preset display height, relative positioning information, and preset hidden area information; The relative positioning information is used to characterize the display position information of the preset text in the browser, and the preset hidden area information is used to characterize the area information used to hide the overflow text. The overflow text is the text in the text content element to be processed that exceeds the display area range of the preset text.

3. The method according to claim 2, characterized in that, The preset attribute information of the text parent element also includes: preset character width information; The step of setting the pseudo-element corresponding to the text content element to be processed based on the preset attribute information of the text parent element includes: Based on the preset character width information, the display width of the pseudo-element corresponding to the text content element to be processed is determined.

4. The method according to claim 3, characterized in that, The target displayed text includes: text in the text content element to be processed that matches the display area range of the preset text, and the preset hidden area information.

5. The method according to any one of claims 1 to 4, characterized in that, The process of obtaining the text content elements to be processed includes: Collect text information input by the user, or read the text information from the database; Extract the text content elements to be processed from the text information.

6. A text processing device, characterized in that, include: The acquisition module is configured to acquire text content elements to be processed. The settings module is configured to set the pseudo-element corresponding to the text content element to be processed based on the preset attribute information of the text parent element, and the preset attribute information of the text parent element matches the attribute information of the browser. The fusion module is configured to fuse the pseudo-element corresponding to the text content element to be processed with the text content element to be processed based on the positioning tag to obtain the target display text; The positioning tag includes: a tag that positions the location to a preset location; The fusion module is specifically used to position the pseudo-element corresponding to the text content element to be processed to the preset position; and to overlay the pseudo-element corresponding to the text content element to be processed and the processed text content element to generate the target display text. The preset attribute information of the text parent element includes: preset line height information and preset background information; The setting module is specifically used to: determine the line height of the pseudo-element corresponding to the text content element to be processed based on the preset line height information; and determine the background information of the pseudo-element corresponding to the text content element to be processed based on the preset background information.

7. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the text processing method as described in any one of claims 1 to 5.

8. A readable storage medium storing a plurality of instructions; the plurality of instructions being loaded by a processor and executed by the text processing method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Text display method and device and user terminal

    CN111460349A