CN116956823A - Document compiling method, device, computer readable medium and electronic equipment - Google Patents

Document compiling method, device, computer readable medium and electronic equipment Download PDF

Info

Publication number
CN116956823A
CN116956823A CN202210413701.2A CN202210413701A CN116956823A CN 116956823 A CN116956823 A CN 116956823A CN 202210413701 A CN202210413701 A CN 202210413701A CN 116956823 A CN116956823 A CN 116956823A
Authority
CN
China
Prior art keywords
document
mark information
compiling
information
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
CN202210413701.2A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210413701.2A priority Critical patent/CN116956823A/en
Publication of CN116956823A publication Critical patent/CN116956823A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/131Fragmentation of text files, e.g. creating reusable text-blocks; Linking to fragments, e.g. using XInclude; Namespaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/221Parsing markup language streams
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application belongs to the field of document processing, and relates to a document compiling method, a device, a computer readable medium and electronic equipment. The method comprises the following steps: responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document; analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document; acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises at least one of insertion information and deletion information required for converting the first mark information sequence into the second mark information sequence; and compiling in the original code corresponding to the original document according to the minimum editing script to obtain the compiling code corresponding to the updated document. The application can improve the compiling efficiency and the document preview quality.

Description

Document compiling method, device, computer readable medium and electronic equipment
Technical Field
The application belongs to the technical field of document processing, and particularly relates to a document compiling method, a document compiling device, a computer readable medium and electronic equipment.
Background
The Markdown grammar is a markup language in a plain text format, and can enable common text contents to have a certain format through a simple markup grammar. While editing Markdown text with Markdown grammar, the Markdown text may be compiled and rendered to obtain HTML (Hyper Text Markup Language ) web page text.
At present, when updating operations such as adding, deleting and replacing Markdown texts are performed, compiling and rendering are required to be performed on the whole Markdown document so as to realize real-time preview, but the mode is long in time consumption, the phenomenon of page clamping and blocking easily occurs under the condition that the document content is long, and the document preview efficiency is poor.
Disclosure of Invention
The application aims to provide a document compiling method, a document compiling device, a computer readable medium and electronic equipment, which can overcome the problem of long time consumption for compiling and rendering Markdown documents in the related technology.
Other features and advantages of the application will be apparent from the following detailed description, or may be learned by the practice of the application.
According to an aspect of an embodiment of the present application, there is provided a document compiling method, the method including: responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document; analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document; acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises at least one of insert information and delete information required for converting the first mark information sequence into the second mark information sequence; and compiling in the original code corresponding to the original document according to the minimum editing script to obtain the compiling code corresponding to the updated document.
According to an aspect of an embodiment of the present application, there is provided a document compiling apparatus including: the response module is used for responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document; the analysis module is used for analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document; the comparison module is used for acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises at least one of insertion information and deletion information required for converting the first mark information sequence into the second mark information sequence; and the compiling module is used for compiling in the original codes corresponding to the original document according to the minimum editing script so as to obtain the compiling codes corresponding to the updated document.
In some embodiments of the present application, based on the above technical solution, the parsing module includes: an obtaining unit, configured to obtain a first block structure and a first inline structure in the original document, and obtain a second block structure and a second inline structure in the updated document at the same time; the analysis unit is used for analyzing the first block structure and the second block structure through a block analysis rule chain in the analysis rule set to acquire marking information corresponding to the first block structure and the second block structure, and analyzing the first inline structure and the second inline structure through an inline analysis rule chain in the analysis rule set to acquire marking information corresponding to the first inline structure and the second inline structure; and the mark information stream generating unit is used for generating the first mark information stream according to the mark information corresponding to the first block structure and the mark information corresponding to the first inline structure, and generating the second mark information stream according to the mark information corresponding to the second block structure and the mark information corresponding to the second inline structure.
In some embodiments of the present application, based on the above technical solution, the acquiring unit is configured to: unifying line-feed symbols in the original document and the updated document by adopting unification rules in the analysis rule set; and processing the original document and the updated document by adopting the mark recognition rules in the analysis rule set to acquire the first block structure, the first inline structure, the second block structure and the second inline structure.
In some embodiments of the present application, based on the above technical solutions, the comparison module is configured to: and respectively grouping the first mark information stream and the second mark information stream according to a preset rule, and generating the first mark information sequence and the second mark information sequence according to the information in each group.
In some embodiments of the present application, based on the above technical solution, the preset rule includes any one of the following: the outermost elements in the first and second streams of marker information, a fixed number of groups.
In some embodiments of the present application, based on the above technical solutions, the comparison module includes: a diagram construction unit for constructing an edit diagram according to the first marker information sequence and the second marker information sequence; a pairing point determining unit, configured to determine a pairing point in the edit graph according to the element in the first marker information sequence and the element in the second marker information sequence; and the script determining unit is used for determining the minimum editing script according to the pairing point.
In some embodiments of the present application, based on the above technical solution, the script determining unit includes: a path generating unit, configured to connect adjacent nodes in the edit graph along a direction from a start point to an end point of the edit graph, so as to generate a path including the pairing point; and the script generation unit is used for determining a minimum editing path according to the path and generating the minimum editing script according to the minimum editing path.
In some embodiments of the present application, based on the above technical solution, the script generating unit is configured to: acquiring a first sub-path and/or a second sub-path in the path, and determining the minimum editing path according to the first sub-path and/or the second sub-path; the first sub-path is a path along the horizontal direction in the paths, and the second sub-path is a path along the vertical direction in the paths.
In some embodiments of the present application, the insertion information includes an insertion object and an insertion identifier, and the deletion information includes a deletion object and a deletion identifier; based on the above technical scheme, the compiling module is configured to: when the minimum editing script includes insertion information or deletion information required to convert the first marker information sequence into the second marker information sequence; determining a first target code in the original code according to the insertion identifier; inserting a code corresponding to the insertion object after the first object code; or determining a second target code in the original code according to the deletion identifier; and deleting the code corresponding to the deleting object in the second target code.
In some embodiments of the present application, the insertion information includes an insertion object and an insertion identifier, and the deletion information includes a deletion object and a deletion identifier; based on the above technical scheme, the compiling module is configured to: when the minimum editing script includes insertion information and deletion information required to convert the first marker information sequence into the second marker information sequence; determining a third target code in the original code according to the insertion identifier; inserting a code corresponding to the insertion object after the third object code; and determining a fourth target code in the original code according to the deletion identifier; and deleting the code corresponding to the deleting object in the fourth target code.
In some embodiments of the present application, based on the above technical solution, the document compiling apparatus is further configured to: and after the compiled code is obtained, rendering is carried out according to the compiled code so as to display the HTML webpage document corresponding to the updated document in a display interface.
In some embodiments of the present application, based on the above technical solution, the rendering according to the compiled code is configured to: and calling a rendering interface, acquiring a target rendering rule according to the type of the compiled code, and rendering according to the target rendering rule and the compiled code.
According to an aspect of the embodiments of the present application, there is provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements a document compiling method as in the above technical solution.
According to an aspect of an embodiment of the present application, there is provided an electronic apparatus including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the document compiling method as in the above technical solution via execution of the executable instructions.
According to the document compiling method provided by the embodiment of the application, on one hand, the first mark information sequence and the second mark information sequence can be obtained by analyzing the original document and the updated document generated after updating the original document, and the minimum editing script corresponding to the updated content can be determined by comparing the first mark information sequence with the second mark information sequence, so that when compiling and rendering, only the original code corresponding to the original document is required to be locally compiled according to the minimum editing script, and the obtained local compiling code is required to be locally rendered, and the compiling and rendering efficiency is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application as claimed.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application. It is evident that the drawings in the following description are only some embodiments of the present application and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
Fig. 1 schematically shows a block diagram of a system to which the technical solution of the application is applied in one embodiment.
Fig. 2 schematically shows an interface diagram of editing and modifying text using Markdown grammar in the related art, and synchronizing previews.
Fig. 3 schematically shows a flow chart of steps of a method for compiling a file in one embodiment.
FIG. 4 schematically illustrates a flow diagram for converting an MD document into an HTML web document using MarkDown-it in one embodiment.
Fig. 5 schematically shows a flow diagram for acquiring a first marker information stream and a second marker information stream in one embodiment.
FIG. 6 schematically illustrates an interface diagram for grouping marker information streams according to outermost elements in the marker information streams in one embodiment.
Fig. 7 schematically shows a flowchart of the related art for comparing the first marker information sequence and the second marker information sequence to obtain the difference information.
FIG. 8 schematically illustrates an interface diagram of an edit graph in one embodiment.
FIG. 9 schematically illustrates an interface diagram for obtaining a minimum edit path in one embodiment.
FIG. 10 schematically illustrates an interface diagram for editing modified text using MarkDown grammar and synchronizing previews in one embodiment.
Fig. 11 schematically shows a block diagram of the structure of the file compiling apparatus in one embodiment.
FIG. 12 schematically illustrates a block diagram of a computer system suitable for use in implementing an embodiment of the application.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the application may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
Fig. 1 schematically shows a block diagram of an exemplary system architecture to which the technical solution of the present application is applied.
As shown in fig. 1, system architecture 100 may include a terminal device 101, a network 102, and a server 103. The terminal device 101 may include various electronic devices with display screens, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart television, and a smart car terminal. The server 103 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing services. Network 102 is a communication medium of various connection types capable of providing a communication link between terminal device 101 and server 103, and may be, for example, a wired communication link or a wireless communication link.
The system architecture in embodiments of the present application may have any number of terminal devices, networks, and servers, as desired for implementation. For example, the server may be a server group composed of a plurality of server devices. In addition, the technical solution provided in the embodiment of the present application may be applied to the server 103, or may be applied to the terminal device 101, or may be implemented by both the terminal device 101 and the server 103, which is not limited in particular.
In one embodiment of the present application, upon receiving information input by a document editor for text editing using Markdown syntax, the terminal device 101 transmits a document compiling request to the server 103 via the network 102, and transmits an original document edited by the document editor before the document update and an updated document to the server 103, and the server 103 parses the original document and the updated document in response to the document compiling request to obtain a first flag information stream corresponding to the original document and a second flag information stream corresponding to the updated document, and further obtains a first flag information sequence and a second flag information sequence according to the first flag information stream and the second flag information stream. And then, the first mark information sequence and the second mark information sequence can be compared, the difference information is extracted, and the minimum editing script can be determined according to the extracted difference information. And finally compiling in the original code corresponding to the original document based on the minimum editing script, and rendering according to the compiled code to obtain the HTML webpage document corresponding to the updated document. In the embodiment of the present application, compiling in the original code based on the minimum editing script is a kind of partial compiling behavior, that is, compiling only the flag information corresponding to the portion in the original document where the update occurs.
The method for compiling a document in the embodiment of the application can also be executed by the terminal equipment 101, when a document editor updates and edits an original document in the terminal equipment 101, the terminal equipment 101 can acquire the original document and a corresponding updated document, then a parser can be called to parse the original document and the updated document so as to acquire a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document, and further acquire a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream. After the first mark information sequence and the second mark information sequence are obtained, difference information between the first mark information sequence and the second mark information sequence can be searched, and a minimum editing script is determined according to the difference information, namely, the minimum editing script comprises at least one of insertion information and deletion information required for converting the first mark information sequence into the second mark information sequence, and finally, compiling is carried out in original codes corresponding to an original document according to the minimum editing script, and rendering is carried out according to codes obtained through compiling, so that an HTML webpage document corresponding to an updated document can be obtained. Likewise, where compilation in the original code is based on a minimal editing script is also a partial compilation.
In one embodiment of the present application, a cloud server providing cloud computing services may be used to execute the document compiling method in the present application, and accordingly, the technical solution of the present application relates to cloud computing and cloud storage in cloud technology.
Cloud computing (clouding) is a computing model that distributes computing tasks across a large pool of computers, enabling various application systems to acquire computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the cloud are infinitely expandable in the sense of users, and can be acquired at any time, used as needed, expanded at any time and paid for use as needed.
As a basic capability provider of cloud computing, a cloud computing resource pool (cloud platform for short, generally referred to as IaaS (Infrastructure as a Service, infrastructure as a service) platform) is established, in which multiple types of virtual resources are deployed for external clients to select for use.
According to the logic function division, a PaaS (Platform as a Service ) layer can be deployed on an IaaS (Infrastructure as a Service ) layer, and a SaaS (Software as a Service, software as a service) layer can be deployed above the PaaS layer, or the SaaS can be directly deployed on the IaaS. PaaS is a platform on which software runs, such as a database, web container, etc. SaaS is a wide variety of business software such as web portals, sms mass senders, etc. Generally, saaS and PaaS are upper layers relative to IaaS.
Cloud storage (cloud storage) is a new concept that extends and develops in the concept of cloud computing, and a distributed cloud storage system (hereinafter referred to as a storage system for short) refers to a storage system that integrates a large number of storage devices (storage devices are also referred to as storage nodes) of various types in a network to work cooperatively through application software or application interfaces through functions such as cluster application, grid technology, and a distributed storage file system, so as to provide data storage and service access functions for the outside.
At present, the storage method of the storage system is as follows: when creating logical volumes, each logical volume is allocated a physical storage space, which may be a disk composition of a certain storage device or of several storage devices. The client stores data on a certain logical volume, that is, the data is stored on a file system, the file system divides the data into a plurality of parts, each part is an object, the object not only contains the data but also contains additional information such as a data Identification (ID) and the like, the file system writes each object into a physical storage space of the logical volume, and the file system records storage position information of each object, so that when the client requests to access the data, the file system can enable the client to access the data according to the storage position information of each object.
The process of allocating physical storage space for the logical volume by the storage system specifically includes: physical storage space is divided into stripes in advance according to the set of capacity measures for objects stored on a logical volume (which measures tend to have a large margin with respect to the capacity of the object actually to be stored) and redundant array of independent disks (RAID, redundant Array of Independent Disk), and a logical volume can be understood as a stripe, whereby physical storage space is allocated for the logical volume.
In the related art in the field, a Markdown grammar is adopted to edit a text, when the edited Markdown text is modified, the whole document is generally compiled and rendered to realize real-time preview, but the mode has the problem of long time consumption, and when the document content is longer, the phenomenon of page clamping and stopping can occur, so that the preview efficiency of the document is influenced, and further the experience of a document editor is influenced.
Fig. 2 shows an interface diagram of editing and modifying text by using Markdown grammar in the related art and synchronously previewing, and as shown in fig. 2, an editing area is displayed on the left side of a display interface, a preview area is displayed on the right side of the display interface, and a document editor can edit text in the editing area based on the Markdown grammar and previews the edited document in the preview area. As shown in fig. 2, in the editing process, the document editor wants to add a piece of text between the first section and the second section, and the document editor has entered "rules and authentication methods related to the interface at API access" in the editing area, but only "interface at API access" is displayed in the preview area, because Markdown text is compiled and rendered according to the whole document at the time of compiling and rendering, and thus, there is a difference between the information presented in the preview area and the information in the editing area, and is not presented synchronously.
In view of the problems in the related art, the following describes in detail, with reference to specific embodiments, the technical schemes such as the document compiling method, the document compiling apparatus, the computer readable medium, and the electronic device provided by the present application.
Fig. 3 schematically shows a schematic flow chart of steps of a document compiling method according to an embodiment of the application, which may be performed by a server, which may be specifically the server 103 in fig. 1, but may also be performed by the terminal device 101. As shown in fig. 3, the document compiling method in the embodiment of the application may mainly include the following steps S310 to S340.
Step S310: responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document;
step S320: analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document;
step S330: acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises at least one of insert information and delete information required for converting the first mark information sequence into the second mark information sequence;
Step S340: and carrying out partial compiling in the original code corresponding to the original document according to the minimum editing script so as to obtain the partial compiling code corresponding to the updated document.
According to the document compiling method provided by the embodiment of the application, on one hand, the first mark information sequence and the second mark information sequence can be obtained by analyzing the original document and the updated document generated after updating the original document, and the minimum editing script corresponding to the updated content can be determined by comparing the first mark information sequence with the second mark information sequence, so that when compiling and rendering, only the original code corresponding to the original document is required to be locally compiled according to the minimum editing script, and the obtained local compiling code is required to be locally rendered, and the compiling and rendering efficiency is improved.
The document compiling method is suitable for online documents and offline documents, and the detailed description of the specific implementation mode of each method step of the document compiling method is given by taking the online documents as an example, and it is worth noting that for convenience of description, the text edited based on Markdown grammar is recorded as MD text, and the text generated after rendering is recorded as HTML webpage text. Meanwhile, the marked information stream is a Token stream generated by performing lexical analysis on the document and converting the character sequence in the document, so that for convenience of description, in the application, the first marked information stream is marked as a first Token stream, the second marked information stream is marked as a second Token stream, the first marked information sequence is marked as a first Token sequence, and the second marked information sequence is marked as a second Token sequence.
In step S310, in response to the document compilation request, the original document and the updated document are contained in the document compilation request.
In one embodiment of the present application, an input operation of a document editor in real time or after a preset period of time may be regarded as a trigger condition for triggering a document compiling request, where the real-time input operation is regarded as a trigger condition, that is, when the document editor inputs the document through an input unit built in the terminal device or an input device connected to the outside of the terminal device, local compiling of an updated document may be triggered; when the input operation after the preset time period is regarded as the trigger condition, the preset time period may be a time interval set according to actual needs, for example, set to 30s, 1min, etc., which is not limited in detail in the embodiment of the present application.
Because the technical scheme of the application is to acquire the updated content existing in the updated document compared with the original document, and then compile and render only Token corresponding to the updated content, when triggering the document compiling request, the original document and the updated document need to be acquired, and the document compiling request is generated according to the original document and the updated document. In the embodiment of the present application, when the document editor edits the document using Markdown syntax, the operations such as adding, deleting, replacing, etc. the original MD document may be regarded as an update operation for the original MD text.
When the real-time input operation of the document editor is regarded as a triggering condition for triggering the document compiling request, the document generated by the document editor in any type of updating processing on the document displayed in the current editing area can be obtained in real time, the document is an updated document, and meanwhile, the document displayed in the editing area when the updating processing is not performed is taken as an original document; when an input operation after a preset period of time of a document editor is regarded as a trigger condition for triggering a document compiling request, a document displayed in a current editing area may be regarded as an original document, and a document displayed in an editing area after the preset period of time may be regarded as an updated document, for example, when the preset period of time is 30s, a document in an editing area corresponding to the current time t may be regarded as an original document, and a document in an editing area corresponding to t+30s may be regarded as an updated document.
In step S320, the original document and the updated document are parsed to acquire a first markup information stream corresponding to the original document and a second markup information stream corresponding to the updated document.
In one embodiment of the present application, after the original document and the updated document are acquired, the original document and the updated document may be parsed to acquire a first Token stream corresponding to the original document and a second Token stream corresponding to the updated document, and information comparison is performed based on the first Token stream and the second Token stream to acquire difference information between the two, that is, updated content, and further compiling and rendering are performed according to the updated content. In the embodiment of the present application, since the update contents are different Token between the first Token stream and the second Token stream, when compiling and rendering according to the update contents, only partial compiling is performed according to the acquired update contents, and accordingly, after acquiring the partial compiled code, partial rendering can be performed according to the partial compiled code. Therefore, the rendering according to codes corresponding to the whole document can be avoided, and compiling and rendering efficiency is improved.
In one embodiment of the application, when parsing the original document and the updated document, a parser, which may be specifically a parsing algorithm in Markdown-it, may be invoked for parsing. Markdown-it is a Markdown parser tool that can convert documents generated based on Markdown syntax into visual HTML web documents. The process of converting the MD document into the HTML webpage document comprises two steps of parsing and rendering, wherein the parsing is realized by a Parser (Parser) and the rendering is realized by a renderer.
FIG. 4 shows a schematic flow diagram of converting an MD document into an HTML web document using MarkDown-it, as shown in FIG. 4, by first parsing the MD document into a Token stream 402 in the form of an array by a parser 401, the Token stream 402 being made up of a plurality of tokens; the HTML web document 404 is then generated by rendering by the renderer 403 from each Token in the Token stream.
In accordance with the flow shown in fig. 4, when the original document and the updated document are parsed, the original document and the updated document are parsed by the parser, and a first Token stream corresponding to the original document and a second Token stream corresponding to the updated document are generated. Next, a specific flow of acquiring the first Token stream and the second Token stream will be described.
Fig. 5 shows a flow chart of acquiring the first mark information stream and the second mark information stream, and as shown in fig. 5, in step S501, a first block structure and a first inline structure in an original document are acquired while a second block structure and a second inline structure in an updated document are acquired; in step S502, the first block structure and the second block structure are parsed by the block parsing rule chain in the parsing rule set to obtain the tag information corresponding to the first block structure and the second block structure, and the first inline structure and the second inline structure are parsed by the inline parsing rule chain in the parsing rule set to obtain the tag information corresponding to the first inline structure and the second inline structure; in step S503, a first flag information stream is generated based on the flag information corresponding to the first block structure and the flag information corresponding to the first inline structure, and a second flag information stream is generated based on the flag information corresponding to the second block structure and the flag information corresponding to the second inline structure.
The block structure (block) and the inline structure (inline) are two basic structures forming an MD document, and the corresponding Token stream can be obtained by analyzing the block structures and the inline structures in the original document and the updated document. When analyzing, firstly, adopting an identification rule in an analysis rule set to identify and acquire a Block identifier (Block Token) and an Inline identifier (Inline Token), when identifying and acquiring the Block identifier, starting a Block analysis rule Chain (Block Chain) to analyze a Block structure corresponding to the Block identifier, when identifying and acquiring the Inline identifier, starting an Inline analysis rule Chain (Inline Chain) to analyze an Inline structure corresponding to the Inline identifier, and acquiring a corresponding Token stream according to an analysis result.
In one embodiment of the application, the original document and the updated document are required to be preprocessed before the block structure and the inline structure are analyzed, specifically, the unification rule in the analysis rule set can be adopted to perform unification processing on line-feeding symbols in the original document and the updated document, namely, the blank characters\u000 are converted into\uFFFD, and the block identifier and the inline identifier can be accurately identified through the unification line-feeding symbols, so that the block structure and the inline structure are obtained, and the block structure and the inline structure are analyzed to obtain accurate Token flow.
In one embodiment of the application, other rules in the parsing rule set can be called to process the original document and the updated document, for example, whether a recognizable URL exists in an identification structure of a text type can be detected through a link rule (link), the URL can be of an http type or a mail type, if so, an originally complete text token is divided into text, link, text three parts, and although the text token is divided into three parts, more than three tokens are generated because link-open and link-close are generated; at the same time, it is also possible to accomplish this by resetting rules (displaments), for example Replacing with + -and simultaneously hiding the object characters contained in link; further, the printing process of the quotation can be completed by smart quotation rules (smartquates).
And processing the original document and the updated document according to the analysis flow, so that a first Token stream corresponding to the original document and a second Token stream corresponding to the updated document can be obtained. It should be noted that not all documents contain links, quotations, etc., but the documents necessarily contain block structures and inline structures, so that block parsing and inline parsing are key parts for acquiring the first Token stream and the second Token stream.
In step S330, a first marker information sequence and a second marker information sequence are acquired according to the first marker information stream and the second marker information stream, and a minimum editing script is determined according to the first marker information sequence and the second marker information sequence, wherein the minimum editing script includes at least one of insert information and delete information required for converting the first marker information sequence into the second marker information sequence.
In one embodiment of the present application, since the original document and the updated document generally have a plurality of lines, and accordingly, the Token stream also includes a plurality of tokens, and the Token stream is circulated in the form of an array as an intermediate product, in order to conveniently and accurately obtain the difference information between the Token streams corresponding to the original document and the updated document, the first Token stream and the second Token stream may be respectively grouped according to a preset rule after the first Token stream and the second Token stream are obtained, so as to obtain the first Token sequence and the second Token sequence, and then the difference information between the first Token sequence and the second Token sequence is obtained by comparing the first Token sequence and the second Token sequence. The preset rule may specifically be grouping according to the outermost elements in the first Token stream and the second Token stream, or dividing the first Token stream and the second Token stream into multiple groups according to a fixed number of Token, or grouping the first Token stream and the second Token stream according to a fixed number of groups, or any other grouping rule. After the grouping is finished, a first Token sequence and a second Token sequence may be generated according to the information in each group.
For example, fig. 6 shows an interface schematic diagram of grouping a Token stream according to the outermost layer element in the Token stream, as shown in fig. 6, the Token stream includes four outermost layer elements A, B, C, D, where the outermost layer element A, C corresponds to two block structures, the outermost layer element B, D corresponds to two inline structures, an A1 sub-element and an A2 sub-element are further provided corresponding to the outermost layer element a, a C1 sub-element and a C2 sub-element are further provided corresponding to the outermost layer element C, the Token stream may be divided into four groups according to the outermost layer element A, B, C, D, and a Token sequence [ a, B, C, D ] corresponding to the Token stream may be obtained according to the outermost layer element included in each group. Since the MD document is a structured text, the outermost elements in the document can be conveniently acquired and grouped according to the outermost elements.
As described above, the first Token stream and the second Token stream may also be grouped according to a fixed number of tokens and a fixed number of groups to obtain a first Token sequence and a second Token sequence. For example, 50 Token may be included in each group, then the first Token stream and the second Token stream may be grouped in units of 50, and the first Token sequence and the second Token sequence may be generated from the information in each group after the grouping. For example, the first Token stream and the second Token stream may be divided into 15 groups, and then the number of tokens included in the Token stream may be divided into 15 groups, so that the first Token sequence and the second Token sequence may be generated according to information included in each group.
In one embodiment of the present application, after the first Token sequence and the second Token sequence are acquired, the first Token sequence and the second Token sequence may be aligned to acquire difference information therebetween, and compiling and rendering may be performed according to the difference information to obtain HTML web text corresponding to the updated text. The alignment methods adopted in the related art are all to perform alignment on elements in the sequence one by one from top to bottom, but such alignment may cause poor accuracy of the difference information. For example, when an element is inserted, it may cause all the elements to be mistaken for the difference information, and the elements to be compiled and rendered. Fig. 7 shows a flowchart of comparing a first Token sequence with a second Token sequence to obtain difference information, as shown in fig. 7, wherein the first Token sequence is [ a, B, C, D ], a new element Y is inserted between A, B to obtain a second Token sequence [ a, Y, B, C, D ], and when comparing, the difference information obtained by comparing from top to bottom is [ Y, B, C, D ], and further compiling and rendering are performed according to the difference information. However, it can be seen that the difference between the second Token sequence and the first Token sequence is only that the element Y is inserted between the elements a and B, so that only Y needs to be acquired for compiling and rendering, so that the efficiency of data processing can be improved, the rendering efficiency can be improved, and the preview efficiency can be further improved.
In one embodiment of the present application, in order to obtain the difference information conveniently and quickly, an O (ND) string difference algorithm may be used to process the first Token sequence and the second Token sequence. Specifically, an edit graph can be constructed according to the first Token sequence and the second Token sequence, a minimum edit path is obtained by performing route planning in the edit graph, and then a minimum edit script is determined according to the minimum edit path, wherein the minimum edit script is the difference information between the first Token sequence and the second Token sequence.
In constructing the edit graph, the elements in the first Token sequence may be taken as the abscissa, the elements in the second Token sequence may be taken as the ordinate, and all the elements may be connected by the horizontal and vertical sides, that is, the edit graph is essentially a two-dimensional grid graph. Fig. 8 shows an interface schematic diagram of an edit graph, as shown in fig. 8, in which Token sequence T1 corresponding to the horizontal axis is [ a, B, C, a, B, a ], token sequence T2 corresponding to the vertical axis is [ C, B, a, C ], and by connecting the elements, a two-dimensional grid graph, that is, the edit graph, can be obtained.
After the edit graph is generated, a pairing point can be determined in the edit graph according to the elements in the first Token sequence and the elements in the second Token sequence, and a minimum edit script is determined based on the pairing point. Continuing with the edit graph of FIG. 8 as an example, T1[ A, B, C, A, B, B, A ]Sequentially from the first bit element with T2[ C, B, A, B, A, C]The elements in the matching table can be obtained to be respectively C, A, B, A, the coordinates of the matching points corresponding to the matching elements in the editing diagram are respectively (3, 1), (4, 3), (5, 4), (7, 5), and trace (3, 1) (4, 3) (5, 4) (7, 5), namely x, of the matching points can be obtained according to the sequence of the matching points i <x( i+1 ) And y is i <y( i+1 ). In the edit graph, the path where the minimum edit path is located is necessarily a path passing through the matching point, so when determining the minimum edit path, adjacent nodes in the edit graph can be connected along the direction from the start point (0, 0) to the end point (N, M) of the edit graph to generate a path containing the matching point, and then the minimum edit path is determined according to the path, wherein N is the length of the first Token sequence, and M is the length of the second Token sequence.
In one embodiment of the present application, a plurality of paths may be generated from a start point to an end point in the edit graph, and the finally generated paths including the matched points may include a first sub-path and/or a second sub-path, and a third sub-path, wherein the first sub-path is a path along a horizontal direction, the horizontal direction represents deletion information, the second sub-path is a path along a vertical direction, the vertical direction represents addition information, the third sub-path is a direction along a hypotenuse at an angle of 45 ° with respect to the horizontal direction and the vertical direction, and the hypotenuse direction represents the same information. Further, since the edit script between the first Token sequence and the second Token sequence is a set of insert and delete operations that convert the first Token sequence into the second Token sequence, the minimum edit path is generated by the first sub-path and/or the second sub-path in the path that includes all the matching points. Continuing with the editing diagram shown in fig. 8, in which the path with the thickened black is a path including all the matching points, the first sub-path including the horizontal direction has L1, L2 and L7, the second sub-path including the vertical direction has L4 and L9, the third sub-path including the oblique direction has L3, L5-L6 and L8, it may be determined that the minimum editing path is a path formed by L1, L2, L4, L7 and L9, and the corresponding element is processed accordingly according to the direction of each sub-path, so that the minimum editing script may be obtained, specifically, the first element A, L2 in L1 corresponds to the first element B, L in T1 corresponds to the sixth element B in T1, then deletion operation needs to be performed on the first element a, the second element B and the sixth element B in T1, the element B, L in L4 corresponds to the element C in T2, then B needs to be added after the third element C in T1, and the seventh element C in T1 can be obtained after the seventh element a 2 is added. In the embodiment of the present application, x in the first Token sequence is deleted in "xD", and B1, B2, … Bt "is inserted after x in the first Token sequence, wherein deletion operation and insertion operation are performed simultaneously, and then the minimum editing path L1-L2-L4-L7-L9 determined according to fig. 8 can be obtained as {1d2d 3ib 6d 7ic } as the minimum editing script.
By processing the first Token sequence and the second Token sequence by the method, a minimum editing script for converting the first Token sequence into the second Token sequence can be obtained.
In step S340, partial compiling is performed in the original code corresponding to the original document according to the minimum editing script, so as to obtain the partial compiling code corresponding to the updated document.
In one embodiment of the present application, the minimum editing script is a set of insert and delete operations performed by converting the first Token sequence into the second Token sequence, that is, the minimum editing script may include insert information and delete information at the same time, or may include only insert information or may include delete information, and in an embodiment of the present application, the insert information includes an insert object and an insert identifier, and the delete information includes a delete object and a delete identifier. The insert object and the delete object may be any type of object used to form a document, such as a character, an image, a URL, and so on.
When the minimum editing script only comprises the insertion information or the deletion information required by converting the first Token sequence into the second Token sequence, the first target code can be determined in the original code according to the insertion identifier; inserting codes corresponding to the inserted objects after the first target codes; or determining a second target code in the original code according to the deletion identifier; and deleting the code corresponding to the deletion object in the second target code.
When the minimum editing script comprises the insertion information and the deletion information required for converting the first Token sequence into the second Token sequence, determining a third target code in the original code according to the insertion identifier; then inserting codes corresponding to the inserted objects after the third target codes; and determining a fourth target code in the original code according to the deletion identifier; and deleting the code corresponding to the deletion object in the fourth object code.
Continuing with the example of the minimum editing script {1d 2d 3ib 6d 7ic } obtained from the editing diagram shown in fig. 8, the minimum editing script contains both insertion information and deletion information, wherein the insertion information includes: the insert object B, C inserts the third and seventh bit elements identified as T1, and the delete information includes: the delete object A, B, B deletes the first, second and sixth bit elements identified as T1.
Next, taking the first Token sequence and the second Token sequence shown in fig. 7 as an example, a method of obtaining a minimum editing script and performing partial compiling on an original code corresponding to an original document according to the minimum editing script in the embodiment of the present application will be described.
Fig. 9 shows an interface schematic diagram for obtaining a minimum editing path, as shown in fig. 9, the first Token sequence [ a, B, C, D ] is taken as a horizontal axis, the second Token sequence [ a, Y, B, C, D ] is taken as a vertical axis, first, a matable element A, B, C, D in the first Token sequence and the second Token sequence can be determined, coordinates of corresponding matching points in the editing graph are (1, 1), (2, 3), (3, 4), (4, 5), by traversing each node in the editing graph, a path including the matching points can be obtained, a sub path along the horizontal direction does not exist in the path, a sub path along the vertical direction exists, the first element a in the first Token sequence is pointed by (1, 1), a new element Y is inserted after the first element a is described, and then the minimum editing script can be determined as 1IY. The code corresponding to the minimum editing script is as follows:
Then, the original code corresponding to the original document is updated according to the minimum editing script, and the compiled code corresponding to the updated document can be obtained. Continuing with the example of the minimum editing script obtained according to fig. 9, by updating the original code corresponding to the original document according to the minimum editing script, the obtained compiled code is as follows:
in one embodiment of the present application, after the compiling code formed by the partial compiling is acquired, rendering may be performed according to the compiling code to generate an HTML web document corresponding to the updated document, and document information corresponding to the compiling code is contained in the HTML web document. When in rendering, a rendering interface can be called, a target rendering rule corresponding to the Token type of the compiled code is obtained through the rendering interface, and rendering is performed according to the target rendering rule and the compiled code.
The determining the target rendering rule corresponding to the Token type of the compiled code is implemented by a renderer, which is shown as a renderer 403 in fig. 4, and the renderer determines the Token type corresponding to the compiled code, matches the Token type with each rendering rule in the rendering rule base after obtaining the Token type Token, takes the rendering rule as the target rendering rule if the corresponding rendering rule exists, and invokes a default rendering function to render as the target rendering rule if the corresponding rendering rule does not exist. The Markdown-it provides some rendering rules corresponding to the common Token types, and when some special rendering effects are needed, the rendering rules can be rewritten, further, plug-ins can be customized, customized analysis rules and rendering rules can be realized, the Markdown-it capability is expanded, and the preview quality is further improved.
In one embodiment of the present application, since the technical solution of the present application compiles and renders only the inserted, deleted and replaced contents in the original document, both the compiling efficiency and the rendering efficiency are much higher than those of the related art. Table 1 shows the time taken to compile and render a component MD document of about 6000 lines using the document compilation method of the present application and the time taken to compile and render the entire document of the MD document in the related art, as shown in Table 1:
table 1 time consuming look-up table for compilation and rendering
Markdown-it parsing Component compilation Component rendering Total time consumption Speed elevation
Before optimization 40ms 1007ms 605ms 1652ms /
After optimization (Block) 34ms 281ms 196ms 511ms 69%
After optimization (inline) 33ms 10ms 6ms 49ms 97%
As can be seen from Table 1, when the block structure and the inline structure are used as two important structures in the Token stream, and the technical scheme of the application is adopted to analyze, compile and render the block structure and the inline structure, the time consumed is much shorter than the time consumed when the technical scheme of the application is not adopted to analyze, compile and render the block structure and the inline structure, the optimization speed of block optimization is improved by 69% relative to the optimization speed in the related art, the optimization speed of inline optimization is improved by 97% relative to the optimization speed in the related art, and the improvement of the optimization speed means that a document editor can preview the input information in a preview area while editing based on the Markdown grammar, so that the speed and quality of real-time compiling and previewing of the document are improved.
Fig. 10 shows an interface schematic diagram of editing and modifying text using Markdown grammar and synchronously previewing, as shown in fig. 10, in the editing process, a document editor wants to add a text segment between a first segment and a second segment, the document editor has input "rules and authentication modes related to interface when API is accessed" in an editing area, and simultaneously "rules and authentication modes related to interface when API is accessed" are synchronously displayed in a preview area, because Markdown text is compiled and rendered according to updated content in a document when compiling and rendering is performed, time consumption is short, and therefore information displayed in the preview area and information in the editing area are basically synchronously displayed.
According to the document compiling method, after a first mark information stream corresponding to an original document and a second mark information stream corresponding to an updated document are obtained through analyzing the original document and the updated document contained in a document compiling request, a first mark information sequence and a second mark information sequence are obtained according to the first mark information stream and the second mark information stream, a minimum editing script is determined according to the first mark information sequence and the second mark information sequence, and finally partial compiling is carried out in an original code corresponding to the original document according to the minimum editing script, so that a compiling code corresponding to the updated document is obtained. On the one hand, the method can determine the minimum editing script corresponding to the updated content by comparing the first mark information sequence with the second mark information sequence, and only needs to compile and render according to the minimum editing script when compiling and rendering, so that the efficiency of compiling and rendering is improved, and the time consumption is reduced; on the other hand, when the original document content is longer, only the updated content is compiled and rendered, but not the whole document is compiled and rendered, so that page clamping phenomenon can not occur, and the editing experience of a document editor is improved.
It should be noted that although the steps of the methods of the present application are depicted in the accompanying drawings in a particular order, this does not require or imply that the steps must be performed in that particular order, or that all illustrated steps be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
The following describes an embodiment of the apparatus of the present application, which can be used to perform the document compiling method in the above embodiment of the present application. Fig. 11 schematically shows a block diagram of a document compiling apparatus according to an embodiment of the application. As shown in fig. 11, the document compiling apparatus 1100 includes: response module 1110, parsing module 1120, comparison module 1130, and compiling module 1140, specifically:
a response module 1110, configured to respond to a document compilation request, where the document compilation request includes an original document and an updated document; a parsing module 1120, configured to parse the original document and the updated document to obtain a first markup information stream corresponding to the original document and a second markup information stream corresponding to the updated document; a comparison module 1130, configured to obtain a first tag information sequence and a second tag information sequence according to the first tag information stream and the second tag information stream, and determine a minimum editing script according to the first tag information sequence and the second tag information sequence, where the minimum editing script includes at least one of insert information and delete information required for converting the first tag information sequence into the second tag information sequence; and the compiling module 1140 is configured to compile in the original code corresponding to the original document according to the minimum editing script, so as to obtain a compiled code corresponding to the updated document.
In some embodiments of the present application, based on the above technical solutions, the parsing module 1120 includes: an obtaining unit, configured to obtain a first block structure and a first inline structure in the original document, and obtain a second block structure and a second inline structure in the updated document at the same time; the analysis unit is used for analyzing the first block structure and the second block structure through a block analysis rule chain in the analysis rule set to acquire marking information corresponding to the first block structure and the second block structure, and analyzing the first inline structure and the second inline structure through an inline analysis rule chain in the analysis rule set to acquire marking information corresponding to the first inline structure and the second inline structure; and the mark information stream generating unit is used for generating the first mark information stream according to the mark information corresponding to the first block structure and the mark information corresponding to the first inline structure, and generating the second mark information stream according to the mark information corresponding to the second block structure and the mark information corresponding to the second inline structure.
In some embodiments of the present application, based on the above technical solution, the acquiring unit is configured to: unifying line-feed symbols in the original document and the updated document by adopting unification rules in the analysis rule set; and processing the original document and the updated document by adopting the mark recognition rules in the analysis rule set to acquire the first block structure, the first inline structure, the second block structure and the second inline structure.
In some embodiments of the present application, based on the above technical solutions, the comparing module 1130 is configured to: and respectively grouping the first mark information stream and the second mark information stream according to a preset rule, and generating the first mark information sequence and the second mark information sequence according to the information in each group.
In some embodiments of the present application, based on the above technical solution, the preset rule includes any one of the following: the outermost elements in the first and second streams of marker information, a fixed number of groups.
In some embodiments of the present application, based on the above technical solutions, the comparing module 1130 includes: a diagram construction unit for constructing an edit diagram according to the first marker information sequence and the second marker information sequence; a pairing point determining unit, configured to determine a pairing point in the edit graph according to the element in the first marker information sequence and the element in the second marker information sequence; and the script determining unit is used for determining the minimum editing script according to the pairing point.
In some embodiments of the present application, based on the above technical solution, the script determining unit includes: a path generating unit, configured to connect adjacent nodes in the edit graph along a direction from a start point to an end point in the edit graph, so as to generate a path including the pairing point; and the script generation unit is used for determining a minimum editing path according to the path and generating the minimum editing script according to the minimum editing path.
In some embodiments of the present application, based on the above technical solution, the script generating unit is configured to: acquiring a first sub-path and/or a second sub-path in the path, and determining the minimum editing path according to the first sub-path and/or the second sub-path; the first sub-path is a path along the horizontal direction in the paths, and the second sub-path is a path along the vertical direction in the paths.
In some embodiments of the present application, the insertion information includes an insertion object and an insertion identifier, and the deletion information includes a deletion object and a deletion identifier; based on the above technical solution, the compiling module 1140 is configured to: when the minimum editing script includes insertion information or deletion information required to convert the first marker information sequence into the second marker information sequence; determining a first target code in the original code according to the insertion identifier; inserting a code corresponding to the insertion object after the first object code; or determining a second target code in the original code according to the deletion identifier; and deleting the code corresponding to the deleting object in the second target code.
In some embodiments of the present application, the insertion information includes an insertion object and an insertion identifier, and the deletion information includes a deletion object and a deletion identifier; based on the above technical solution, the compiling module 1140 is configured to: when the minimum editing script includes insertion information and deletion information required to convert the first marker information sequence into the second marker information sequence; determining a third target code in the original code according to the insertion identifier; inserting a code corresponding to the insertion object after the third object code; and determining a fourth target code in the original code according to the deletion identifier; and deleting the code corresponding to the deleting object in the fourth target code.
In some embodiments of the present application, based on the above technical solutions, the document compiling apparatus 1100 is further configured to: and after the compiled code is obtained, rendering is carried out according to the compiled code so as to display the HTML webpage document corresponding to the updated document in a display interface.
In some embodiments of the present application, based on the above technical solution, the rendering according to the compiled code is configured to: and calling a rendering interface, acquiring a target rendering rule according to the type of the compiled code, and rendering according to the target rendering rule and the compiled code.
Specific details of the document compiling apparatus provided in each embodiment of the present application have been described in the corresponding method embodiments, and are not described herein.
Fig. 12 schematically shows a block diagram of a computer system for implementing an electronic device, which may be the terminal device 101 and the server 103 as shown in fig. 1, according to an embodiment of the present application.
It should be noted that, the computer system 1200 of the electronic device shown in fig. 12 is only an example, and should not impose any limitation on the functions and the application scope of the embodiments of the present application.
As shown in fig. 12, the computer system 1200 includes a central processing unit 1201 (Central Processing Unit, CPU) which can perform various appropriate actions and processes according to a program stored in a Read-Only Memory 1202 (ROM) or a program loaded from a storage section 1208 into a random access Memory 1203 (Random Access Memory, RAM). In the random access memory 1203, various programs and data necessary for the system operation are also stored. The cpu 1201 and the ram 1202 are connected to each other via a bus 1204. An Input/Output interface 1205 (i.e., an I/O interface) is also connected to the bus 1204.
In some embodiments, the following components are connected to the input/output interface 1205: an input section 1206 including a keyboard, a mouse, and the like; an output portion 1207 including a Cathode Ray Tube (CRT), a liquid crystal display (Liquid Crystal Display, LCD), and a speaker, etc.; a storage section 1208 including a hard disk or the like; and a communication section 1209 including a network interface card such as a lan card, a modem, or the like. The communication section 1209 performs communication processing via a network such as the internet. The driver 1210 is also connected to the input/output interface 1205 as needed. A removable medium 1211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on the drive 1210 so that a computer program read out therefrom is installed into the storage section 1208 as needed.
In particular, the processes described in the various method flowcharts may be implemented as computer software programs according to embodiments of the application. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion 1209, and/or installed from the removable media 1211. The computer programs, when executed by the central processor 1201, perform the various functions defined in the system of the present application.
It should be noted that, the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable medium, or any combination of the two. The computer readable medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-Only Memory (ROM), an erasable programmable read-Only Memory (Erasable Programmable Read Only Memory, EPROM), flash Memory, an optical fiber, a portable compact disc read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may be any computer readable medium that is not a computer readable medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a mobile hard disk, etc.) or on a network, comprising several instructions for causing an electronic device to perform the method according to the embodiments of the present application.
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (15)

1. A document compiling method, comprising:
responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document;
analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document;
acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises at least one of insert information and delete information required for converting the first mark information sequence into the second mark information sequence;
and compiling in the original code corresponding to the original document according to the minimum editing script to obtain the compiling code corresponding to the updated document.
2. The method of claim 1, wherein the parsing the original document and the updated document to obtain a first stream of markup information corresponding to the original document and a second stream of markup information corresponding to the updated document comprises:
Acquiring a first block structure and a first inline structure in the original document, and acquiring a second block structure and a second inline structure in the updated document;
analyzing the first block structure and the second block structure through a block analysis rule chain in an analysis rule set to obtain marking information corresponding to the first block structure and the second block structure, and analyzing the first inline structure and the second inline structure through an inline analysis rule chain in the analysis rule set to obtain marking information corresponding to the first inline structure and the second inline structure;
generating the first mark information stream according to the mark information corresponding to the first block structure and the mark information corresponding to the first inline structure, and generating the second mark information stream according to the mark information corresponding to the second block structure and the mark information corresponding to the second inline structure.
3. The method of claim 2, wherein the obtaining the first block structure and the first inline structure in the original document while obtaining the second block structure and the second inline structure in the updated document comprises:
Unifying line-feed symbols in the original document and the updated document by adopting unification rules in the analysis rule set;
and processing the original document and the updated document by adopting the mark recognition rules in the analysis rule set to acquire the first block structure, the first inline structure, the second block structure and the second inline structure.
4. The method of claim 1, wherein the obtaining a first marker information sequence and a second marker information sequence from the first marker information stream and the second marker information stream comprises:
and respectively grouping the first mark information stream and the second mark information stream according to a preset rule, and generating the first mark information sequence and the second mark information sequence according to the information in each group.
5. The method of claim 4, wherein the preset rules comprise any one of: the outermost elements in the first and second streams of marker information, a fixed number of groups.
6. The method of claim 1, wherein said determining a minimum editing script from said first marker information sequence and said second marker information sequence comprises:
Constructing an editing diagram according to the first mark information sequence and the second mark information sequence;
determining a matching point in the editing diagram according to the elements in the first mark information sequence and the elements in the second mark information sequence;
and determining the minimum editing script according to the pairing point.
7. The method of claim 6, wherein said determining the minimum edit script from the pairing point comprises:
connecting adjacent nodes in the editing diagram along the direction from the starting point to the ending point of the editing diagram so as to generate a path containing the pairing point;
and determining a minimum editing path according to the path, and generating the small editing script according to the minimum editing path.
8. The method of claim 7, wherein said determining a minimum edit path from said path comprises:
acquiring a first sub-path and/or a second sub-path in the path, and determining the minimum editing path according to the first sub-path and/or the second sub-path;
the first sub-path is a path along the horizontal direction in the paths, and the second sub-path is a path along the vertical direction in the paths.
9. The method of claim 1, wherein the insertion information includes an insertion object and an insertion identification, and the deletion information includes a deletion object and a deletion identification;
when the minimum editing script includes insertion information or deletion information required to convert the first marker information sequence into the second marker information sequence;
the performing local compiling in the original code corresponding to the original document according to the minimum editing script comprises the following steps:
determining a first target code in the original code according to the insertion identifier;
inserting a code corresponding to the insertion object after the first object code; or alternatively
Determining a second target code in the original code according to the deletion identifier;
and deleting the code corresponding to the deleting object in the second target code.
10. The method of claim 1, wherein the insertion information includes an insertion object and an insertion identification, and the deletion information includes a deletion object and a deletion identification;
when the minimum editing script includes insertion information and deletion information required to convert the first marker information sequence into the second marker information sequence;
The performing local compiling in the original code corresponding to the original document according to the minimum editing script comprises the following steps:
determining a third target code in the original code according to the insertion identifier;
inserting a code corresponding to the insertion object after the third object code; and
determining a fourth target code in the original code according to the deletion identifier;
and deleting the code corresponding to the deleting object in the fourth target code.
11. The method according to claim 1, wherein the method further comprises:
and after the compiled code is obtained, rendering is carried out according to the compiled code so as to display the HTML webpage document corresponding to the updated document in a display interface.
12. The method of claim 11, wherein the rendering according to the compiled code comprises:
and calling a rendering interface, acquiring a target rendering rule according to the type of the marking information corresponding to the compiling code, and rendering according to the target rendering rule and the compiling code.
13. A document compiling apparatus, comprising:
the response module is used for responding to a document compiling request, wherein the document compiling request comprises an original document and an updated document;
The analysis module is used for analyzing the original document and the updated document to obtain a first mark information stream corresponding to the original document and a second mark information stream corresponding to the updated document;
the comparison module is used for acquiring a first mark information sequence and a second mark information sequence according to the first mark information stream and the second mark information stream, and determining a minimum editing script according to the first mark information sequence and the second mark information sequence, wherein the minimum editing script comprises insertion information and/or deletion information required by converting the first mark information sequence into the second mark information sequence;
and the compiling module is used for compiling in the original codes corresponding to the original document according to the minimum editing script so as to obtain the compiling codes corresponding to the updated document.
14. A computer readable medium having stored thereon a computer program which, when executed by a processor, implements the document compiling method of any one of claims 1 to 12.
15. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
Wherein the processor is configured to perform the document compilation method of any of claims 1 to 12 via execution of the executable instructions.
CN202210413701.2A 2022-04-15 2022-04-15 Document compiling method, device, computer readable medium and electronic equipment Pending CN116956823A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210413701.2A CN116956823A (en) 2022-04-15 2022-04-15 Document compiling method, device, computer readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210413701.2A CN116956823A (en) 2022-04-15 2022-04-15 Document compiling method, device, computer readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN116956823A true CN116956823A (en) 2023-10-27

Family

ID=88441457

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210413701.2A Pending CN116956823A (en) 2022-04-15 2022-04-15 Document compiling method, device, computer readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN116956823A (en)

Similar Documents

Publication Publication Date Title
CN109933752B (en) Method and device for exporting electronic document
KR20130066603A (en) Initiating font subsets
US20110167332A1 (en) System and Method for Generating Web Pages
CN106294493B (en) Method and device for realizing document format conversion
CN111427561A (en) Service code generation method and device, computer equipment and storage medium
CN113126990B (en) Page development method, device, equipment and storage medium
CN109799985B (en) Front-end code generation method and device, storage medium and electronic equipment
CN112100550A (en) Page construction method and device
CN111241793A (en) Method, system, and medium for parsing rich text editor content for native client rendering
CN110543298A (en) webpage style generation method and device and webpage generation method and device
CN113377653A (en) Method and device for generating test case
CN113495730A (en) Resource package generation and analysis method and device
CN115599386A (en) Code generation method, device, equipment and storage medium
CN115422066A (en) Test case management method and device
CN114139502A (en) Document content processing method, device, equipment and storage medium
US7802181B2 (en) Document processing device and document processing method
CN115268904A (en) User interface design file generation method, device, equipment and medium
CN116956823A (en) Document compiling method, device, computer readable medium and electronic equipment
US9594737B2 (en) Natural language-aided hypertext document authoring
CN108664511B (en) Method and device for acquiring webpage information
CN115640279A (en) Method and device for constructing data blood relationship
KR20200001342A (en) Web electric document editing apparatus for rendering object and operating method thereof
CN113886748A (en) Method, device and equipment for generating editing information and outputting information of webpage content
CN113656041A (en) Data processing method, device, equipment and storage medium
CN113971044A (en) Component document generation method, device, equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination