CN111679825A - Cascading style sheet generation method and device, computer equipment and storage medium - Google Patents

Cascading style sheet generation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111679825A
CN111679825A CN202010333551.5A CN202010333551A CN111679825A CN 111679825 A CN111679825 A CN 111679825A CN 202010333551 A CN202010333551 A CN 202010333551A CN 111679825 A CN111679825 A CN 111679825A
Authority
CN
China
Prior art keywords
html
closed
style sheet
replaceable
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010333551.5A
Other languages
Chinese (zh)
Inventor
黄坤
张淼
黄亚飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Saiante Technology Service Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202010333551.5A priority Critical patent/CN111679825A/en
Publication of CN111679825A publication Critical patent/CN111679825A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application belongs to the field of front-end development and relates to a cascading style sheet generation method, which comprises the following steps: when closed HTML tag data appear in a target HTML file, extracting the closed HTML tag data; reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code; acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation; acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area; embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet; and outputting the target cascading style sheet. The method and the device for converting the HTML documents into the CSS documents can realize the process of automatically converting the HTML documents into the CSS documents, and can greatly improve the accuracy and the development efficiency of projects.

Description

Cascading style sheet generation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of front-end development, and in particular, to a method and an apparatus for generating a cascading style sheet, a computer device, and a storage medium.
Background
The web front-end development evolves from web page production, and with the development of internet technology and the application of HTML5 and CSS3, modern web pages are more attractive, remarkable in interaction effect and more powerful. With the rapid development of the web2.0 development technology, developers are more and more concerned about the efficiency problem of front-end development, and more web systems with front-end and back-end separation are provided, so that how to quickly and efficiently write and package a front-end interaction component with good performance on a front end becomes a key problem.
After a page file with an HTML structure is written, a cascading style sheet is written according to a class style name and a design draft of a tag element in an HTML file, so that the cascading style sheet is generated.
However, the traditional cascading style sheet generation method is generally not intelligent, and the cascading style sheet is written according to the class style name and the design draft of the label element in the HTML file, so that the workload of developers is increased, and the resource investment of development is increased; meanwhile, the conditions of word spelling errors and nesting errors are easy to occur in the comparison process, so that the processing accuracy and efficiency are greatly reduced.
Disclosure of Invention
Based on the above, the problem that the traditional cascading style sheet generation scheme is low in processing accuracy and efficiency is solved.
The embodiment of the application provides a method for generating a cascading style sheet, which adopts the following technical scheme:
when closed HTML tag data appear in a target HTML file, extracting the closed HTML tag data;
reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code;
acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation;
acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area;
embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet;
and outputting the target cascading style sheet.
In order to solve the above technical problem, an embodiment of the present application further provides a cascading style sheet generating device, which adopts the following technical solutions:
the tag extraction module is used for extracting closed HTML tag data when the closed HTML tag data in the target HTML file is detected;
the code set acquisition module is used for reading a local database and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code;
a replacing code obtaining module, configured to obtain, in the replaceable code set, a replaceable style code corresponding to the closed HTML tag data based on a preset correspondence;
the cascading style sheet module is used for acquiring a preset cascading style sheet from the local database, and the preset cascading style sheet at least carries a default style code and an active area;
the target style sheet acquisition module is used for embedding the replaceable style codes into the active area of the preset cascading style sheet to acquire a target cascading style sheet; and
and the target style sheet output module is used for outputting the target cascading style sheet.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:
comprising a memory and a processor, said computer readable storage medium having stored thereon a computer program which, when executed by the processor, carries out the steps of the cascading style sheet generating method as described above.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:
the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the cascading style sheet generating method as described above.
The invention provides a cascading style sheet generating method, which comprises the steps of extracting closed HTML label data when the closed HTML label data in a target HTML file is detected; reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code; acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation; acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area; embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet; and outputting the target cascading style sheet. The replaceable style codes are obtained by extracting the obtained target HTML data, and the target cascading style sheet corresponding to the CSS file is converted based on the replaceable style codes, so that the process of automatically converting the HTML file into the CSS file is realized, the accuracy can be greatly improved, and the development efficiency of the project can be improved.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a flowchart illustrating an implementation of a method for generating a cascading style sheet according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating an implementation of a method for determining a closed tag according to an embodiment of the present invention;
FIG. 3 is a flowchart of one implementation of step S202 in FIG. 2;
FIG. 4 is a flowchart of another implementation of step S202 in FIG. 2;
fig. 5 is a flowchart of an implementation of a compatible cascading style sheet obtaining method according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a stacking style sheet generating apparatus according to a second embodiment of the present invention;
fig. 7 is a schematic structural diagram of a closed tag determination apparatus according to a second embodiment of the present invention;
FIG. 8 is a schematic block diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
According to the method for generating the cascading style sheet, the target attribute data are obtained by extracting the obtained target HTML data, and the target attribute data are converted into the target cascading style sheet corresponding to the CSS file on the basis of the target attribute data, so that the process of automatically converting the HTML file into the CSS file is realized, the accuracy can be greatly improved, and the development efficiency of a project can be improved.
Example one
Fig. 1 shows an implementation flowchart of a cascading style sheet generation method according to a first embodiment of the present invention, and for convenience of description, only a part related to the present invention is shown.
In step S101, when the presence of closed HTML tag data in a target HTML file is detected, the closed HTML tag data is extracted.
In the embodiment of the present invention, the target HTML file refers to an HTML file being written by a user.
In the embodiment of the present invention, the closed HTML tag data refers to the closed HTML tag data from the current start tag to the first end tag appearing in the target HTML file. As an example, for example, when the current start tag is < div class ═ imgbox >, and when the first end tag of the HTML file appears as </div >, the < div class ═ imgbox > to </div > are considered as closed HTML tag data.
In step S102, a local database is read, and an alternative code set is obtained in the local database, where the alternative code set includes an alternative style code.
In the embodiment of the present invention, the local database stores the above alternative code set in advance.
In the embodiment of the invention, the replaceable style code is a code for determining the style difference presented by different cascading style sheets, so that the difference of the replaceable style code is the root cause for different page styles based on the preset cascading style. Since the display style difference between the pages is different in different websites, the code amount of the fixed style code in the preset cascading style is determined according to the difference between the display styles of the pages in actual situations, and is not particularly limited herein.
In step S103, an alternative style code corresponding to the closed HTML tag data is acquired in the alternative code set based on a preset correspondence.
In the embodiment of the invention, when the closed HTML tag data is extracted, the replaceable style code corresponding to the closed HTML tag data is searched in the replaceable code set according to the preset corresponding relation, and the searched replaceable style code corresponds to the webpage style required by the data content. In addition, the data type in this step may be an actual content type of the data content, such as a picture type, an audio type, a text type, and the like, or a source type of the data content or a data type defined according to a division standard of each data type preset by a user, which is determined according to an actual situation and is not limited herein.
In step S104, a preset cascading style sheet is obtained in the local database, where the preset cascading style sheet carries at least a default style code and an active area.
In the embodiment of the invention, the preset cascading style sheet is equivalent to a complete cascading style sheet which is not yet written, fixed content codes contained in each cascading style sheet can be extracted according to actual conditions to generate the preset cascading style, the preset cascading style contains the active region capable of writing corresponding code contents according to style differences among different pages, and the preset cascading style can be generally used for pages with different display styles by editing the active region in the preset cascading style.
In the embodiment of the invention, the replaceable style code is a code for determining the style difference presented by different cascading style sheets, so that the difference of the replaceable style code is the root cause for different page styles based on the preset cascading style. Since the display style difference between the pages is different in different websites, the code amount of the fixed style code in the preset cascading style is determined according to the difference between the display styles of the pages in actual situations, and is not particularly limited herein.
In step S105, the replaceable style code is embedded into the active area of the preset cascading style sheet, and a target cascading style sheet is obtained.
In the embodiment of the invention, the replaceable style code is embedded into the active area of the cascading style sheet template, and actually the replaceable style code is edited into the active area of the cascading style sheet template, so that the cascading style sheet required by the page presentation data content is formed.
In step S106, the target cascading style sheet is output.
In the embodiment of the invention, a cascading style sheet generating method is provided, when closed HTML tag data in a target HTML file is detected, extracting the closed HTML tag data; reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code; acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation; acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area; embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet; and outputting the target cascading style sheet. The replaceable style codes are obtained by extracting the obtained target HTML data, and the target cascading style sheet corresponding to the CSS file is converted based on the replaceable style codes, so that the process of automatically converting the HTML file into the CSS file is realized, the accuracy can be greatly improved, and the development efficiency of the project can be improved.
Continuing to refer to fig. 2, a flowchart of an implementation of the method for determining a closed tag according to an embodiment of the present invention is shown, and for convenience of description, only the relevant portions of the method are shown.
In some optional implementations as the first embodiment, before the step S101, the method further includes: steps S201, S202, S203, and S204.
In step S201, when the user writes the target HTML file, a preset node parser is started to collect HTML tag data of the target HTML file.
In the embodiment of the present invention, when the target HTML file starts to be edited, it is considered that the user writes the target HTML file.
In the embodiment of the invention, the preset node parser is a JavaScript running environment based on a Chrome V8 engine, and the node parser is preset with event drive of 'target HTML file is written' and event drive of 'occurrence end tag'.
In the embodiment of the present invention, the monitoring operation refers to an operation of acquiring the content of the target HTML file in real time after the target HTML file is written.
In step S202, it is determined whether the HTML tag data satisfies a closed tag condition.
In the embodiment of the present invention, the HTML tags in which HTML documents and HTML elements are marked by HTML tags are composed of a start tag and an end tag, the start tag is an element name end tag enclosed by brackets, the slash enclosed by brackets is used as the element name end tag, and some HTML elements have no end tag, such as < br/> comment: the English translation of the start tag is a start tag or an opening tag, and the English translation of the end tag is an end tag or a closing tag.
In the embodiment of the invention, the condition of meeting the closed label can be judged by judging whether the end label appears. As an example, as described above, < div class > </div >, it is determined that the closed tag condition is not satisfied when the "</div >" of the top lattice does not occur, and it is determined that the closed tag condition is satisfied when the "</div >" of the top lattice occurs, it should be understood that the example of how to determine whether the end tag occurs is merely for convenience of understanding and is not limited to the embodiment of the present invention.
In step S203, if the HTML tag data satisfies the closed tag condition, it is determined that the closed HTML tag data appears in the target HTML file, and the HTML tag data is used as the closed HTML tag data.
In step S204, if the HTML tag data does not satisfy the closed tag condition, the HTML tag data of the target HTML file is continuously collected.
In the embodiment of the invention, whether closed HTML tag data appears in the target HTML file is judged by judging whether the end tag appears, the implementation mode is simple and convenient, and the processing efficiency of the system for detecting the target HTML file is effectively improved.
With continued reference to fig. 3, a flowchart of one implementation of step S202 in fig. 2 is shown, and for ease of illustration, only the portions relevant to the present invention are shown.
In some optional implementation manners of the first embodiment of the present invention, the step S202 specifically includes: step S301, step S302, step S303, and step S304.
In step S301, a closed tag set is obtained in the local database.
In the embodiment of the present invention, the local database stores in advance a tag set based on HTML codes, and is used to identify whether a tag set corresponding to a closed tag set in the local database appears in the HTML tag data, for example: the label sets of "< div class" > "and" </div > ", it should be understood that the example of the closed label set is only for convenience of understanding and is not meant to limit the embodiments of the present invention.
In step S302, it is determined whether a tag corresponding to the HTML tag data exists in the closed tag set.
In the embodiment of the invention, the closed tag set is preset in the local database, and the closed tag set is used for judging whether the HTML tag data meets the closed tag condition, so that the implementation mode is simple and convenient, and the processing efficiency of the system can be effectively improved.
In step S303, if there is no tag corresponding to the HTML tag data in the closed tag set, continue to collect HTML tag data of the target HTML file.
In step S304, if a tag corresponding to the HTML tag data exists in the closed tag set, it is determined whether the HTML tag data satisfies a closed tag format.
In embodiments of the present invention, the closed label format refers to a top case label. As an example, < divclass > </div > as described above, it is determined that the closed tag condition is not satisfied when "</div >" of the top lattice does not occur, and it is determined that the closed tag condition is satisfied when "</div >" of the top lattice occurs.
With continued reference to fig. 4, there is shown another implementation flowchart illustrating step S202 in fig. 2, and for convenience of illustration, only the parts relevant to the present invention are shown.
In some optional implementations as the first embodiment, the step S202 specifically includes: step S401, step S402, and step S403; step S203 specifically includes: step S404; step S204 specifically includes: step S405.
In step S401, the HTML tag data is traversed, and when the start format occurs, a tag data is inserted into the stack.
In the embodiment of the present invention, the start format refers to a start tag format of html code, and as an example, the start format may be "< T >", and it should be understood that the example of the start format is only for convenience of understanding and is not used to limit the embodiment of the present invention.
In an embodiment of the invention, the stack is a linear table with limited operations. A linear table is defined in which insert and delete operations are performed only at the end of the table. This end is referred to as the top of the stack, while the opposite end is referred to as the bottom of the stack. Inserting a new element into a stack, also called pushing, stacking or pushing, is to put the new element on the top element of the stack to make it become a new top element; deleting an element from a stack, also known as popping or popping, deletes the top-of-stack element, making its neighbors a new top-of-stack element.
In embodiments of the invention, the marking data is used only to mark elements present in the stack.
In step S402, when the end format occurs, one of the marker data is deleted in the stack.
In the embodiment of the present invention, the ending format refers to an ending tag format of html code, and as an example, the ending format may be "</T >, and it should be understood that the example of the ending format is only for convenience of understanding and is not used to limit the embodiment of the present invention.
In step S403, when the HTML tag data is traversed, it is determined whether the number of the tag data in the stack is zero.
In an embodiment of the invention, the stack is a special linear table that allows insert and delete operations to be performed at the same end. One end allowing the insert and delete operations is called the top of stack (top) and the other end is the bottom of stack (bottom); the stack bottom is fixed, and the stack top floats; the number of elements in the stack is zero and is called an empty stack. Insertion is generally referred to as PUSH (PUSH) and deletion is referred to as POP. The stack is also known as a first-in-last-out table.
In step S404, if the number of the tag data in the stack is zero, it is determined that the closed HTML tag data appears in the target HTML file, and the HTML tag data is used as the closed HTML tag data.
In step S405, if the number of the tag data in the stack is not zero, the HTML tag data of the target HTML file is continuously collected.
In the embodiment of the invention, the accuracy of judging the closed tag condition is reduced in order to avoid the condition that the set is missed in the closed tag set preset in the local database, so that whether the HTML tag data meets the closed tag condition is judged in a stacking mode, the closed tag set does not need to be preset in the local database, the implementation mode is simpler and more convenient and easier to operate, and the processing efficiency of the system is greatly improved.
In some optional implementation manners as the first embodiment of the present invention, an identity that uniquely represents the replaceable style code is marked in the replaceable style code;
the preset corresponding relation is specifically the corresponding relation between the closed HTML tag data and the identity mark.
In the embodiment of the invention, the replaceable style code is marked with the unique identity which can represent the identity of the replaceable style code in advance, correspondingly, the corresponding recorded content in the corresponding relation is the mapping relation between the data type and the identity, when the target replaceable style code corresponding to the data type is searched according to the corresponding relation, the replaceable style code can be represented by the identity, the corresponding target identity is searched according to the data type in the corresponding relation, and the target replaceable style code marked with the target identity is searched and obtained in the replaceable code set. Because the identity identification has simplicity compared with the replaceable style code, the implementation mode relatively ensures the high efficiency of searching the corresponding target replaceable style code according to the data type.
Continuing to refer to fig. 5, a flowchart of an implementation of the compatible cascading style sheet obtaining method provided in the first embodiment of the present invention is shown, and for convenience of description, only the relevant portions of the present invention are shown.
In some optional implementation manners of the first embodiment of the present invention, the step S105 specifically includes: step S501, step S502, and step S503.
In step S501, format contents in the preset cascading style sheet are modified into a compatible format.
In the embodiment of the present invention, the compatible format refers to a currently popular CSS preprocessing language, for example, formats such as LESSs, SASS, and the like, and it should be understood that the compatible format is only exemplified for convenience of understanding and is not limited to the embodiment of the present invention.
In practical application, the format modification in the preset cascading style sheet can be completed by setting the format attribute of the configuration file config to be the corresponding compatible format.
In step S502, the parent code of each level in the preset cascading style sheet is deleted and modified into a nested form, so as to obtain a compatible cascading style sheet.
In step S503, the replaceable style code is embedded into the active area of the compatible cascading style sheet, and the target cascading style sheet is obtained.
In the embodiment of the invention, the compatibility of two CSS preprocessing languages, namely the currently popular LESS and SASS, is realized by modifying the format content and the code form of the configuration file, so that the application range of the scheme is further improved, and the compatibility of the technical scheme is effectively improved.
In summary, the present invention provides a cascading style sheet generating method, wherein when closed HTML tag data is detected to appear in a target HTML file, the closed HTML tag data is extracted; reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code; acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation; acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area; embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet; and outputting the target cascading style sheet. The target attribute data are obtained by extracting the obtained target HTML data, and the target attribute data are converted into the target cascading style sheet corresponding to the CSS file based on the target attribute data, so that the process of automatically converting the HTML file into the CSS file based on the HTML file is realized, the accuracy can be greatly improved, and the development efficiency of the project can be improved. Meanwhile, whether closed HTML tag data appear in the target HTML file or not is judged by judging whether the end tag appears or not, the implementation mode is simple and convenient, and the processing efficiency of the system for detecting the target HTML file is effectively improved; the closed tag set is preset in the local database, and whether the HTML tag data meet the closed tag condition or not is judged by using the closed tag set, so that the realization mode is simple and convenient, and the processing efficiency of the system can be effectively improved; in order to avoid the situation that a set missing occurs in a closed tag set preset in a local database, the accuracy of judging the closed tag condition is reduced, so that whether HTML tag data meet the closed tag condition is judged in a stacking mode, the closed tag set does not need to be preset in the local database, the implementation mode is simpler and more convenient, the operation is easy, and the processing efficiency of the system is greatly improved; by modifying the format content and the code form of the configuration file, the compatibility of two CSS preprocessing languages, namely the LESS and the SASS, which are popular at present is realized, the adaptive range of the scheme is further improved, and the compatibility of the technical scheme is effectively improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
Example two
With further reference to fig. 6, as an implementation of the method shown in fig. 1, the present application provides a cascading style sheet generating apparatus, an embodiment of which corresponds to the embodiment of the method shown in fig. 1, and the apparatus can be applied to various electronic devices.
As shown in fig. 6, a stacking style sheet generating apparatus 100 according to a second embodiment of the present invention includes: a code set acquisition module 101, a code set acquisition module 102, a replacement code acquisition module 103, a cascading style sheet module 104, a target style sheet acquisition module 105, and a target style sheet output module 106. Wherein:
the tag extraction module 101 is configured to, when it is detected that closed HTML tag data occurs in a target HTML file, extract the closed HTML tag data;
a code set acquiring module 102, configured to read a local database, and acquire an alternative code set in the local database, where the alternative code set includes an alternative style code;
a replacing code obtaining module 103, configured to obtain, in the replaceable code set, a replaceable style code corresponding to the closed HTML tag data based on a preset correspondence;
a cascading style sheet module 104, configured to obtain a preset cascading style sheet in the local database, where the preset cascading style sheet carries at least a default style code and an active area;
a target style sheet obtaining module 105, configured to embed the replaceable style code into an active area of the preset cascading style sheet, and obtain a target cascading style sheet; and
and a target style sheet output module 106, configured to output the target cascading style sheet.
In the embodiment of the present invention, it is,
in the embodiment of the present invention, the target HTML file refers to an HTML file being written by a user.
In the embodiment of the present invention, the closed HTML tag data refers to the closed HTML tag data from the current start tag to the first end tag appearing in the target HTML file. As an example, for example, when the current start tag is < div class ═ imgbox >, and when the first end tag of the HTML file appears as </div >, the < div class ═ imgbox > to </div > are considered as closed HTML tag data.
In the embodiment of the present invention, the local database stores the above alternative code set in advance.
In the embodiment of the invention, the replaceable style code is a code for determining the style difference presented by different cascading style sheets, so that the difference of the replaceable style code is the root cause for different page styles based on the preset cascading style. Since the display style difference between the pages is different in different websites, the code amount of the fixed style code in the preset cascading style is determined according to the difference between the display styles of the pages in actual situations, and is not particularly limited herein.
In the embodiment of the invention, when the closed HTML tag data is extracted, the replaceable style code corresponding to the closed HTML tag data is searched in the replaceable code set according to the preset corresponding relation, and the searched replaceable style code corresponds to the webpage style required by the data content. In addition, the data type in this step may be an actual content type of the data content, such as a picture type, an audio type, a text type, and the like, or a source type of the data content or a data type defined according to a division standard of each data type preset by a user, which is determined according to an actual situation and is not limited herein.
In the embodiment of the invention, the preset cascading style sheet is equivalent to a complete cascading style sheet which is not yet written, fixed content codes contained in each cascading style sheet can be extracted according to actual conditions to generate the preset cascading style, the preset cascading style contains the active region capable of writing corresponding code contents according to style differences among different pages, and the preset cascading style can be generally used for pages with different display styles by editing the active region in the preset cascading style.
In the embodiment of the invention, the replaceable style code is a code for determining the style difference presented by different cascading style sheets, so that the difference of the replaceable style code is the root cause for different page styles based on the preset cascading style. Since the display style difference between the pages is different in different websites, the code amount of the fixed style code in the preset cascading style is determined according to the difference between the display styles of the pages in actual situations, and is not particularly limited herein.
In the embodiment of the invention, the replaceable style code is embedded into the active area of the cascading style sheet template, and actually the replaceable style code is edited into the active area of the cascading style sheet template, so that the cascading style sheet required by the page presentation data content is formed.
In an embodiment of the present invention, there is provided a cascading style sheet generating apparatus, including: the tag extraction module 101 is configured to, when it is detected that closed HTML tag data occurs in a target HTML file, extract the closed HTML tag data; a code set acquiring module 102, configured to read a local database, and acquire an alternative code set in the local database, where the alternative code set includes an alternative style code; a replacing code obtaining module 103, configured to obtain, in the replaceable code set, a replaceable style code corresponding to the closed HTML tag data based on a preset correspondence; a cascading style sheet module 104, configured to obtain a preset cascading style sheet in the local database, where the preset cascading style sheet carries at least a default style code and an active area; a target style sheet obtaining module 105, configured to embed the replaceable style code into an active area of the preset cascading style sheet, and obtain a target cascading style sheet; and a target style sheet output module 106, configured to output the target cascading style sheet. The target attribute data are obtained by extracting the obtained target HTML data, and the target attribute data are converted into the target cascading style sheet corresponding to the CSS file based on the target attribute data, so that the process of automatically converting the HTML file into the CSS file based on the HTML file is realized, the accuracy can be greatly improved, and the development efficiency of the project can be improved.
With reference to fig. 7, a schematic structural diagram of a closed tag determination apparatus according to a second embodiment of the present invention is shown, and for convenience of description, only the parts related to the present invention are shown.
In some optional implementations of the second embodiment of the present invention, as shown in fig. 7, the stacking style sheet generating apparatus 100 further includes: a start acquisition sub-module 107, a condition judgment sub-module 108, a closure determination sub-module 109, and a first continue acquisition sub-module 110. Wherein:
the start acquisition submodule 107 is configured to start a preset node parser to acquire HTML tag data of the target HTML file when the user writes the target HTML file;
a condition judgment submodule 108, configured to judge whether the HTML tag data meets a closed tag condition;
a closed determining submodule 109, configured to determine that the closed HTML tag data appears in the target HTML file if the HTML tag data meets the closed tag condition, and use the HTML tag data as the closed HTML tag data;
the first continuous collecting sub-module 110 is configured to continuously collect the HTML tag data of the target HTML file if the HTML tag data does not satisfy the closed tag condition.
In the embodiment of the present invention, when the target HTML file starts to be edited, it is considered that the user writes the target HTML file.
In the embodiment of the invention, the preset node parser is a JavaScript running environment based on a Chrome V8 engine, and the node parser is preset with event drive of 'target HTML file is written' and event drive of 'occurrence end tag'.
In the embodiment of the present invention, the monitoring operation refers to an operation of acquiring the content of the target HTML file in real time after the target HTML file is written.
In the embodiment of the present invention, the HTML tags in which HTML documents and HTML elements are marked by HTML tags are composed of a start tag and an end tag, the start tag is an element name end tag enclosed by brackets, the slash enclosed by brackets is used as the element name end tag, and some HTML elements have no end tag, such as < br/> comment: the English translation of the start tag is a start tag or an opening tag, and the English translation of the end tag is an end tag or a closing tag.
In the embodiment of the invention, the condition of meeting the closed label can be judged by judging whether the end label appears. As an example, as described above, < div class > </div >, it is determined that the closed tag condition is not satisfied when the "</div >" of the top lattice does not occur, and it is determined that the closed tag condition is satisfied when the "</div >" of the top lattice occurs, it should be understood that the example of how to determine whether the end tag occurs is merely for convenience of understanding and is not limited to the embodiment of the present invention.
In the embodiment of the invention, whether closed HTML tag data appears in the target HTML file is judged by judging whether the end tag appears, the implementation mode is simple and convenient, and the processing efficiency of the system for detecting the target HTML file is effectively improved.
In some optional implementations of the second embodiment of the present invention, the condition determining sub-module 106 includes: the system comprises a label set acquisition submodule, a label judgment submodule, a second continuous acquisition submodule and a format judgment submodule. Wherein:
the tag set acquisition submodule is used for acquiring a closed tag set from the local database;
the tag judgment submodule is used for judging whether tags corresponding to the HTML tag data exist in the closed tag set or not;
the second continuous acquisition submodule is used for continuously acquiring the HTML tag data of the target HTML file if the tag corresponding to the HTML tag data does not exist in the closed tag set;
and the format judgment submodule is used for judging whether the HTML tag data meet the closed tag format or not if the tags corresponding to the HTML tag data exist in the closed tag set.
In the embodiment of the invention, the closed tag set is preset in the local database, and the closed tag set is used for judging whether the HTML tag data meets the closed tag condition, so that the implementation mode is simple and convenient, and the processing efficiency of the system can be effectively improved.
In some optional implementations of the second embodiment of the present invention, the condition determining sub-module 106 includes:
the tag insertion submodule is used for traversing the HTML tag data, and inserting a tag datum into the stack when the starting format occurs;
a tag delete sub-module for deleting one of said tag data in said stack when an end format occurs;
the tag quantity judging submodule is used for judging whether the number of the tag data in the stack is zero or not when the HTML tag data is traversed;
a correct tag number sub-module, configured to determine that the closed HTML tag data appears in the target HTML file if the number of the tag data in the stack is zero, and use the HTML tag data as the closed HTML tag data;
and the marking number error submodule is used for continuously acquiring the HTML tag data of the target HTML file if the number of the marking data in the stack is not zero.
In the embodiment of the invention, the accuracy of judging the closed label condition is reduced in order to avoid the condition that the set is missed in the closed label set preset in the local database, so that whether the replaceable style code meets the closed label condition is judged in a stacking mode without presetting the closed label set in the local database, the implementation mode is simpler and more convenient and easier to operate, and the processing efficiency of the system is greatly improved.
In some optional implementations of the second embodiment of the present invention, an identity uniquely characterizing the replaceable style code is marked in the replaceable style code;
the preset corresponding relation is specifically the corresponding relation between the closed HTML tag data and the identity mark.
The implementation mode relatively ensures the high efficiency of searching the corresponding target replaceable style code according to the data type.
In some optional implementations of the second embodiment of the present invention, the stacking style sheet generating apparatus 100 further includes: the device comprises a format modification submodule, a compatible style sheet acquisition submodule and a target style sheet acquisition submodule. Wherein:
the format modification submodule is used for modifying the format content in the preset cascading style sheet into a compatible format;
the compatible style sheet acquisition submodule is used for deleting the parent code of each level in the preset cascading style sheet, modifying the parent code into a nested form and acquiring a compatible cascading style sheet;
and the target style sheet acquisition submodule is used for embedding the replaceable style code into the active area of the compatible cascading style sheet and acquiring the target cascading style sheet.
In the embodiment of the invention, the compatibility of two CSS preprocessing languages, namely the currently popular LESS and SASS, is realized by modifying the format content and the code form of the configuration file, so that the application range of the scheme is further improved, and the compatibility of the technical scheme is effectively improved.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 8, fig. 8 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 8 comprises a memory 81, a processor 82, a network interface 83 communicatively connected to each other via a system bus. It is noted that only computer device 8 having components 81-83 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable gate array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 81 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 81 may be an internal storage unit of the computer device 8, such as a hard disk or a memory of the computer device 8. In other embodiments, the memory 81 may also be an external storage device of the computer device 8, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a flash Card (FlashCard), and the like, which are provided on the computer device 8. Of course, the memory 81 may also comprise both an internal storage unit of the computer device 8 and an external storage device thereof. In this embodiment, the memory 81 is generally used for storing an operating system installed in the computer device 8 and various types of application software, such as program codes of the X method. Further, the memory 81 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 82 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 82 is typically used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is configured to execute the program code stored in the memory 81 or process data, for example, execute the program code of the X method.
The network interface 83 may comprise a wireless network interface or a wired network interface, and the network interface 83 is generally used for establishing communication connections between the computer device 8 and other electronic devices.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing an X program, which is executable by at least one processor to cause the at least one processor to perform the steps of the X method as described above.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A method for generating a cascading style sheet, the method comprising the steps of:
when closed HTML tag data appear in a target HTML file, extracting the closed HTML tag data;
reading a local database, and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code;
acquiring replaceable style codes corresponding to the closed HTML label data in the replaceable code set based on a preset corresponding relation;
acquiring a preset cascading style sheet in the local database, wherein the preset cascading style sheet at least carries a default style code and an active area;
embedding the replaceable style code into an active area of the preset cascading style sheet to obtain a target cascading style sheet;
and outputting the target cascading style sheet.
2. The cascading style sheet generating method of claim 1, wherein before the step of extracting closed HTML tag data when the presence of the closed HTML tag data in the target HTML file is detected, further comprising:
when a user writes the target HTML file, starting a preset node parser to collect HTML tag data of the target HTML file;
judging whether the HTML label data meets a closed label condition or not;
if the HTML tag data meet the closed tag condition, judging that the closed HTML tag data appear in the target HTML file, and taking the HTML tag data as the closed HTML tag data;
and if the HTML tag data do not meet the closed tag condition, continuously collecting the HTML tag data of the target HTML file.
3. The method according to claim 2, wherein the step of determining whether the HTML tag data satisfies a closed tag condition specifically includes:
acquiring a closed label set in the local database;
judging whether a tag corresponding to the HTML tag data exists in the closed tag set or not;
if the tag corresponding to the HTML tag data does not exist in the closed tag set, continuously collecting the HTML tag data of the target HTML file;
and if the tag corresponding to the HTML tag data exists in the closed tag set, judging whether the HTML tag data meets a closed tag format.
4. The method according to claim 2, wherein the step of determining whether the HTML tag data satisfies a closed tag condition specifically includes:
traversing the HTML tag data, and inserting a piece of marking data into the stack when the starting format occurs;
deleting one of said marker data in said stack when an end format occurs;
when the HTML tag data is traversed, judging whether the number of the tag data in the stack is zero or not;
if the number of the tag data in the stack is zero, judging that the closed HTML tag data appears in the target HTML file, and taking the HTML tag data as the closed HTML tag data;
and if the number of the marked data in the stack is not zero, continuously collecting the HTML label data of the target HTML file.
5. The cascading style sheet generating method of claim 1, wherein the replaceable style code is marked with an identity that uniquely characterizes the replaceable style code;
the preset corresponding relation is specifically the corresponding relation between the closed HTML tag data and the identity mark.
6. The cascading style sheet generating method according to claim 1, wherein the step of acquiring the target cascading style sheet by embedding the replaceable style code into the active area of the preset cascading style sheet further includes:
modifying the format content in the preset cascading style sheet into a compatible format;
deleting the parent code of each level in the preset cascading style sheet, modifying the parent code into a nested form, and obtaining a compatible cascading style sheet;
and embedding the replaceable style code into an active area of the compatible cascading style sheet to obtain the target cascading style sheet.
7. A cascading style sheet generating apparatus, the apparatus comprising:
the tag extraction module is used for extracting closed HTML tag data when the closed HTML tag data in the target HTML file is detected;
the code set acquisition module is used for reading a local database and acquiring a replaceable code set in the local database, wherein the replaceable code set comprises a replaceable style code;
a replacing code obtaining module, configured to obtain, in the replaceable code set, a replaceable style code corresponding to the closed HTML tag data based on a preset correspondence;
the cascading style sheet module is used for acquiring a preset cascading style sheet from the local database, and the preset cascading style sheet at least carries a default style code and an active area;
the target style sheet acquisition module is used for embedding the replaceable style codes into the active area of the preset cascading style sheet to acquire a target cascading style sheet; and
and the target style sheet output module is used for outputting the target cascading style sheet.
8. The overlay style sheet generation apparatus according to claim 7, further comprising:
the starting and collecting submodule is used for starting a preset node analyzer to collect the replaceable style codes of the target HTML file when the target HTML file is compiled by a user;
the condition judgment submodule is used for judging whether the replaceable style code meets a closed label condition;
the condition meeting submodule is used for judging that the closed HTML tag data appears in the target HTML file if the replaceable style code meets the closed tag condition, and taking the replaceable style code as the closed HTML tag data;
and the condition insufficiency sub-module is used for continuously collecting the replaceable style codes of the target HTML file if the replaceable style codes do not meet the closed label condition.
9. A computer device comprising a memory having stored therein a computer program and a processor which, when executing the computer program, implements the steps of the cascading style sheet generating method of any one of claims 1-6.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the cascading style sheet generation method of any one of claims 1 to 6.
CN202010333551.5A 2020-04-24 2020-04-24 Cascading style sheet generation method and device, computer equipment and storage medium Pending CN111679825A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010333551.5A CN111679825A (en) 2020-04-24 2020-04-24 Cascading style sheet generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010333551.5A CN111679825A (en) 2020-04-24 2020-04-24 Cascading style sheet generation method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111679825A true CN111679825A (en) 2020-09-18

