Method for automatically correcting style, electronic device and storage medium
By detecting and correcting the style information of e-book pages and utilizing preset object lists and logical relationships, the problem of incompatible style display of e-books on web pages, mini-programs, or H5 pages was solved, and the pages were displayed normally.
Patent Information
- Application Number
- CN202111327162.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2041-11-10
AI Technical Summary
In the web pages, mini-programs, or H5 pages of e-books, the display of e-books suffers from problems such as content misalignment, overlapping, excessive white space, and truncated images, which are difficult to solve effectively with existing technologies.
By acquiring the page information to be displayed, the style information is detected using a preset list of objects to be corrected, the target objects that need to be corrected are identified, and the correction process is carried out according to the relationship between the objects to be corrected and the correction logic, generating corrected style information that is adapted to the current display interface.
It enables automatic identification and correction of incompatible style code, ensuring that page information is displayed correctly on the current display interface, thus solving the problem of incompatible style display.
Smart Images

Figure CN113918850B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of Internet, and particularly relates to a style automatic correction method, an electronic device and a storage medium. BACKGROUND
[0002] With the development of Internet technology, in the field of electronic reading, electronic books can be presented in various forms. Users can read electronic books through client application programs (such as electronic book reading APP), web pages (such as browsers), mini programs or H5 (Hyper Text Markup Language 5) pages loaded by fast application (fast application is a new application ecology of mobile Internet, which is deeply integrated with mobile phone system and has complete application experience of traditional APP, but does not need to be installed and can be used immediately).
[0003] From the perspective of web page development of electronic books, the content display web page of most Epub standard (an electronic book standard proposed by International Digital Publishing Forum (IDPF)) electronic books is a document type written in Extensible HyperText Markup Language (xhtml). The page corresponding to the above document can be rendered by a client engine on an electronic book reading APP, and a better display effect can be achieved. However, when the above document is applied to a web page, a mini program or an H5 page for display, various problems of style display may occur, such as content misplacement and superposition, too much page blank, picture truncation, etc. SUMMARY
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, embodiments of the present disclosure provide a style automatic correction method, an electronic device and a storage medium.
[0005] In a first aspect, embodiments of the present disclosure provide a style automatic correction method. The above method comprises: obtaining page information to be displayed; detecting style information in the page information according to a preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information; when it is determined that the target object exists in the style information, correcting the target object according to an association relationship between the object to be corrected and correction logic, and obtaining corrected style information adapted to a current display interface.
[0006] In a second aspect, embodiments of the present disclosure provide an electronic device. The electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus. The memory is configured to store at least one executable instruction, and the executable instruction causes the processor to perform the following steps: obtaining page information to be displayed; detecting style information in the page information according to a preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information; when it is determined that the target object exists in the style information, performing correction processing on the target object according to an association relationship between the object to be corrected and correction logic, to obtain corrected style information that is adapted to a current display interface.
[0007] According to embodiments of the present disclosure, in the method for automatically correcting style and the electronic device provided in the first aspect and the second aspect, the detecting the style information in the page information according to the preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information, includes: locating the style information in the page information according to an identifier of the style information; detecting whether specific code information that matches one or more objects to be corrected in the list of objects to be corrected exists in the style information according to the preset list of objects to be corrected; and when the specific code information exists in the style information, determining that the specific code information is the target object that needs to be corrected.
[0008] According to embodiments of the present disclosure, in the method for automatically correcting style and the electronic device provided in the first aspect and the second aspect, the association relationship between the object to be corrected and the preset correction logic is one-to-one or one-to-many. The method includes: determining one or more candidate processing logics corresponding to the target object according to the association relationship between the object to be corrected and the preset correction logic; when the candidate processing logic corresponding to the target object is one, performing correction processing on the target object according to the candidate processing logic, to obtain corrected style information; and when the candidate processing logic corresponding to the target object is multiple, determining a target processing logic corresponding to a target function defined by a sentence in which the target object is located, from the multiple candidate processing logics according to the target function; performing correction processing on the target object according to the target processing logic, to obtain corrected style information.
[0009] In the method for automatically correcting a style and the electronic device according to the first aspect of the present disclosure, for a one-to-many association relationship, a plurality of preset correction logics associated with the same object to be corrected are bound with respective function identifiers, and the function identifiers are used to define that the current preset correction logic is set for a problem of the object to be corrected with a specific function. The target function defined according to the sentence in which the target object is located is used to determine a target processing logic corresponding to the target function from a plurality of candidate processing logics, including: matching the target function defined according to the sentence in which the target object is located in the function identifiers of the plurality of candidate processing logics or the function identifiers of the association relationships corresponding to the plurality of candidate processing logics; and when there is a target function identifier matching the target function, determining that the preset candidate processing logic corresponding to the target function identifier is the target processing logic.
[0010] In the method for automatically correcting a style according to the first aspect of the present disclosure, the method further includes the following steps, or in the electronic device according to the second aspect of the present disclosure, the executable instructions further cause the processor to perform the following steps: generating a list of objects to be corrected and an association relationship between the objects to be corrected and the correction logics. The generation of the list of objects to be corrected and the association relationship between the objects to be corrected and the correction logics includes: obtaining style code information and corresponding processing logic information that are not adapted to a current display interface; generating the list of objects to be corrected according to the style code information; and generating the association relationship between the objects to be corrected and the correction logics according to the style code information and the corresponding processing logic information.
[0011] In the method for automatically correcting a style and the electronic device according to the first aspect of the present disclosure, the obtaining of the style code information and the corresponding processing logic information that are not adapted to the current display interface includes at least one of the following: obtaining example information of a non-adaptive style code input by a user and processing logic information for the non-adaptive style code; or obtaining historical correction data of a code document of a front-end style that has been written and corrected by the user in a debugging process, and determining the style code information and the corresponding processing logic information that are not adapted to the current display interface according to the historical correction data and interface display information in the debugging process.
[0012] According to an embodiment of the present disclosure, the method for automatically correcting the style provided in the first aspect and the electronic device provided in the second aspect, the generating of the association between the to-be-corrected object and the correction logic according to the style code information and the corresponding processing logic information comprises: when there are multiple processing logic information corresponding to the style code information, binding a respective function identifier to each of the multiple processing logic information corresponding to the style code information according to the function to be implemented by the style code information; taking the style code information as the to-be-corrected object, taking the processing logic information corresponding to the style code information as the correction logic, and generating the association related to the function identifier.
[0013] According to an embodiment of the present disclosure, the method for automatically correcting the style provided in the first aspect further comprises the following steps, or the executable instructions of the electronic device provided in the second aspect further cause the processor to perform the following steps: receiving update information for updating the association; and updating the list of to-be-corrected objects and the association according to the update information. The updating of the association comprises at least one of the following: updating the to-be-corrected object in the association, updating the correction logic in the association, and updating the correspondence between the to-be-corrected object and the correction logic. Wherein, the detecting of the style information in the page information according to the list of to-be-corrected objects comprises: detecting the style information in the page information according to the updated list of to-be-corrected objects. The correcting of the target object according to the association between the to-be-corrected object and the correction logic comprises: correcting the target object according to the updated association.
[0014] According to an embodiment of the present disclosure, the method for automatically correcting the style provided in the first aspect and the electronic device provided in the second aspect, the to-be-corrected object comprises: a first setting parameter corresponding to a display position setting error, invalidity, or unreasonable correspondence, a second setting parameter related to alignment, a third setting parameter corresponding to incomplete content display, a fourth setting parameter corresponding to unreasonable floating setting, and a fifth setting parameter corresponding to unreasonable multi-element layout. The correction logic comprises: replacing the parameter setting value in the to-be-corrected object based on a preset value; correcting the syntax in the to-be-corrected object; converting the setting parameter in the to-be-corrected object into a replacement parameter that conforms to the syntax specification of the current display interface, and supplementing a parameter preset value corresponding to the replacement parameter; replacing the setting parameter in the to-be-corrected object with a new parameter, and supplementing a parameter preset value corresponding to the new parameter and association parameter information associated with the new parameter.
[0015] In the method for automatically correcting styles and the electronic device according to the first aspect and the second aspect, the page information to be displayed is an electronic book document written in extensible hypertext markup language (xhtml), and the current display interface includes a browser webpage, a mini-program interface, or an H5 page loaded in a fast application.
[0016] In a third aspect, the embodiments of the present disclosure provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method for automatically correcting styles is implemented.
[0017] One or more of the technical solutions in the above embodiments have at least some or all of the following advantages:
[0018] By detecting the style information in the obtained page information to be displayed (for example, information in an xhtml page code document conforming to an Epub standard), it is determined whether there is a target object that needs to be corrected in the style information. The target object is a style code that does not adapt to the specification format of the current display interface (for example, a writing specification of an H5 page). When it is determined that the target object exists in the style information, the target object is corrected according to a predefined association relationship between a to-be-corrected object and a correction logic. The automatic finding and automatic correction of the style code that does not adapt are implemented. The corrected style information that adapts to the current display interface is obtained. It is ensured that the obtained page information can be normally displayed on the current display interface. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or the related description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0021] Figure 1 The system architecture of the method for automatically correcting styles suitable for the embodiments of the present disclosure is schematically shown;
[0022] Figure 2 The flowchart of the method for automatically correcting styles according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 3 The detailed implementation flowchart of step S202 according to an embodiment of the present disclosure is schematically shown.
[0024] Figure 4 A detailed implementation flowchart of step S203 according to an embodiment of the present disclosure is schematically shown;
[0025] Figure 5 A flowchart of a style automatic correction method according to another embodiment of the present disclosure is schematically shown.
[0026] Figure 6 A detailed implementation flowchart of generating a list of objects to be corrected and an association between the objects to be corrected and correction logic according to an embodiment of the present disclosure is schematically shown.
[0027] Figure 7 A flowchart of a style automatic correction method according to still another embodiment of the present disclosure is schematically shown; and
[0028] Figure 8 A structural block diagram of an electronic device provided by an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure provide a style automatic correction method, an electronic device, and a storage medium. The above method comprises: obtaining page information to be displayed; detecting style information in the page information according to a preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information; when it is determined that the target object exists in the style information, correcting the target object according to an association between the objects to be corrected and correction logic, and obtaining corrected style information that is adapted to a current display interface.
[0030] In the above method, based on the list of objects to be corrected and the association between the objects to be corrected and the correction logic, automatic searching and automatic correction of style information in the obtained page information to be displayed that is not adapted to style code can be realized, and corrected style information that is adapted to a current display interface is obtained, so as to ensure that the obtained page information can be normally displayed on the current display interface.
[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.
[0032] Figure 1 A system architecture suitable for the style automatic correction method according to an embodiment of the present disclosure is schematically shown.
[0033] Referring to Figure 1 As shown in FIG. 1, a system architecture 100 of the method for automatic style correction suitable for the embodiments of the present disclosure includes terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0034] A user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as e-book reading software / applications, web browser applications, search applications, news client applications, instant messaging tools, take-out applications, social platform software, shopping applications, short video applications, etc. (only as examples).
[0035] The terminal devices 101, 102, 103 can be electronic devices with a display screen and support for playing at least one of text, pictures, videos, etc., or the terminal devices 101, 102, 103 can also be electronic devices with a display screen and support for web browsing. For example, the above-mentioned electronic devices can include but are not limited to: smartphones, tablet computers, notebook computers, desktop computers, smartwatches, etc.
[0036] The server 105 can be a server providing various services, such as a background management server providing service support for the application interface or web page browsed by the user using the terminal devices 101, 102, 103 (only as an example). The background management server can analyze and process the received request and feed back the processing result (such as a web page, information, or data generated or obtained according to the user request, etc.) to the terminal device.
[0037] It should be noted that the method for automatic style correction provided by the embodiments of the present disclosure can generally be executed by a terminal device or a server.
[0038] In the embodiments of the present disclosure, the execution logic of the executable instructions related to the detection of style information and the correction processing in the above-mentioned method for automatic style correction is included in a style normalization toolkit (such as an Epub style correction software package).
[0039] In an application scenario, the style normalization toolkit can be installed on a terminal device. The server sends the page information to be displayed to the terminal device. After the terminal device obtains the page information to be displayed from the server, the automatic detection and correction of the style are realized based on the style normalization toolkit, and after obtaining the corrected style information, the terminal device displays the page content based on the above-mentioned corrected style information.
[0040] In another extendable application scenario, the above style normalization toolkit can be set in a server, the server acquires page information to be displayed for display on a terminal device, and then performs the logic of style information detection and deviation correction processing based on the above style normalization toolkit to obtain corrected style information adapted to the current display interface. Then, the server can send the above corrected style information to the terminal device, and the terminal device displays the page content based on the above corrected style information.
[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in
[0042] Although the above scenario takes the application of the above style automatic deviation correction method in the electronic reading scenario as an example, it can be understood that the application scenario of the technical solution provided by the embodiments of the present disclosure is not limited to the electronic reading scenario, and can be extended to any scenario that needs to perform style deviation correction.
[0043] The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0044] The first exemplary embodiment of the present disclosure provides a style automatic deviation correction method.
[0045] Figure 2 A flowchart of the style automatic deviation correction method according to an embodiment of the present disclosure is schematically shown.
[0046] Referring to Figure 2 The style automatic deviation correction method provided by the embodiments of the present disclosure includes the following steps: S201, S202 and S203. The steps S201-S203 can be performed by a terminal device for content display, or can be performed by a server providing service support for the above content display. The specific description can refer to the foregoing examples about the application scenario, and will not be repeated here.
[0047] In step S201, page information to be displayed is acquired.
[0048] For example, the above page information to be displayed is an electronic book document format (applicable to an electronic book reading APP) written in xhtml, and the above page information to be displayed can be information in an xhtml page code document conforming to the electronic book Epub standard.
[0049] The above page information to be displayed is used for display on the current display interface of the terminal device, and the current display interface includes but is not limited to: a browser webpage, a small program interface or a H5 page loaded in a fast application, etc.
[0050] In step S202, the style information in the page information is detected according to a preset to-be-corrected object list, and it is determined whether the target object needing rectification exists in the style information.
[0051] The preset to-be-corrected object list includes one or more to-be-corrected objects, and the to-be-corrected object includes a style code in an xhtml written e-book document that is not adapted to the current display interface.
[0052] For example, the to-be-corrected object includes margin-top (an attribute in CSS, used to set the upper outer margin of an element): -30% (used to realize the effect of offsetting out of the page in an e-book reading APP); margin (left and right outer margin) -30%, padding (left and right inner margin) 30% and the like. The meanings of the codes mentioned are well known to those skilled in the art, and will not be described in detail.
[0053] Based on the to-be-corrected object list, the style information in the page information can be automatically detected to find the target object needing rectification in the style information.
[0054] In step S203, when it is determined that the target object exists in the style information, the target object is rectified according to the association relationship between the to-be-corrected object and the correction logic, to obtain the corrected style information adapted to the current display interface.
[0055] The association relationship between the to-be-corrected object and the correction logic is generated in advance, and for a certain to-be-corrected object, the corresponding correction logic for processing can be one or more. For example, for the to-be-corrected object margin-top (upper outer margin): 30%, a corresponding correction logic can be to replace margin-top (upper outer margin): -30% with margin-top (upper outer margin): 0.
[0056] By the association relationship between the to-be-corrected object and the correction logic, the target object can be rectified by the corresponding correction logic to obtain the rectified style information. The rectified style information is the corrected style information, which can be adapted to the current display interface, so that the page information containing the corrected style information can be normally displayed on the current display interface.
[0057] Based on the above steps S201-S203, by detecting the style information in the obtained page information to be displayed (for example, information in an xhtml page code document conforming to the Epub standard), it is determined whether there is a target object in the style information that needs to be corrected, the target object is a style code that does not adapt to the specification format (for example, the writing specification of H5 page) of the current display interface, and when it is determined that the target object exists in the style information, the target object is corrected according to the predefined association relationship between the object to be corrected and the correction logic, realizing automatic finding and automatic correction of the non-adaptive style code, obtaining corrected style information that adapts to the current display interface, and ensuring that the obtained page information can be normally displayed on the current display interface.
[0058] Taking an electronic book as an example, in the xhtml page code document of the electronic book (adapted to an electronic reading APP, one display page corresponds to one code document), one page of electronic book content usually corresponds to one body (main content of a web page), and multiple pages of electronic book content have multiple bodies, and the style information of the electronic book content is defined in the page code document. If the xhtml page code document is directly applied to H5 pages such as browser web pages, applets or fast applications for rendering, taking rendering to H5 pages as an example, generally, multiple pages of an electronic book will be laid out in sequence, and a user can read multiple pages of electronic book content on one web page by pulling up and down, and in this case, since the style code in the original xhtml page code document is written for the one-page display of the electronic book reading APP, the style setting in the H5 page of the browser web page, the applet or the fast application will cause abnormal display problems. In addition, for single-page display, some parameters set according to previous habits (adapted to the setting parameters of the electronic reading APP) will also cause non-adaptation in the current display interface, thereby causing problems such as content misplacement and superposition, excessive page blanking, and picture truncation.
[0059] By implementing the above steps S201-S203, based on the association relationship between the object to be corrected and the correction logic, automatic finding and automatic correction of non-adaptive style code in the style information of the obtained page information to be displayed in the electronic book can be realized, corrected style information that adapts to the current display interface (for example, H5 page) is obtained, and it is ensured that the obtained page information can be normally displayed on the current display interface.
[0060] It should be understood that as long as the style code of the page information to be displayed is compatible with the general framework of the current display interface actually to be displayed, only the settings of the style code do not adapt to the current display interface, the style automatic correction method provided by the embodiments of the present disclosure can be applied, and it is not limited to the information in the xhtml page code document in the above-mentioned embodiment example and the browser webpage, the small program interface or the H5 page loaded in the fast application.
[0061] Figure 3 A detailed implementation flowchart of step S202 according to an embodiment of the present disclosure is schematically shown.
[0062] According to an embodiment of the present disclosure, referring to Figure 3 In step S202, according to the preset to-be-corrected object list, the style information in the page information is detected to determine whether there is a target object that needs to be corrected in the style information, including the following steps: S301, S302 and S303.
[0063] In step S301, according to the identification of the style information, the style information in the page information is located.
[0064] In addition to the style information, the page information can also include: web page content, web page description information, etc. In an embodiment, the information in the xhtml page code document conforming to the electronic book Epub standard (an example of page information) is that the identification of the style information is, for example, style, and the identification of the specific style content can be: height, width, position, bottom, vertical-align, display, margin, padding, color, overflow, transform, size, etc.
[0065] In step S302, according to the preset to-be-corrected object list, it is detected whether the style information contains specific code information matching one or more to-be-corrected objects in the to-be-corrected object list.
[0066] In step S303, when the specific code information exists in the style information, it is determined that the specific code information is a target object that needs to be corrected.
[0067] Based on steps S301-S303, by detecting the located style information according to the to-be-corrected object list, when the specific code information matching one or more to-be-corrected objects in the to-be-corrected list is detected, the specific code information can be determined as a target object that needs to be corrected, and the automatic finding of the non-adaptive style code in the page information is realized.
[0068] Figure 4 A detailed implementation flowchart of step S203 according to an embodiment of the present disclosure is schematically shown.
[0069] The association between the object to be corrected and the preset correction logic is one-to-one or one-to-many.
[0070] According to an embodiment of the present disclosure, referring to Figure 4 As shown in FIG. 4, in step S203, the target object is corrected according to the association between the object to be corrected and the preset correction logic, to obtain correction style information adapted to the current display interface, including the following steps: S401, S402a, S402b and S403b.
[0071] In step S401, one or more candidate processing logics corresponding to the target object are determined according to the association between the object to be corrected and the preset correction logic.
[0072] When the candidate processing logic corresponding to the target object is one, step S402a is executed.
[0073] In step S402a, the target object is corrected according to the candidate processing logic, to obtain corrected style information, which is the correction style information.
[0074] When the candidate processing logic corresponding to the target object is multiple, steps S402b and S403b are executed.
[0075] In step S402b, when the candidate processing logic corresponding to the target object is multiple, a target processing logic corresponding to a target function defined by the sentence in which the target object is located is determined from the multiple candidate processing logics.
[0076] The target function defined by the sentence in which the target object is located includes a position function, an alignment function, a display function, a layout between multiple elements, etc.
[0077] For example, the target object "margin-top: 30%" appears in two statements, one of which defines a position function, and because the parameter value set is too large, the display in the H5 page results in too large a spacing between the title and the picture; the other statement defines the layout between multiple elements, and there is an element "margin-top: 10%" and another element "margin-bottom: 5%", which results in the problems of margin collapse between parent and child elements (the limit of the parent element on the vertical direction (the y direction of the screen) has no effect on the child element), and margin merging (between two parallel sibling elements, their margin-bottom and margin-top are merged, and the larger value is displayed, and the actual spacing along the vertical direction is not the sum of the two defined spacings).
[0078] For example, the target processing logic corresponding to the position function is, for example, replacing the parameter setting value in the object to be corrected with a preset value, such as replacing "margin-top: 30%" with "margin-top: 0"; the target processing logic corresponding to the layout function between multiple elements is, for example, replacing the setting parameter in the object to be corrected with a new parameter, supplementing the parameter preset value corresponding to the new parameter and the associated parameter information associated with the new parameter. For example, setting the float / position attribute of the child element to make it separate from the document flow (block-level box of the conventional document flow (non-float and absolute positioning)), or setting the border / padding of the parent element, and then setting the box-size attribute to border-box / padding-box, and the like.
[0079] In step S403b, the target object is corrected according to the target processing logic described above, and the corrected style information is obtained, and the corrected style information is the corrected style information.
[0080] According to an embodiment of the present disclosure, for a one-to-many association relationship, multiple preset correction logics associated with the same object to be corrected are bound with their respective corresponding function identifiers, and the function identifier is used to define that the current preset correction logic is set for the problem of the object to be corrected with a specific function.
[0081] In the step S402b, the target processing logic corresponding to the target function is determined from the multiple candidate processing logics according to the target function defined by the sentence in which the target object is located, including: matching the target function defined by the sentence in which the target object is located with the function identifiers of the multiple candidate processing logics or the function identifiers of the association relationships corresponding to the multiple candidate processing logics; and when there is a target function identifier matching the target function, determining the preset candidate processing logic corresponding to the target function identifier as the target processing logic.
[0082] Figure 5 A flowchart of a method for automatic style correction is shown schematically.
[0083] According to an embodiment of the present disclosure, referring to Figure 5 In addition to the steps S201-S203, the method for automatic style correction can further include the following steps: S501, generating a list of objects to be corrected and an association relationship between the objects to be corrected and the correction logics. The step S501 is performed before the steps S202 and S203, and within a certain time period (the effective time period of the association relationship), the steps S201-S203 can be performed multiple times based on the association relationship generated in the step S501.
[0084] Figure 6 A detailed implementation flowchart of generating a list of objects to be corrected and an association relationship between the objects to be corrected and the correction logics is shown schematically.
[0085] Referring to Figure 6 In the step S501, generating a list of objects to be corrected and an association relationship between the objects to be corrected and the correction logics, includes the following steps: S601, S602 and S603.
[0086] In the step S601, the style code information and the corresponding processing logic information that are not adapted to the current display interface are obtained.
[0087] The style code information that is not adapted to the current display interface refers to some style code information that is not adapted to the display specification of the current display interface (for example, the display specification of an H5 page). These style code information can be directly input by a developer, and the corresponding processing logic information can be customized by the developer. These style code information can also be generated by the developer during the debugging process of the display effect of a front-end code file (for example, an electronic book document written in xhtml), and the corresponding processing logic information is the actual processing scheme adopted by the developer.
[0088] In an embodiment, the acquiring the style code information and the corresponding processing logic information that are not adapted to the current display interface comprises: acquiring example information of a style code input by a user and processing logic information corresponding to the style code.
[0089] In another embodiment, the acquiring the style code information and the corresponding processing logic information that are not adapted to the current display interface comprises: acquiring historical rectification data of rectification of a code document of a front-end style performed by a user in a debugging process, and determining the style code information and the corresponding processing logic information that are not adapted to the current display interface according to the historical rectification data and interface display information in the debugging process.
[0090] In other embodiments, the implementation of step S601 can also be a method that simultaneously contains the above two embodiments, that is, simultaneously including the manner of acquiring the relevant information (the style code information and the corresponding processing logic information that are not adapted to the current display interface) input by the user and the manner of generating the relevant information according to the historical rectification data of the user.
[0091] In step S602, a to-be-corrected object list is generated according to the style code information.
[0092] The style code information that is not adapted to the current display interface is taken as a to-be-corrected object, and a to-be-corrected object list containing one or more to-be-corrected objects is generated.
[0093] In step S603, an association relationship between the to-be-corrected object and the correction logic is generated according to the style code information and the corresponding processing logic information.
[0094] According to an embodiment of the present disclosure, the generating the association relationship between the to-be-corrected object and the correction logic according to the style code information and the corresponding processing logic information comprises: when the style code information corresponds to multiple processing logic information, binding a respective corresponding function identifier to each of the multiple processing logic information corresponding to the style code information according to a function to be implemented by the style code information; taking the style code information as the to-be-corrected object, taking the processing logic information corresponding to the style code information as the correction logic, and generating an association relationship related to the function identifier.
[0095] In an embodiment, the object to be corrected includes, but is not limited to, display position setting error, invalid, unreasonable corresponding first setting parameter, alignment related second setting parameter, third setting parameter corresponding to incomplete content display, unreasonable fourth setting parameter corresponding to floating setting, and fifth setting parameter corresponding to unreasonable multi-element layout. The correction logic includes, but is not limited to, replacing the parameter setting value in the object to be corrected based on the preset value; correcting the syntax in the object to be corrected; converting the setting parameter in the object to be corrected into an alternative parameter conforming to the syntax specification of the current display interface, and supplementing the parameter preset value corresponding to the alternative parameter; replacing the setting parameter in the object to be corrected with a new parameter, supplementing the parameter preset value corresponding to the new parameter and the associated parameter information associated with the new parameter.
[0096] The association between the object to be corrected and the correction logic is described below.
[0097] For example, (a) the object to be corrected is the first setting code of the upper margin (margin) that causes the content overlap problem, which corresponds to display position setting error and is unreasonable, for example: "margin-top: -30%". The setting can achieve the effect of offsetting out of the page in the e-book reading APP, and there is no display problem, but in the H5 page, since multiple chapters are presented in one page, it will cause the content overlap problem. The first correction logic associated therewith is to replace the parameter setting value with the upper margin setting value corresponding to the preset value (for example, 0).
[0098] (b) The object to be corrected is the second setting code of the outer margin (margin) and the inner margin (padding) that causes the horizontal scroll of the page, which corresponds to display position setting error and is unreasonable, and the second correction logic associated therewith is to forcibly remove the horizontal scroll in the current display interface (html) and the main part (body) thereof, and to replace the values of the outer margin (margin) and the inner margin (padding) with target values (for example, 0-1em) in order to achieve the effect of full screen width.
[0099] Alternatively, for example, the value is written incorrectly on the audio / video or the audio / video container, which causes it to be too large or too small. The correction logic to solve the problem is to uniformly set the parameters of the video container to width: 100%, and set the audio container to a minimum width of 120px.
[0100] (c) The object to be corrected is the height setting parameter in the third setting code (corresponding to the display position setting invalid) in the current display interface. Based on the epub specification, the height (height) in the document is usually located in the body when the document is written and stored. When the H5 page is displayed, the body is changed to div, and multiple chapters are placed in one display page. Since the div syntax does not have the syntax of multiple bodies placed side by side, the height setting parameter in the body corresponding to the previous multiple chapters is partially invalid. Therefore, the third correction logic corresponding to the association is to convert the setting parameter in the third setting code into a setting parameter that conforms to the syntax of the current display interface, and supplement the preset parameter value and the preset parameter information associated with the setting parameter, for example: based on the css selector, convert height using div.background-img-center, and supplement the preset parameter value height: 177.8vw; min-height: 640px; and the preset parameter information associated with the setting parameter: overflow: hidden; position: relative reset.
[0101] (d) The object to be corrected is the fourth setting code (alignment related) corresponding to the parameter that does not completely work to limit alignment, for example, the fourth setting code is the setting parameter vertical-align: bottom bottom alignment; the fourth correction logic associated therewith is to replace vertical-align: bottom with position: absolute; bottom: xxx (preset parameter value). Alternatively, for example, the fourth setting code is: ×× (abbreviation of e-book operator)-b-l (abbreviation of bottom-left), and the fourth correction logic associated therewith is to add the following style according to the above style name: height: auto; position: absolute; bottom: 0; left: 0.
[0102] (e) The object to be corrected is the fifth setting code (alignment related) corresponding to the parameter that causes the content to be displayed incompletely, for example, vertical-align only works on inline-block and table cell elements; the fifth correction logic associated therewith is to add the following style according to the h5_rule_hv hook in the page under the alignment code: height: auto; position: relative; top: 50%; -webkit-transform: translate(0, -50%); transform: translate(0, -50%); and after rendering, the js (script running on the browser) checks again, and if it finds that the parent level is smaller than the height itself, removes the vertical centering.
[0103] (f) the object to be corrected is a sixth setting code corresponding to a parameter that does not fully work in limited alignment (display integrity related), for example, some links and content are long strings of continuous characters, which can cause the problem of stretching out of the screen to occur; the sixth correction logic associated therewith is to supplement the following setting: word-break: break-all. Alternatively, in another embodiment, the current H5 does not make a gallery carousel, and the pictures are sequentially coded down, which causes the parent to be not high enough when there are many pictures, and the picture is truncated. The correction logic to solve the problem is to make a hook based on the agreed gallery-div (the old one is full-page) to reset the parent height, so that the parent adapts to the picture content height. In yet another embodiment, the content in the code block is too long to stretch the page, and the correction logic to solve the problem is to set overflow: auto to allow local left and right sliding in the code block. In still another embodiment, there is already a setting of width: 100%, and padding or border is added to cause the problem, and the browser defaults to stretch out of the screen. The correction logic to solve the problem is to set box-sizing: border-box. Alternatively, for example, float is used in the child element, which causes the parent height to be displayed incorrectly. The correction logic to solve the problem is to set the parent overflow: hidden.
[0104] The above examples are only examples of the association relationship, and can be expanded or changed on this basis.
[0105] Figure 7 A flowchart of a method of automatic style correction according to yet another embodiment of the present disclosure is schematically shown.
[0106] According to the embodiments of the present disclosure, on the basis of the above embodiments, the above method of automatic style correction can further include the following steps: S701 and S702 in addition to the above steps S201-S203 and S501, and the above step S202 can include step S202a in implementation, and the above step S203 can include step S203a in implementation, as shown in the following. Figure 7
[0107] In step S701, update information for updating the above association relationship is received.
[0108] In step S702, the above object to be corrected list and the above association relationship are updated according to the above update information.
[0109] The updating of the association relationship includes at least one of the following: updating the object to be corrected in the association relationship, updating the correction logic in the association relationship, and updating the correspondence between the object to be corrected and the correction logic.
[0110] In the step S202, the style information in the page information is detected according to the preset object to be corrected list, including the following step S202a: detecting the style information in the page information according to the updated object to be corrected list. In the step S203, the target object is corrected according to the association relationship between the object to be corrected and the correction logic, including the following step S203a: correcting the target object according to the updated association relationship.
[0111] By updating the object to be corrected, the correction logic, or the correspondence between the object to be corrected and the correction logic in the association relationship, the inadaptation detection can be updated and adjusted adaptively with the changes of the programming language and the display specification, so as to achieve the purpose of normal display in various types of display interfaces.
[0112] The various technical solutions provided by the embodiments of the present disclosure can be implemented in whole or in part by hardware, or by software modules running on one or more processors, or by a combination thereof. Those skilled in the art should understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the electronic device according to the embodiments of the present disclosure. The embodiments of the present disclosure can also be implemented as device or apparatus programs (e.g., computer programs and computer program products) for performing part or all of the methods described herein. The programs implementing the embodiments of the present disclosure can be stored on a computer readable medium or can have the form of one or more signals. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0113] A second exemplary embodiment of the present disclosure provides an electronic device.
[0114] Figure 8 The structure block diagram of the electronic device provided by the embodiments of the present disclosure is schematically shown.
[0115] Reference Figure 8As shown, the electronic device 800 provided by the embodiment of the present disclosure includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802 and the memory 803 complete mutual communication through the communication bus 804; the memory 803 is used for storing at least one executable instruction; and the processor 801 is used for executing the executable instruction stored on the memory to implement the method for automatically correcting the style as described above.
[0116] Specifically, the executable instruction causes the processor to perform the following steps: obtaining page information to be displayed; detecting style information in the page information according to a preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information; when it is determined that the target object exists in the style information, performing correction processing on the target object according to an association relationship between the object to be corrected and correction logic, and obtaining corrected style information that is adapted to a current display interface. The detailed implementation process of each step and the steps that can be further included can be referred to the description of the first embodiment, and will not be described here.
[0117] The page information to be displayed is an electronic book document format written in xhtml, and the current display interface includes a browser webpage, a small program interface or an H5 page loaded in a fast application.
[0118] According to the embodiment of the present disclosure, the electronic device can be a terminal device having a browser, a small program, a fast application or the like for displaying content (for example, an electronic book content). Alternatively, the electronic device can be a server that provides service support for the display of the content, or a server in a server cluster that can communicate with the terminal device and / or the server.
[0119] The memory 803 can be an electronic storage such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. The memory 803 has a storage space for executable instructions for performing any of the method steps in the above-described methods. For example, the storage space for executable instructions can include individual executable instructions for implementing individual steps in the above-described methods, respectively. The executable instructions can be read from or written to one or more computer program products. The computer program products include program code carriers such as a hard disk, a compact disk (CD), a memory card, or a floppy disk. Such computer program products are typically portable or stationary storage units. The storage unit can have a storage section or a storage space, etc., arranged similarly to the memory 803 in the above-described electronic device. The executable instructions can be compressed, for example, in an appropriate form. Typically, the storage unit includes program codes that can be read by a processor such as 801, for example, which, when executed by the electronic device, cause the electronic device to perform the individual steps in the above-described methods.
[0120] The third exemplary embodiment of the present disclosure also provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the method for automatic style correction as described above.
[0121] The computer readable storage medium can be included in the device / apparatus described in the above-described embodiments; or can exist separately, without being assembled into the device / apparatus. The computer readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present disclosure.
[0122] According to the embodiments of the present disclosure, the computer readable storage medium can be a non-volatile computer readable storage medium, which can include, but is not limited to, 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), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in connection with an instruction execution system, apparatus, or device.
[0123] It has to be noted that, in the present document, relational terms are intended only to convey a possible relationship between elements or steps without necessarily being construed as requiring such a relationship. Furthermore, the terms "comprise", "comprising", "contain", "containing" or any other variant are intended not to exclude other elements or steps but to encompass the possession of those elements or steps recited. The terms "comprising" and "including" and variations thereof mean "open ended" and do not exclude additional elements or steps. The terms "comprise", "comprising", "contain", "containing", "include", "including" and "includes" are not used in a restrictive sense.
[0124] The foregoing is merely illustrative of the principles of this disclosure and various modifications can be made by those skilled in the art without departing from the spirit and scope of the disclosure. The above embodiments are illustrative, and not restrictive, of the scope of the present disclosure.
Claims
1. A method for automatic style correction, characterized in that, The method comprises: acquiring page information to be displayed; detecting style information in the page information according to a preset list of objects to be corrected, and determining whether a target object that needs to be corrected exists in the style information; the preset list of objects to be corrected comprises one or more objects to be corrected, and the object to be corrected comprises style code in an electronic book document written in extensible hypertext markup language (xhtml) that is not adapted to a current display interface, and comprises one or more of the following: display position setting error, invalid, unreasonable corresponding first setting parameter, alignment related second setting parameter, third setting parameter corresponding to incomplete content display, unreasonable floating setting corresponding fourth setting parameter, and unreasonable multi-element layout corresponding fifth setting parameter; when it is determined that the target object exists in the style information, performing correction processing on the target object according to an association relationship between the object to be corrected and correction logic, to obtain corrected style information that is adapted to the current display interface; wherein the correction logic comprises one or more of the following: replacing a parameter setting value in the object to be corrected based on a preset value; correcting syntax in the object to be corrected; converting a setting parameter in the object to be corrected into a replacement parameter that conforms to a syntax specification of the current display interface, and supplementing a parameter preset value corresponding to the replacement parameter; and replacing the setting parameter in the object to be corrected with a new parameter, and supplementing a parameter preset value corresponding to the new parameter and association parameter information associated with the new parameter.
2. The method of claim 1, wherein, The method comprises: locating to the style information in the page information according to an identifier of the style information; detecting whether specific code information that matches one or more objects to be corrected in the list of objects to be corrected is included in the style information according to the list of objects to be corrected; when the specific code information exists in the style information, determining that the specific code information is the target object that needs to be corrected.
3. The method of claim 1, wherein, The association relationship between the object to be corrected and the preset correction logic is one-to-one or one-to-many. The method comprises: determining one or more candidate processing logics corresponding to the target object according to the association relationship between the object to be corrected and the preset correction logic; when the candidate processing logic corresponding to the target object is one, performing correction processing on the target object according to the candidate processing logic to obtain corrected style information; when the candidate processing logic corresponding to the target object is multiple, determining a target processing logic corresponding to a target function defined by a sentence in which the target object is located in the multiple candidate processing logics according to the target function, and performing correction processing on the target object according to the target processing logic to obtain corrected style information.
4. The method of claim 3, wherein, For a one-to-many association relationship, a plurality of preset correction logics associated with one to-be-corrected object are bound with respective corresponding function identifiers, and the function identifiers are used to define that the current preset correction logic is set for problems of the to-be-corrected object with a specific function; The target function defined according to the sentence in which the target object is located is used to determine a target processing logic corresponding to the target function from a plurality of candidate processing logics, and the method comprises the following steps: The target function defined according to the sentence in which the target object is located is used to match a function identifier of a plurality of candidate processing logics or a function identifier of an association relationship corresponding to the plurality of candidate processing logics; When there is a target function identifier matching the target function, the preset candidate processing logic corresponding to the target function identifier is determined as the target processing logic.
5. The method of claim 1, wherein, Further comprising: Generating a to-be-corrected object list and an association relationship between the to-be-corrected object and a correction logic; The generating of the to-be-corrected object list and the association relationship between the to-be-corrected object and the correction logic comprises the following steps: Obtaining style code information and corresponding processing logic information that are not adapted to a current display interface; Generating a to-be-corrected object list according to the style code information; Generating an association relationship between the to-be-corrected object and the correction logic according to the style code information and the corresponding processing logic information.
6. The method of claim 5, wherein, The obtaining of the style code information and the corresponding processing logic information that are not adapted to the current display interface comprises at least one of the following: Obtaining example information of a non-adaptive style code input by a user and processing logic information for the non-adaptive style code; Or, Obtaining historical rectification data of rectification of a code document of a front-end style that has been written by the user in a debugging process; According to the historical rectification data and interface display information in the debugging process, determining style code information and corresponding processing logic information that are not adapted to a current display interface.
7. The method of claim 5, wherein, The generating of the association relationship between the to-be-corrected object and the correction logic according to the style code information and the corresponding processing logic information comprises the following steps: When the style code information corresponds to a plurality of processing logic information, binding respective corresponding function identifiers for the plurality of processing logic information corresponding to each style code information according to a function to be implemented by the style code information; Taking the style code information as a to-be-corrected object and taking the processing logic information corresponding to the style code information as a correction logic, generating an association relationship related to the function identifier.
8. The method of claim 5, wherein, Further comprising: Receiving update information for updating the association relationship; And According to the update information, updating the to-be-corrected object list and the association relationship, and the updating of the association relationship comprises at least one of the following: updating a to-be-corrected object in the association relationship, updating a correction logic in the association relationship, and updating a corresponding relationship between the to-be-corrected object and the correction logic; The detecting of the style information in the page information according to the preset to-be-corrected object list comprises the following step: detecting the style information in the page information according to the updated to-be-corrected object list. The target object is corrected according to the association between the object to be corrected and the correction logic.
9. The method according to any one of claims 1-8, characterized in that, The page information to be displayed is an electronic book document format written in extensible hypertext markup language (XHTML), and the current display interface includes a browser webpage, a small program interface, or an H5 page loaded in a fast application.
10. An electronic device, comprising: The device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store at least one executable instruction, which causes the processor to perform the following steps: Obtain page information to be displayed; Detect style information in the page information according to a preset object-to-be-corrected list to determine whether a target object that needs to be corrected exists in the style information; the object-to-be-corrected list includes one or more objects to be corrected, and the object to be corrected includes style code in an electronic book document written in extensible hypertext markup language (XHTML) that is not adapted to a current display interface, including one or more of the following: a display position setting error, an invalid first setting parameter, an unreasonable first setting parameter, an alignment-related second setting parameter, a third setting parameter that causes content display to be incomplete, an unreasonable fourth setting parameter for floating setting, and an unreasonable fifth setting parameter for multi-element layout; When it is determined that the target object exists in the style information, correct the target object according to an association between the object to be corrected and correction logic to obtain corrected style information that is adapted to the current display interface; the correction logic includes replacing a parameter setting value in the object to be corrected based on a preset value, correcting syntax in the object to be corrected, converting a setting parameter in the object to be corrected into an alternative parameter that conforms to a syntax specification of the current display interface and supplementing a parameter preset value corresponding to the alternative parameter, replacing the setting parameter in the object to be corrected with a new parameter, and supplementing a parameter preset value corresponding to the new parameter and association parameter information associated with the new parameter.
11. The electronic device of claim 10, wherein, The detection of the style information in the page information according to the preset object-to-be-corrected list to determine whether a target object that needs to be corrected exists in the style information includes: Locate the style information in the page information according to an identifier of the style information; Detect whether specific code information that matches one or more objects to be corrected in the object-to-be-corrected list is included in the style information according to the preset object-to-be-corrected list; When the specific code information exists in the style information, determine that the specific code information is the target object that needs to be corrected.
12. The electronic device of claim 10, wherein, The association between the object to be corrected and the preset correction logic is one-to-one or one-to-many; The correction of the target object according to the association between the object to be corrected and the correction logic to obtain corrected style information that is adapted to the current display interface includes: determine one or more candidate processing logics corresponding to the target object according to an association relationship between the object to be corrected and the preset correction logic; when the candidate processing logic corresponding to the target object is one, perform a correction processing on the target object according to the candidate processing logic, to obtain corrected style information, the corrected style information being the correction style information; when the candidate processing logic corresponding to the target object is multiple, determine a target processing logic corresponding to a target function defined by a sentence where the target object is located, from the multiple candidate processing logics; perform a correction processing on the target object according to the target processing logic, to obtain corrected style information, the corrected style information being the correction style information.
13. The electronic device of claim 12, wherein, For a one-to-many association relationship, multiple preset correction logics associated with the same object to be corrected are bound with respective function identifiers, the function identifiers being used to define that the current preset correction logic is set for problems of the object to be corrected with a specific function; wherein, the determining of the target processing logic corresponding to the target function defined by the sentence where the target object is located, from the multiple candidate processing logics, comprises: matching the target function defined by the sentence where the target object is located, from the function identifiers of the multiple candidate processing logics or the function identifiers of the association relationships corresponding to the multiple candidate processing logics; when there is a target function identifier matching the target function, determining that the preset candidate processing logic corresponding to the target function identifier is the target processing logic.
14. The electronic device of claim 10, wherein, The executable instructions further cause the processor to perform the following steps: generating a list of objects to be corrected and an association relationship between the objects to be corrected and correction logics; wherein, the generating of the list of objects to be corrected and the association relationship between the objects to be corrected and correction logics comprises: obtaining style code information and corresponding processing logic information that are not adapted to a current display interface; generating a list of objects to be corrected according to the style code information; generating an association relationship between the objects to be corrected and correction logics according to the style code information and the corresponding processing logic information.
15. The electronic device of claim 14, wherein, The obtaining of the style code information and the corresponding processing logic information that are not adapted to the current display interface comprises at least one of the following: obtaining example information of a non-adaptive style code input by a user and processing logic information for the non-adaptive style code; or, obtaining historical correction data of a code document with a front-end style written by a user during a debugging process; determining style code information and corresponding processing logic information that are not adapted to a current display interface according to the historical correction data and interface display information during the debugging process.
16. The electronic device of claim 14, wherein, The generating of the association relationship between the objects to be corrected and correction logics according to the style code information and the corresponding processing logic information comprises: when the style code information corresponds to multiple processing logic information, binding respective function identifiers to the multiple processing logic information corresponding to each style code information according to a function to be implemented by the style code information. The style code information is taken as a to-be-corrected object, and processing logic information corresponding to the style code information is taken as a correction logic, and an association relationship related to the function identifier is generated.
17. The electronic device of claim 14, wherein, The executable instructions further cause the processor to perform the following steps: receiving update information for updating the association relationship; and updating the to-be-corrected object list and the association relationship according to the update information, and the updating of the association relationship includes at least one of updating the to-be-corrected object in the association relationship, updating the correction logic in the association relationship, and updating the correspondence between the to-be-corrected object and the correction logic; wherein the detecting of the style information in the page information according to the preset to-be-corrected object list includes detecting the style information in the page information according to the updated to-be-corrected object list; the correcting of the target object according to the association relationship between the to-be-corrected object and the correction logic includes correcting the target object according to the updated association relationship.
18. The electronic device of any of claims 10-17, wherein, The to-be-displayed page information is an electronic book document format written in extensible hypertext markup language (xhtml), and the current display interface includes a browser webpage, a small program interface, or an H5 page loaded in a fast application.
19. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by a processor, implements the method of any one of claims 1-9.
Citation Information
Patent Citations
Third-party page design specification matching method and device, medium and equipment
CN109597615A