File processing method and device, computer equipment and storage medium
By automatically processing the file identification, title and picture path of Markdown files, the inefficiency of processing and content display problems caused by manual operations by insurance companies are solved, and efficient file extraction and processing are achieved.
Patent Information
- Application Number
- CN202411180603.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-13
AI Technical Summary
In the prior art, insurance companies need to manually operate when processing Markdown files in project databases, resulting in long processing time, low efficiency, and easy to cause file content to not be displayed normally.
By judging the file extraction request triggered by the user, obtain the file identity of the Markdown file, read the file content, extract the title and process the image path using regular expressions, replace the string, and finally send the processed content to the target server.
The automated Markdown file content extraction and processing is realized, which improves processing efficiency, ensures the accuracy and readability of the content, and avoids the problem that files cannot be displayed normally on the target server.
Smart Images

Figure CN119127804A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of big data technology and financial technology, and in particular to file processing methods, devices, computer equipment and storage media. Background Art
[0002] In the front-end development of the financial insurance field, many insurance companies will develop corresponding project databases. The project database can be a project library corresponding to financial data, which can include transaction data, payment data, business data, etc. There are usually some document files in the project database, and most of these document files are Markdown files.
[0003] At present, there are some tools for processing Markdown files in the industry, but these existing tools usually only provide some basic Markdown file operation functions, such as reading files, parsing Markdown syntax, etc. In the actual business processing flow, when it is necessary to extract the content of the Markdown files contained in the project database, the existing processing method is usually for the staff to complete the content extraction of the Markdown files contained in the project database manually. This processing method takes a lot of processing time, has a large workload, and has low processing efficiency. In addition, it is easy for the file content of the extracted Markdown files to not be displayed normally. Summary of the invention
[0004] The purpose of the embodiments of the present application is to propose a file processing method, apparatus, computer equipment and storage medium to solve the existing problem that when it is necessary to extract content from Markdown files contained in a project database, the existing processing method is usually to manually extract the content of the Markdown files contained in the project database by staff. This processing method requires a lot of processing time, a large workload, low processing efficiency, and is prone to technical problems such as the file content of the extracted Markdown files cannot be displayed normally.
[0005] In order to solve the above technical problems, the present application provides a file processing method, which adopts the following technical solution:
[0006] Determine whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file;
[0007] If so, extract the file identifier from the file extraction request, and obtain the target Markdown file corresponding to the file identifier based on a preset target development platform;
[0008] Read the file content of the target Markdown file;
[0009] Extracting title content from the file content based on a preset first regular expression;
[0010] Searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content;
[0011] Performing a target-format content replacement process on the first file content based on a preset string replacement strategy to obtain corresponding second file content;
[0012] The title content and the second file content are sent to a target server.
[0013] Furthermore, the step of acquiring the target Markdown file corresponding to the file identifier based on a preset target development platform specifically includes:
[0014] Get the specified directory corresponding to the Markdown file;
[0015] Calling the target development platform;
[0016] Read all Markdown files corresponding to the specified directory based on the target development platform;
[0017] Filter out a specified Markdown file corresponding to the file identifier from all the Markdown files;
[0018] The specified Markdown file is used as the target Markdown file.
[0019] Furthermore, the step of reading the file content of the target Markdown file specifically includes:
[0020] Call the preset read function;
[0021] The file content of the target Markdown file is asynchronously read based on the read function.
[0022] Furthermore, the step of extracting the title content from the file content based on the preset first regular expression specifically includes:
[0023] Using the first regular expression to search for a title part from the file content, to obtain a corresponding search result;
[0024] If the search result is a matching item corresponding to the title part found in the file content, extracting the title part from the file content;
[0025] Filtering useless information from the title part to obtain a filtered title part;
[0026] The filtered title part is used as the title content.
[0027] Furthermore, the step of searching for image content from the file content based on a preset second regular expression and performing path replacement processing on the image content to obtain the corresponding first file content specifically includes:
[0028] Using the second regular expression to search for image content from the file content;
[0029] Filtering out image links whose image reference paths are relative paths from the image content;
[0030] Replace the relative path in the image link with the absolute path to obtain the modified file content;
[0031] The modified file content is used as the first file content.
[0032] Furthermore, the step of performing content replacement processing on the first file content in a target format based on a preset string replacement strategy to obtain corresponding second file content specifically includes:
[0033] Finding a content block corresponding to the target format from the first file content;
[0034] Obtaining a target replacement tag corresponding to the content block;
[0035] Performing a replacement process on the content block based on the target replacement tag to obtain a replaced first file content;
[0036] The replaced first file content is used as the second file content.
[0037] Furthermore, the step of sending the title content and the second file content to the target server specifically includes:
[0038] Constructing file extraction content corresponding to the target Markdown file based on the title content and the second file content;
[0039] Call the preset processing interface library;
[0040] Obtaining a file processing interface from the processing interface library;
[0041] Obtaining communication address information of the target server;
[0042] Based on the communication address information, the file extraction content is sent to the target server using the file processing interface.
[0043] In order to solve the above technical problems, the embodiment of the present application further provides a file processing device, which adopts the following technical solution:
[0044] A judgment module, used to judge whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file;
[0045] an acquisition module, configured to extract the file identifier from the file extraction request, and acquire the target Markdown file corresponding to the file identifier based on a preset target development platform;
[0046] A reading module, used to read the file content of the target Markdown file;
[0047] An extraction module, used for extracting the title content from the file content based on a preset first regular expression;
[0048] A first processing module, used for searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content;
[0049] A second processing module, configured to perform content replacement processing on the first file content in a target format based on a preset string replacement strategy to obtain corresponding second file content;
[0050] A sending module is used to send the title content and the second file content to a target server.
[0051] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0052] Determine whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file;
[0053] If so, extract the file identifier from the file extraction request, and obtain the target Markdown file corresponding to the file identifier based on a preset target development platform;
[0054] Read the file content of the target Markdown file;
[0055] Extracting title content from the file content based on a preset first regular expression;
[0056] Searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content;
[0057] Performing a target-format content replacement process on the first file content based on a preset string replacement strategy to obtain corresponding second file content;
[0058] The title content and the second file content are sent to a target server.
[0059] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0060] Determine whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file;
[0061] If so, extract the file identifier from the file extraction request, and obtain the target Markdown file corresponding to the file identifier based on a preset target development platform;
[0062] Read the file content of the target Markdown file;
[0063] Extracting title content from the file content based on a preset first regular expression;
[0064] Searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content;
[0065] Performing a target-format content replacement process on the first file content based on a preset string replacement strategy to obtain corresponding second file content;
[0066] The title content and the second file content are sent to a target server.
[0067] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0068] The present application first determines whether a file extraction request triggered by a user is received; wherein the file extraction request carries the file identifier of the target Markdown file; if so, the file identifier is extracted from the file extraction request, and the target Markdown file corresponding to the file identifier is obtained based on the preset target development platform; then the file content of the target Markdown file is read; then the title content is extracted from the file content based on the preset first regular expression; subsequently, the image content is searched from the file content based on the preset second regular expression, and the path replacement processing is performed on the image content to obtain the corresponding first file content; further, the content of the first file content is replaced with the target format based on the preset string replacement strategy to obtain the corresponding second file content; finally, the title content and the second file content are sent to the target server. After receiving a file extraction request triggered by a user, the present application will obtain the target Markdown file corresponding to the file identifier carried in the file extraction request based on the use of the target development platform, and read the file content of the target Markdown file. Furthermore, based on the use of the first regular expression, the title content of the target Markdown file can be quickly and accurately extracted, ensuring the accuracy and consistency of the title content. And based on the second regular expression, the image content is searched from the file content, and the path replacement processing is performed on the image content to obtain the corresponding first file content, which can effectively avoid the problem that the image of the first file content cannot be displayed normally after uploading, and ensure that the first file content can be displayed normally on the target server after migration. The target format content replacement processing of the first file content based on the string replacement strategy is then performed to obtain the second file content, which effectively solves the defect that the target format content in the first file content may not be recognized and displayed. Finally, the title content and the second file content are sent to the target server, and the content extraction and sending processing of the target Markdown file are automatically and intelligently completed, which effectively reduces the processing time of content extraction and reduces the workload of content extraction processing, thereby improving the processing efficiency and processing intelligence of content extraction. In addition, sending the content data processed by the regular expression and string replacement strategy to the target server can effectively avoid the situation that the extracted content data cannot be displayed normally in the target server, thereby improving the readability and availability of the content data of the target Markdown file. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0070] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0071] Figure 2 A flowchart of an embodiment of a file processing method according to the present application;
[0072] Figure 3 is a schematic structural diagram of an embodiment of a file processing device according to the present application;
[0073] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0074] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0075] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0076] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0077] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0078] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0079] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0080] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .
[0081] It should be noted that the file processing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the file processing device is generally arranged in the server / terminal device.
[0082] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0083] Continue to refer Figure 2 , shows a flowchart of an embodiment of the file processing method according to the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. The file processing method provided in the embodiment of the present application can be applied to any scenario where file processing is required, and the file processing method can be applied to products in these scenarios, for example, file processing for project databases in the financial insurance field. The file processing method comprises the following steps:
[0084] Step S201, determining whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file.
[0085] In this embodiment, the electronic device (eg, Figure 1 The server / terminal device shown in the figure) can obtain the file extraction request through a wired connection or a wireless connection. It should be noted that the above-mentioned wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future. In the financial field, many financial businesses will develop corresponding project databases. The project database may be a project library corresponding to financial data. The financial data may include transaction data, payment data, business data, and so on. There are usually some document files in the project database, and most of these document files are Markdown files. The above-mentioned user may be an employee of a financial company. The above-mentioned file extraction request may be a processing request triggered by the user for extracting the file content of the target Markdown file from the project database. The file identifier of the above-mentioned target Markdown file refers to the target file name of the target Markdown file. And the file name of each Markdown file in the project database is unique.
[0086] Step S202: If yes, extract the file identifier from the file extraction request, and obtain the target Markdown file corresponding to the file identifier based on a preset target development platform.
[0087] In this embodiment, the file identifier can be extracted from the file extraction request by parsing the file extraction request. The specific implementation process of obtaining the target Markdown file corresponding to the file identifier based on the preset target development platform will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated on here.
[0088] Step S203, reading the file content of the target Markdown file.
[0089] In this embodiment, the specific implementation process of reading the file content of the target Markdown file will be further described in detail in subsequent specific embodiments of the present application, and will not be elaborated on here.
[0090] Step S204: extracting the title content from the file content based on a preset first regular expression.
[0091] In this embodiment, the specific implementation process of extracting the title content from the file content based on the preset first regular expression will be further described in detail in subsequent specific embodiments of the present application, and will not be elaborated on here.
[0092] Step S205: searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content.
[0093] In this embodiment, the specific implementation process of searching for image content from the file content based on the preset second regular expression and performing path replacement processing on the image content to obtain the corresponding first file content will be described in further detail in subsequent specific embodiments of the present application and will not be elaborated on here.
[0094] Step S206: performing content replacement processing of the first file content in a target format based on a preset string replacement strategy to obtain corresponding second file content.
[0095] In this embodiment, the above-mentioned specific implementation process of replacing the content of the first file in the target format based on the preset string replacement strategy to obtain the corresponding second file content will be further described in detail in the subsequent specific embodiments of this application and will not be elaborated here.
[0096] Step S207: sending the title content and the second file content to a target server.
[0097] In this embodiment, the specific implementation process of sending the title content and the second file content to the target server will be described in further detail in subsequent specific embodiments of the present application, and will not be elaborated on here.
[0098] After receiving the file extraction request triggered by the user, the present application will obtain the target Markdown file corresponding to the file identifier carried in the file extraction request based on the use of the target development platform, and read the file content of the target Markdown file. Then, based on the use of the first regular expression, the title content of the target Markdown file can be quickly and accurately extracted, ensuring the accuracy and consistency of the title content. And based on the second regular expression, the image content is searched from the file content, and the path replacement processing of the image content is performed to obtain the corresponding first file content, which can effectively avoid the problem that the image content of the first file content cannot be displayed normally after uploading, and ensure that the first file content can be displayed normally on the target server after migration. Subsequently, the first file content is replaced with the target format content based on the string replacement strategy to obtain the second file content, which effectively solves the defect that the target format content in the first file content may not be recognized and displayed. Finally, the title content and the second file content are sent to the target server, realizing the automatic and intelligent completion of the content extraction and sending processing of the target Markdown file, effectively reducing the processing time of content extraction, reducing the workload of content extraction processing, and thus improving the processing efficiency and processing intelligence of content extraction. In addition, sending the content data processed by regular expressions and string replacement strategies to the target server can effectively avoid the situation where the extracted content data cannot be displayed normally in the target server, thereby improving the readability and usability of the content data of the target Markdown file.
[0099] In some optional implementations, the step of acquiring the target Markdown file corresponding to the file identifier based on a preset target development platform in step S202 includes the following steps:
[0100] Get the specified directory corresponding to the Markdown file.
[0101] In this embodiment, in the financial field, many financial businesses will develop corresponding project databases. The project database can be a project library corresponding to financial data. Financial data may include transaction data, payment data, business data, etc. There are usually some document files in the project database, and most of these document files are Markdown files. And the Markdown files will be pre-stored in a specified directory, that is, the specified directory stores document files containing Markdown files. Of course, the document files stored in the specified directory documents can be other formats in addition to Markdown files.
[0102] The target development platform is called.
[0103] In this embodiment, the target development platform may specifically adopt the Node.js development platform. Node.js, referred to as Node, is a development platform that can run JavaScript on the server side. JavaScript is a Web front-end language, and Node.js makes JavaScript a server-side scripting language.
[0104] All Markdown files corresponding to the specified directory are read based on the target development platform.
[0105] In this embodiment, the directory path corresponding to the above-mentioned specified directory can be obtained first, and then the fs.readdir method is used to asynchronously read all the files and file names in the specified directory corresponding to the directory path through the fs file system module in the target development platform. After the reading is completed, for each file in the specified directory, a for loop is used to filter out the specified file with the extension .md (indicating a Markdown file) from all files, and the specified file is used as all the Markdown files corresponding to the above-mentioned specified directory.
[0106] A designated Markdown file corresponding to the file identifier is filtered out from all the Markdown files.
[0107] In this embodiment, the above-mentioned file identifier refers to the target file name of the target Markdown file. The file names of all the Markdown files can be obtained, and then the specified file name matching the above-mentioned target file name can be filtered out from all the file names, and then the file matching the specified file name can be filtered out from all the Markdown files and used as the above-mentioned specified Markdown file.
[0108] The specified Markdown file is used as the target Markdown file.
[0109] This application obtains a designated directory corresponding to a Markdown file; then calls the target development platform; then reads all Markdown files corresponding to the designated directory based on the target development platform; subsequently, selects a designated Markdown file corresponding to the file identifier from all the Markdown files, and uses the designated Markdown file as the target Markdown file. This application performs file reading processing on the designated directory based on the use of the target development platform, and can quickly and accurately find the target Markdown file corresponding to the file identifier, effectively improving the file acquisition efficiency of the target Markdown file.
[0110] In some optional implementations of this embodiment, step S203 includes the following steps:
[0111] Call the preset read function.
[0112] In this embodiment, the above reading function specifically adopts the processMarkdownFile function.
[0113] The file content of the target Markdown file is asynchronously read based on the read function.
[0114] In this embodiment, the processMarkdownFile function is called and the corresponding fs.readFile method is used to asynchronously read out the entire content of the target Markdown file, that is, the above-mentioned file content. In addition, if an error occurs during the reading process, an exception will be thrown.
[0115] This application calls a preset read function; then asynchronously reads the file content of the target Markdown file based on the read function. This application can quickly and accurately read the file content of the target Markdown file by using the read function, effectively improving the reading efficiency of the file content of the target Markdown file and ensuring the data accuracy of the obtained file content.
[0116] In some optional implementations, step S204 includes the following steps:
[0117] The first regular expression is used to search the title part from the file content to obtain corresponding search results.
[0118] In this embodiment, the first regular expression specifically adopts / ---\ntitle:([\s\S]+?)\n[\s\S]*? --- / g. The search result includes searching for a matching item corresponding to the title part in the file content, or not searching for a matching item corresponding to the title part in the file content.
[0119] If the search result is a matching item corresponding to the title part found in the file content, the title part is extracted from the file content.
[0120] In this embodiment, if a matching item corresponding to the title part is searched in the file content, it indicates that the title part exists in the file content, and the title part will be extracted from the file content.
[0121] Useless information is filtered out of the title part to obtain a filtered title part.
[0122] In this embodiment, the useless information includes blank characters before and after the title part, order (instruction information), description (description information), and sorting information in the line below the title part.
[0123] The filtered title part is used as the title content.
[0124] In this embodiment, by using the title part that has been filtered for useless information as the title content, the accuracy of the title content can be ensured.
[0125] The present application searches for the title part from the file content by using the first regular expression to obtain a corresponding search result; if the search result is a match corresponding to the title part searched in the file content, the title part is extracted from the file content; then useless information is filtered out of the title part to obtain a filtered title part; and the filtered title part is subsequently used as the title content. The present application can extract the title part from the file content based on the use of the first regular expression, and then useless information is filtered out of the title part and the filtered title part is used as the title content, so as to realize fast and accurate extraction of the title content of the target Markdown file and ensure the accuracy and consistency of the title content.
[0126] In some optional implementations, step S205 includes the following steps:
[0127] The second regular expression is used to search for image content from the file content.
[0128] In this embodiment, the second regular expression may be specifically / \]\(\.\.\ / assets\ / ([\s\S]+?\.png)\) / g. The ([\s\S]+?\.png) portion in the second regular expression is used to capture the path portion of the image file name, including the file name and the .png extension. [\s\S]+? is a non-greedy match that matches as many arbitrary characters as possible (including line breaks) until .png is encountered. By using the second regular expression, the content in the .png format may be first found from the file content and used as the image content.
[0129] Filter out image links whose image reference paths are relative paths from the image content.
[0130] In this embodiment, by using the second regular expression, image links whose image reference paths are relative paths can be further filtered out from the image content.
[0131] The relative path in the image link is replaced with an absolute path to obtain the modified file content.
[0132] In this embodiment, the absolute path is constructed by using the second regular expression, and then the relative path in the image link is replaced with the absolute path, thereby obtaining the modified file content.
[0133] The modified file content is used as the first file content.
[0134] In this embodiment, by using the modified file content obtained after the path replacement process as the first file content, the problem that the image cannot be displayed after uploading the first file content can be effectively avoided.
[0135] This application searches for image content from the file content by using the second regular expression; then filters out image links whose image reference paths are relative paths from the image content; then replaces the relative paths in the image links with absolute paths to obtain modified file content; and subsequently uses the modified file content as the first file content. This application can filter out image links whose image reference paths are relative paths from the file content by using the second regular expression, and then replace the relative paths in the image links with absolute paths to obtain modified file content as the first file content. This can achieve fast and accurate execution of path replacement processing for the image content, ensure the accuracy of the obtained first file content, and effectively avoid the problem that the image in the first file content cannot be displayed normally after uploading, ensuring that the first file content can be displayed normally on the target server after migration.
[0136] In some optional implementations of this embodiment, step S206 includes the following steps:
[0137] A content block corresponding to the target format is searched from the first file content.
[0138] In this embodiment, the content blocks corresponding to the target format may specifically include :::tips, :::warning and :::caution. These content blocks belong to Markdown syntax extensions, which are usually called "tips blocks", "warning blocks" and "caution blocks". These syntax extensions are used to highlight specific types of information in Markdown files to attract the reader's attention. They are used as a structured way to highlight and emphasize the importance of specific content or related information. Generally, the usage of these syntax extensions is as follows:
[0139] *:::tips: Used to give tips and share useful suggestions, tricks or hints.
[0140] *:::warning: Used to alert and remind readers of potential risks, problems or precautions.
[0141] *:::caution: Used to emphasize matters or warnings that require special caution or attention.
[0142] In Markdown files, these syntax extensions are usually recognized by the parser or renderer and styled or rendered in different ways so that they are displayed prominently in the final output. However, these syntax extensions are not standard Markdown syntax, but extended functions implemented by different Markdown parsers or renderers. Therefore, when using these syntax extensions, if the target platform does not support them, they will not be displayed in ordinary markdown files. Therefore, replacement or conversion is required so that they can be presented in ordinary HTML or other markup languages in ordinary Markdown files.
[0143] Get the target replacement tag corresponding to the content block.
[0144] In this embodiment, the target replacement tag can be in the form of HTML The tag format. Specifically, the replacement tag of the :::tips content block is recommend ;:::warning content block replacement tag is warn , the replacement tag of the :::caution content block is Enforcement .
[0145] The content block is replaced based on the target replacement tag to obtain the replaced first file content.
[0146] In this example, by replacing the content of the :::tips content block with recommend , to display the recommended information. By replacing the contents of the :::warning content block with warn , to display a warning message. And by replacing the contents of the :::caution content block with Enforcement , to display mandatory information, so that you can easily display content in a specific format in the Markdown file, thereby improving the readability and usability of the Markdown file.
[0147] The replaced first file content is used as the second file content.
[0148] The present application searches out a content block corresponding to the target format from the first file content; then obtains a target replacement tag corresponding to the content block; then replaces the content block based on the target replacement tag to obtain the replaced first file content; and then uses the replaced first file content as the second file content. The present application searches out a content block corresponding to the target format from the first file content, and then uses the target replacement tag corresponding to the content block to replace the content block to obtain the replaced first file content as the second file content. The present application effectively solves the defect that the content block cannot be recognized and displayed by replacing the content block corresponding to the target format with a recognizable HTML tag. This makes it easy to successfully display content in a specific format in the second file content on the target server, thereby improving the readability and usability of the second file content.
[0149] In some optional implementations of this embodiment, step S207 includes the following steps:
[0150] A file extraction content corresponding to the target Markdown file is constructed based on the title content and the second file content.
[0151] In this embodiment, the title content and the second file content can be filled into a preset content template to construct the file extraction content corresponding to the target Markdown file. The above-mentioned content template is a pre-constructed template file suitable for file extraction processing of Markdown files, and the content template includes a title field and a file content field. The above-mentioned file extraction content is obtained by filling the title content into the title filling area corresponding to the title field in the content template, and filling the second file content into the content filling area corresponding to the file content field in the content template.
[0152] Call the preset processing interface library.
[0153] In this embodiment, for different data processing types, one-to-one corresponding interfaces adapted to various data processing types will be constructed in advance, and after the interface construction is completed, all interfaces will be stored in a database to generate a corresponding processing interface library. Among them, the above data processing types can be set according to actual processing requirements, for example, they may include file processing types, image processing types, video processing types, audio processing types, etc. Correspondingly, the interfaces in the interface library may include at least a file processing interface, an image processing interface, a video processing interface, and an audio processing interface.
[0154] Obtain a file processing interface from the processing interface library.
[0155] In this embodiment, the target data processing type of the content extracted from the above-mentioned file can be obtained, and then the specified data processing type matching the target data processing type can be queried from the processing interface library, and then the specified interface corresponding to the specified data processing type can be extracted from the processing interface library, and the specified interface can be used as the above-mentioned file processing interface.
[0156] Obtain the communication address information of the target server.
[0157] In this embodiment, the communication address information of the target server can be queried from the server information by acquiring the server information of the target server.
[0158] Based on the communication address information, the file extraction content is sent to the target server using the file processing interface.
[0159] In this embodiment, after obtaining the communication address information of the target server, communication interaction with the target server can be performed according to the communication address information, and the file extraction content can be sent to the target server using the file processing interface.
[0160] The present application constructs the file extraction content corresponding to the target Markdown file based on the title content and the second file content; then calls a preset processing interface library; then obtains a file processing interface from the processing interface library; subsequently obtains the communication address information of the target server, and based on the communication address information, uses the file processing interface to send the file extraction content to the target server. The present application constructs the file extraction content corresponding to the target Markdown file based on the title content and the second file content; then uses a file processing interface based on the use of a processing interface library; and then uses the file processing interface to send the file extraction content to the target server according to the communication address information of the target server. This realizes the intelligent and rapid completion of the standardized sending processing of the file extraction content of the Markdown file according to the dedicated file processing interface adapted to the Markdown file, ensures the normal sending processing of the file extraction content, and improves the processing efficiency and processing standardization of the file extraction content.
[0161] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0162] It should be emphasized that in order to further ensure the privacy and security of the second file content, the second file content can also be stored in a blockchain node.
[0163] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0164] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0165] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0166] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0167] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0168] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a file processing device, and the device embodiment is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0169] like Figure 3 As shown, the file processing device 300 described in this embodiment includes: a judgment module 301, an acquisition module 302, a reading module 303, an extraction module 304, a first processing module 305, a second processing module 306 and a sending module. Among them:
[0170] The judgment module 301 is used to judge whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file;
[0171] The acquisition module 302 is used to extract the file identifier from the file extraction request, and acquire the target Markdown file corresponding to the file identifier based on a preset target development platform;
[0172] The reading module 303 is used to read the file content of the target Markdown file;
[0173] An extraction module 304, configured to extract the title content from the file content based on a preset first regular expression;
[0174] A first processing module 305 is used to search for image content from the file content based on a preset second regular expression, and perform path replacement processing on the image content to obtain corresponding first file content;
[0175] A second processing module 306 is used to perform a content replacement process of the first file content in a target format based on a preset string replacement strategy to obtain corresponding second file content;
[0176] The sending module 307 is used to send the title content and the second file content to a target server.
[0177] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0178] In some optional implementations of this embodiment, the acquisition module 302 includes:
[0179] The first acquisition submodule is used to obtain a specified directory corresponding to the Markdown file;
[0180] A first calling submodule, used for calling the target development platform;
[0181] A first reading submodule, configured to read all Markdown files corresponding to the specified directory based on the target development platform;
[0182] A first screening submodule, used to screen out a designated Markdown file corresponding to the file identifier from all the Markdown files;
[0183] The first determination submodule is used to use the specified Markdown file as the target Markdown file.
[0184] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0185] In some optional implementations of this embodiment, the reading module 303 includes:
[0186] The second calling submodule is used to call a preset reading function;
[0187] The second reading submodule is used to asynchronously read the file content of the target Markdown file based on the reading function.
[0188] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and will not be repeated here.
[0189] In some optional implementations of this embodiment, the extraction module 304 includes:
[0190] A search submodule, configured to use the first regular expression to search for a title part from the file content to obtain a corresponding search result;
[0191] an extraction submodule, configured to extract the title part from the file content if the search result is a matching item corresponding to the title part searched in the file content;
[0192] A filtering submodule, used for filtering useless information in the title part to obtain a filtered title part;
[0193] The second determining submodule is used to use the filtered title part as the title content.
[0194] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0195] In some optional implementations of this embodiment, the first processing module 305 includes:
[0196] A first search submodule, used for searching for picture content from the file content using the second regular expression;
[0197] A second screening submodule is used to screen out picture links whose picture reference paths are relative paths from the picture content;
[0198] A first replacement submodule is used to replace the relative path in the image link with an absolute path to obtain the modified file content;
[0199] The third determining submodule is used to use the modified file content as the first file content.
[0200] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0201] In some optional implementations of this embodiment, the second processing module 306 includes:
[0202] A second search submodule, used to search for a content block corresponding to the target format from the first file content;
[0203] A second acquisition submodule, used to acquire a target replacement tag corresponding to the content block;
[0204] A second replacement submodule, configured to perform replacement processing on the content block based on the target replacement tag to obtain the replaced first file content;
[0205] The fourth determining submodule is configured to use the replaced first file content as the second file content.
[0206] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0207] In some optional implementations of this embodiment, the sending module 307 includes:
[0208] A construction submodule, used to construct a file extraction content corresponding to the target Markdown file based on the title content and the second file content;
[0209] The third calling submodule is used to call a preset processing interface library;
[0210] A third acquisition submodule is used to acquire a file processing interface from the processing interface library;
[0211] The fourth acquisition submodule is used to obtain the communication address information of the target server;
[0212] The sending submodule is used to send the file extraction content to the target server using the file processing interface based on the communication address information.
[0213] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the file processing method in the aforementioned implementation mode, and are not described in detail here.
[0214] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0215] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0216] The computer device may be a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with the user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0217] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the file processing method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0218] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run computer-readable instructions stored in the memory 41 or process data, such as computer-readable instructions for running the file processing method.
[0219] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0220] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0221] In the embodiment of the present application, after receiving the file extraction request triggered by the user, the target Markdown file corresponding to the file identifier carried in the file extraction request will be obtained based on the use of the target development platform, and the file content of the target Markdown file will be read. Then, based on the use of the first regular expression, the title content of the target Markdown file can be quickly and accurately extracted, ensuring the accuracy and consistency of the title content. And based on the second regular expression, the image content is searched from the file content, and the path replacement processing of the image content is performed to obtain the corresponding first file content, which can effectively avoid the problem that the image content of the first file content cannot be displayed normally after uploading, and ensure that the first file content can be displayed normally on the target server after migration. Subsequently, the first file content is replaced with the target format content based on the string replacement strategy to obtain the second file content, which effectively solves the defect that the target format content in the first file content may not be recognized and displayed. Finally, the title content and the second file content are sent to the target server, realizing the automatic and intelligent completion of the content extraction and sending processing of the target Markdown file, effectively reducing the processing time of content extraction, reducing the workload of content extraction processing, and thus improving the processing efficiency and processing intelligence of content extraction. In addition, sending the content data processed by regular expressions and string replacement strategies to the target server can effectively avoid the situation where the extracted content data cannot be displayed normally in the target server, thereby improving the readability and usability of the content data of the target Markdown file.
[0222] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the file processing method as described above.
[0223] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0224] In the embodiment of the present application, after receiving the file extraction request triggered by the user, the target Markdown file corresponding to the file identifier carried in the file extraction request will be obtained based on the use of the target development platform, and the file content of the target Markdown file will be read. Then, based on the use of the first regular expression, the title content of the target Markdown file can be quickly and accurately extracted, ensuring the accuracy and consistency of the title content. And based on the second regular expression, the image content is searched from the file content, and the path replacement processing of the image content is performed to obtain the corresponding first file content, which can effectively avoid the problem that the image content of the first file content cannot be displayed normally after uploading, and ensure that the first file content can be displayed normally on the target server after migration. Subsequently, the first file content is replaced with the target format content based on the string replacement strategy to obtain the second file content, which effectively solves the defect that the target format content in the first file content may not be recognized and displayed. Finally, the title content and the second file content are sent to the target server, realizing the automatic and intelligent completion of the content extraction and sending processing of the target Markdown file, effectively reducing the processing time of content extraction, reducing the workload of content extraction processing, and thus improving the processing efficiency and processing intelligence of content extraction. In addition, sending the content data processed by regular expressions and string replacement strategies to the target server can effectively avoid the situation where the extracted content data cannot be displayed normally in the target server, thereby improving the readability and usability of the content data of the target Markdown file.
[0225] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0226] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A file processing method, characterized in that: The steps include: Determine whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file; If yes, extract the file identifier from the file extraction request, and obtain the target Markdown file corresponding to the file identifier based on a preset target development platform; Read the file content of the target Markdown file; Extracting title content from the file content based on a preset first regular expression; Searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content; Performing a target-format content replacement process on the first file content based on a preset string replacement strategy to obtain corresponding second file content; The title content and the second file content are sent to a target server.
2. The file processing method according to claim 1, characterized in that: The step of acquiring the target Markdown file corresponding to the file identifier based on the preset target development platform specifically includes: Get the specified directory corresponding to the Markdown file; Calling the target development platform; Read all Markdown files corresponding to the specified directory based on the target development platform; Filter out a designated Markdown file corresponding to the file identifier from all the Markdown files; The designated Markdown file is used as the target Markdown file.
3. The file processing method according to claim 1, characterized in that: The step of reading the file content of the target Markdown file specifically includes: Call the preset read function; The file content of the target Markdown file is asynchronously read based on the read function.
4. The file processing method according to claim 1, characterized in that: The step of extracting the title content from the file content based on the preset first regular expression specifically includes: Using the first regular expression to search for a title part from the file content, to obtain a corresponding search result; If the search result is a matching item corresponding to the title part found in the file content, extracting the title part from the file content; Filtering useless information from the title part to obtain a filtered title part; The filtered title part is used as the title content.
5. The file processing method according to claim 1, characterized in that: The step of searching for image content from the file content based on a preset second regular expression and performing path replacement processing on the image content to obtain the corresponding first file content specifically includes: Using the second regular expression to search for image content from the file content; Filtering out image links whose image reference paths are relative paths from the image content; Replace the relative path in the image link with the absolute path to obtain the modified file content; The modified file content is used as the first file content.
6. The file processing method according to claim 1, characterized in that: The step of performing a target format content replacement process on the first file content based on a preset string replacement strategy to obtain the corresponding second file content specifically includes: Finding a content block corresponding to the target format from the first file content; Obtaining a target replacement tag corresponding to the content block; Performing a replacement process on the content block based on the target replacement tag to obtain a replaced first file content; The replaced first file content is used as the second file content.
7. The file processing method according to claim 1, characterized in that: The step of sending the title content and the second file content to the target server specifically includes: Constructing a file extraction content corresponding to the target Markdown file based on the title content and the second file content; Call the preset processing interface library; Obtaining a file processing interface from the processing interface library; Obtaining communication address information of the target server; Based on the communication address information, the file extraction content is sent to the target server using the file processing interface.
8. A file processing device, characterized in that: include: A judgment module, used to judge whether a file extraction request triggered by a user is received; wherein the file extraction request carries a file identifier of a target Markdown file; an acquisition module, configured to extract the file identifier from the file extraction request, and acquire the target Markdown file corresponding to the file identifier based on a preset target development platform; A reading module, used for reading the file content of the target Markdown file; An extraction module, used for extracting the title content from the file content based on a preset first regular expression; A first processing module, used for searching for image content from the file content based on a preset second regular expression, and performing path replacement processing on the image content to obtain corresponding first file content; A second processing module, configured to perform content replacement processing on the first file content in a target format based on a preset string replacement strategy to obtain corresponding second file content; A sending module is used to send the title content and the second file content to a target server.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the file processing method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the file processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method, device and computer-readable storage medium for document generation
CN108376127A
Method for storing and generating static resources in document
CN110008182A
Document website generation method and terminal
CN110187886A
Resource reference method and device, storage medium and electronic device
CN116541000A