Family

ID=72452177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010333551.5A Pending CN111679825A (en) 2020-04-24 2020-04-24 Cascading style sheet generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111679825A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113296773A (en) * 2021-05-28 2021-08-24 北京思特奇信息技术股份有限公司 Copyright marking method and system for cascading style sheet
CN114428615A (en) * 2022-01-26 2022-05-03 北京有竹居网络技术有限公司 CSS compiling method, style updating method, device, medium and equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113296773A (en) * 2021-05-28 2021-08-24 北京思特奇信息技术股份有限公司 Copyright marking method and system for cascading style sheet
CN114428615A (en) * 2022-01-26 2022-05-03 北京有竹居网络技术有限公司 CSS compiling method, style updating method, device, medium and equipment
CN114428615B (en) * 2022-01-26 2024-05-17 北京有竹居网络技术有限公司 CSS compiling method, style updating device, medium and equipment

Similar Documents

Publication Publication Date Title
CN109062874B (en) Financial data acquisition method, terminal device and medium
RU2358311C2 (en) Word processing document, stored as single xml file, which can be manipulated by applications which can read xml language
JP2005339566A (en) Method and system for mapping content between starting template and target template
CN111679825A (en) Cascading style sheet generation method and device, computer equipment and storage medium
CN110347390B (en) Method, storage medium, equipment and system for rapidly generating WEB page
CN111797630A (en) PDF-format-paper-oriented biomedical entity identification method
CN114238575A (en) Document parsing method, system, computer device and computer-readable storage medium
CN112527291A (en) Webpage generation method and device, electronic equipment and storage medium
CN116402020A (en) Signature imaging processing method, system and storage medium based on OFD document
CN110414010A (en) The processing method of internationalized resources file translation text, readable storage medium storing program for executing
CN112965772A (en) Web page display method and device and electronic equipment
CN112328246A (en) Page component generation method and device, computer equipment and storage medium
CN111241096A (en) Text extraction method, system, terminal and storage medium for EXCEL document
JP4072293B2 (en) Data processing method and apparatus, and storage medium
CN113255369B (en) Text similarity analysis method and device and storage medium
CN115169292A (en) Document processing method and device, electronic equipment and computer readable storage medium
CN114637505A (en) Page content extraction method and device
CN112428705A (en) Drawing printing and filing system
CN113378526A (en) PDF paragraph processing method, device, storage medium and equipment
CN110795931B (en) Method and terminal for detecting WEB website page language
CN112417819A (en) Word document information extraction method and device, electronic equipment and medium
CN108319467B (en) Comment filling method
CN110837614A (en) Method and system for efficiently generating webpage information extraction rule
CN114154092B (en) Method for translating web pages and related product
CN114035726B (en) Method and system for robot flow automatic page element identification process

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210209

Address after: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.)

Applicant after: Shenzhen saiante Technology Service Co.,Ltd.

Address before: 1-34 / F, Qianhai free trade building, 3048 Xinghai Avenue, Mawan, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong 518000

Applicant before: Ping An International Smart City Technology Co.,Ltd.

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination