Partial editing method and device of Markdown text and storage medium
By splitting Markdown text into array elements and generating a text rendering component, and using the text selection component to obtain the frame selection area parameters, the problem of local editing in the existing technology is solved, and editing efficiency is improved.
Patent Information
- Application Number
- CN202510810738.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-10-24
Smart Images

Figure CN120832869A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and particularly relates to a local editing method, device and storage medium for Markdown text. BACKGROUND
[0002] In a WeChat mini-program, the display and editing of Markdown text is a common requirement. The current Markdown editing scheme needs to parse and render the entire Markdown text, and only the entire document can be operated during editing, so local editing cannot be achieved. However, in actual application scenarios, only a part of the content in the document may need to be modified, such as a paragraph or a list item. The existing editing method cannot meet the demand for local editing, resulting in low editing efficiency of the Markdown text.
[0003] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY
[0004] The main purpose of the present application is to provide a local editing method, device and storage medium for Markdown text, aiming to solve the technical problem of low editing efficiency of Markdown text.
[0005] To achieve the above purpose, the present application provides a local editing method for Markdown text, which comprises the following steps: The received Markdown text is divided into array elements and stored in the same array, and each array element in the array is converted into executable text; Text rendering components corresponding to the number of array elements are generated, and the executable text corresponding to each array element is rendered through the text rendering components, and the rendering result is displayed on the mini-program interface; In response to the box selection operation on the rendering result in the mini-program interface, the starting point parameter and the ending point parameter of the box selection area are obtained through the text selection component; According to the identification parameter of the text rendering component corresponding to the starting point parameter and the ending point parameter, the local text selected by the user is obtained from the array, so as to edit the local text.
[0006] In an embodiment, the step of dividing the received Markdown text into array elements and storing them in the same array comprises: According to a preset first label rule, the table element and the unordered list element in the Markdown text are determined; According to a preset second label rule, the text element in the Markdown text is split; The table element and the unordered list element are respectively regarded as an array element, and each text element obtained by splitting is respectively regarded as an array element in the form of a character string to obtain the array.
[0007] In one embodiment, the step of rendering the executable text corresponding to each array element by the text rendering component includes: Traversing the array, taking the executable text corresponding to each array element in the array as a parameter, and inputting it into the text rendering component corresponding to the array element; The identification parameter of the text rendering component is set to the index value of the array element corresponding to the text rendering component.
[0008] In one embodiment, the starting point parameter includes a first starting point parameter, and the first starting point parameter is used to indicate the starting row of the frame selection. The ending point parameter includes a first ending point parameter, and the first ending point parameter is used to indicate the ending row of the frame selection. The step of obtaining the local text selected by the user from the array according to the identification parameters of the text rendering component corresponding to the starting point parameter and the end point parameter includes: Determine the index value of the starting point array element according to the identification parameter of the text rendering component corresponding to the first starting point parameter; Determine the index value of the endpoint array element according to the identification parameter of the text rendering component corresponding to the first endpoint parameter; According to the index value of the starting point array element and the index value of the end point array element, the array is traversed to obtain the selected local text.
[0009] In one embodiment, the starting point parameter further includes a second starting point parameter, and the second starting point parameter is used to indicate the starting position of the selection area of the frame selection start line. The ending point parameter further includes a second ending point parameter, and the second ending point parameter is used to indicate the ending position of the selection area of the frame selection end line. The step of obtaining the local text selected by the user from the array according to the identification parameters of the text rendering component corresponding to the starting point parameter and the end point parameter further includes: Determine the starting position of the character string in the starting array element according to the second starting point parameter; Determine the end position of the character string in the end array element according to the second end parameter; According to the index value of the starting array element, the index value of the ending array element, the starting position of the string in the starting array element and the ending position of the string in the ending array element, the array is traversed to obtain the selected local text.
[0010] In an embodiment, the text selection component nests the text rendering component, and before the step of obtaining, by the text selection component, the start point parameter and the end point parameter of the selected region in response to the marquee operation of the applet interface, the method further comprises: setting an interaction parameter of the text rendering component, so that the text rendering component can trigger the text selection component to identify the selected region in response to a marquee operation on the rendering result.
[0011] In an embodiment, after the step of obtaining, from the array, the local text selected by the user according to the identification parameter of the text rendering component corresponding to the start point parameter and the end point parameter, the method further comprises: inputting the local text, the position information corresponding to the local text, and the Markdown text into a language model; receiving a new Markdown text output by the language model after the language model edits the local text according to the demonstrative word.
[0012] In an embodiment, the step of editing, by the language model, the local text according to the demonstrative word comprises: replacing the modified local text into the array according to the position information corresponding to the local text by the language model; extracting the array elements by traversing the array by the language model, and converting the array elements into Markdown format.
[0013] In addition, to achieve the above-mentioned purpose, the present application also proposes a local editing device for Markdown text, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the local editing method for Markdown text as described above.
[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the local editing method for Markdown text as described above.
[0015] The application provides a partial editing method of Markdown text. The received Markdown text is first divided into array elements and stored in the same array, and each array element in the array is converted into executable text. Then, text rendering components corresponding to the number of array elements are generated, and the executable text corresponding to each array element is rendered by the text rendering components, and the rendering result is displayed on the mini-program interface. In response to the box selection operation on the rendering result on the mini-program interface, the start point parameter and the end point parameter of the box selection area are obtained by the text selection component. The local text selected by the user is obtained from the array according to the identification parameter of the text rendering component corresponding to the start point parameter and the end point parameter, so as to edit the local text.
[0016] The above method divides the received Markdown text into array elements for storage and converts it into executable text, simultaneously generates text rendering components corresponding thereto, and renders and displays the executable text of each array element on the mini-program interface. When the user selects a box, the text selection component obtains the start point and the end point parameters of the box selection area, and then accurately obtains the local text selected by the user from the array according to the identification parameter of the text rendering component corresponding to the parameters, for modification. In this way, the partial editing of the document is realized, without the need to operate the entire document, thereby effectively improving the editing efficiency of the Markdown text. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are incorporated into and form a part of the specification, illustrate preferred embodiments of the application and, together with the description, serve to explain the principles of the application.
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0019] Figure 1 The flowchart provided by the partial editing method of the Markdown text in Embodiment One of the application; Figure 2 The flowchart provided by the partial editing method of the Markdown text in Embodiment Three of the application; Figure 3 The device structure diagram of the hardware running environment involved in the partial editing method of the Markdown text in the embodiments of the application.
[0020] The purpose implementation, functional characteristics and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0021] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.
[0022] In order to better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and specific embodiments.
[0023] In the WeChat applet, the display and editing of Markdown text are common requirements. The current Markdown editing scheme needs to parse and render the entire Markdown text, and only the entire document can be operated during editing, and local editing cannot be realized. However, in actual application scenarios, only a part of the content in the document may need to be modified, such as a paragraph or a list item. The existing editing method cannot meet the demand of local editing, resulting in low editing efficiency of Markdown text.
[0024] In view of the above problems, the present application provides a local editing method of Markdown text, which divides the received Markdown text into array elements for storage and converts it into executable text, and generates a text rendering component corresponding thereto. The executable text of each array element is rendered and displayed on the applet interface. When the user selects a box, the text selection component obtains the start and end parameters of the selected box area, and then obtains the local text selected by the user from the array according to the text rendering component identification parameter corresponding to the parameters, and modifies it. In this way, local editing of the document is realized, and the entire document does not need to be operated, thereby effectively improving the editing efficiency of Markdown text.
[0025] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions. The present embodiment and the following embodiments will be described below taking the WeChat applet as an example.
[0026] Based on this, the first embodiment of the present application provides a local editing method of Markdown text, which is described in detail as follows with reference to Figure 1 In the present embodiment, the local editing method of Markdown text includes steps S10-S40: Step S10, the received Markdown text is divided into array elements and stored in the same array, and each array element in the array is converted into executable text.
[0027] It can be understood that, according to the syntax rules of the Markdown text, different element types in the Markdown text can be recognized, such as table, unordered list and normal text. Exemplarily, in the Markdown text, the first line of the table element starts with “|” and contains at least one cell, the next line contains the “---” separator, and the subsequent lines keep the “|” alignment format. The unordered list starts with the “-”, “*” or “+” symbol, etc. Therefore, different elements in the Markdown text can be found according to the syntax parser by matching the corresponding symbols through regular expressions.
[0028] Optionally, step S10 comprises steps S11-S13: In step S11, the table element and the unordered list element in the Markdown text are determined according to a preset first label rule.
[0029] Exemplarily, according to the syntax rules of the Markdown text, the first label rule is defined, which can include the rule for identifying the table element and the rule for identifying the unordered list element. The rule for identifying the table element can be that the first line contains the “|” separator and the second line contains the “---” separator in the two consecutive lines. The rule for identifying the unordered list element can be that the “-”, “*” or “+” symbol is followed by a space.
[0030] According to the preset first label rule, the Markdown text is scanned line by line from the beginning, and it is checked whether each line meets the rule of the table or the unordered list.
[0031] Exemplarily, for the table element, it is first checked whether the current line contains the “|” separator. If it contains, it is further checked whether the next line contains the “---” separator. If the above conditions are met, it is determined that the table element is recognized, and the subsequent table content is continuously scanned until a line no longer contains the “|” separator. The scanned content is taken as a complete table element.
[0032] Exemplarily, for the unordered list element, it is checked whether the current line starts with the “-”, “*” or “+” symbol and the symbol is followed by a space. If so, it is determined that the unordered list element is recognized, and the current line is taken as a complete unordered list element.
[0033] In step S12, the text element in the Markdown text is split according to a preset second label rule.
[0034] Exemplarily, after the table element and the unordered list element are determined, other normal text is split by line with the line feed character, and each line is taken as an independent text element.
[0035] Step S13, the table element and the unordered list element are respectively taken as an array element, and each text element obtained by splitting is taken as an array element in the form of a string, to obtain the array.
[0036] For example, the table element, the unordered list element, and the text element split by rows are sequentially stored as array elements in the same array, wherein the split text elements are stored in the order of their appearance in the Markdown text.
[0037] For example, after splitting the Markdown text, an array z is obtained: ["|Header 1|Header 2|Header 3|\n|---|---|---|\n|Content 1|Content 2|Content 3|\n|Content 4|Content 5|Content 6|\n","-List item 1\n*List item 2\n+List item 3\n","This is the first line of text.\n","This is the third line of text.\n"]. The first array element in the array z is the table element, the second array element is the unordered list element, and the third and fourth array elements are text elements.
[0038] Optionally, after obtaining the array, the Markdown text of each array element in the array is converted into other executable texts such as HTML (Hypertext Markup Language) texts.
[0039] Step S20, a text rendering component corresponding to the number of array elements is generated, and the executable text corresponding to each array element is rendered through the text rendering component, and the rendering result is displayed on the mini-program interface.
[0040] For example, after obtaining the array, the array is traversed, starting from index 0, and each array element in the array is accessed one by one. Each time an array element is accessed, the counter is incremented by 1, and a text rendering component is generated. When the entire array is traversed, a text rendering component corresponding to the number of array elements is obtained. The array and the text rendering component are traversed, and the array elements and the corresponding text rendering components are accessed synchronously using the index, so that the array elements and the text rendering components correspond one by one.
[0041] Optionally, the step of rendering the executable text corresponding to each array element through the text rendering component comprises steps S21-S22: Step S21, traverse the array, and input the executable text corresponding to each array element in the array as a parameter to the text rendering component corresponding to the array element.
[0042] Step S22, set the identification parameter of the text rendering component to the index value of the array element corresponding to the text rendering component.
[0043] Exemplarily, a loop, such as a for loop or a foreach loop, is used to access each element in the array one by one. In each iteration, the array element corresponding to the current index value is extracted from the array, i.e., the executable text. Based on the current index value, the text rendering component corresponding to the array element is found, and the extracted executable text is passed as a parameter to the corresponding text rendering component, so that the executable text is rendered by the text rendering component.
[0044] In one feasible implementation, a rich-text component is used as a text rendering component. The rich-text component is looped through according to an array, and the HTML text within each array element is passed as the "nodes" parameter of the rich-text component. Each HTML text item is rendered to obtain a rendering result, which is then displayed on the mini-program interface, allowing the user to select the rendered text within the mini-program interface. Simultaneously, the rich-text component's identification parameter, such as the component ID, is set to the index value of the array element.
[0045] Step S30, in response to the selection operation of the rendering result in the mini program interface, the start point parameter and the end point parameter of the selection area are obtained through the text selection component.
[0046] Step S40 , obtaining the local text selected by the user from the array according to the identification parameters of the text rendering component corresponding to the starting point parameter and the end point parameter, so as to edit the local text.
[0047] Exemplarily, the scope of the selected area is determined by the text selection component, and the index value of the array element is located according to the identification parameter of the text rendering component corresponding to the rendering result within the selected area, so that the selected local text can be determined from the array according to the index value of the array element.
[0048] Optionally, the starting point parameter includes a first starting point parameter, which is used to indicate the starting line of the selection, and the ending point parameter includes a first ending point parameter, which is used to indicate the ending line of the selection. According to the identification parameters of the text rendering component corresponding to the starting point parameter and the ending point parameter, the step of obtaining the local text selected by the user from the array includes steps S41 to S43: Step S41: determining the index value of the starting point array element according to the identification parameter of the text rendering component corresponding to the first starting point parameter.
[0049] Step S42: determining the index value of the end point array element according to the identification parameter of the text rendering component corresponding to the first end point parameter.
[0050] Step S43, according to the index value of the start array element and the index value of the end array element, traversing the array to get the framed local text.
[0051] In a feasible implementation, the selection component is used as a text selection component. When the user frames the rendering result in the applet interface, the selectionchange method of the selection component is triggered, and the selection area object selections is obtained through the selectionchange function. The selection area object selections returns the firstNodeId parameter and the lastNodeId parameter. The firstNodeId parameter represents the starting line of the user's framing, which is equivalent to the first start parameter described above; the lastNodeId parameter represents the termination line of the user's framing, which is equivalent to the first end parameter described above.
[0052] For example, assuming that the Markdown text is processed to generate the following HTML text array: array A: ["", "", "", "", ""]. List item 1 List item 2 "," First line. "," Second line. "," Third line. The array A has one unordered list array element A[0] and three text array elements A[1], A[2], and A[3], which correspond to the component IDs of the rich-text components 0, 1, 2, and 3, respectively. Assuming that the text rendering component displays the above array elements on the applet interface, and the user frames the text content of the first and second lines on the applet interface, the selectionchange function can obtain the firstNodeId parameter "[1]" and the lastNodeId parameter "[2]". Then, the rich-text component corresponding to the framed area is determined according to the above parameters, and the array element corresponding to the framed content is determined according to the component ID of the rich-text component. Finally, the array is traversed to extract the framed content from the array element to obtain the local text framed by the user.
[0053] Exemplarily, if the user performs the box selection on the text content on the applet interface, the firstNodeId parameter obtained by the selectionchange function is [1] and the lastNodeId parameter is [3]. Then, the rich-text component [1] and the rich-text component [3] are determined according to the parameters. The index value corresponding to the rich-text component [1] is taken as the start position and the index value corresponding to the rich-text component [3] is taken as the end position by traversing the array. The three array elements A[1], A[2] and A[3], i.e., the contents of the first to third rows are extracted to obtain the local text selected by the user.
[0054] Optionally, the start point parameter further includes a second start point parameter, and the second start point parameter is used to indicate the selection start position of the box selection starting row. The end point parameter further includes a second end point parameter, and the second end point parameter is used to indicate the selection end position of the box selection ending row. The step of obtaining the local text selected by the user from the array according to the identification parameters of the text rendering components corresponding to the start point parameter and the end point parameter further includes steps S44-S46: Step S44, determining the start point position of the string in the start point array element according to the second start point parameter.
[0055] Step S45, determining the end point position of the string in the end point array element according to the second end point parameter.
[0056] Step S46, traversing the array according to the index value of the start point array element, the index value of the end point array element, the start point position of the string in the start point array element and the end point position of the string in the end point array element to obtain the local text selected by the user.
[0057] Exemplarily, the selectionchange function can further return a firstOffset parameter and a lastOffset parameter. The firstOffset parameter represents the selection start position of the starting row, which is equivalent to the second start point parameter. The lastOffset parameter represents the selection end position of the ending row, which is equivalent to the second end point parameter.
[0058] Taking the above example as an example, each array element in the array A is a string. The offset of the selection start position and the selection end position in the string of the corresponding array element can be determined according to the firstOffset parameter and the lastOffset parameter.
[0059] For example, if the user selects a text content in the widget interface, the firstNodeId parameter obtained by the selectionchange function is [1], the lastNodeId parameter is [3], the firstOffset parameter is 4, and the lastOffset parameter is 6. The start position of the selected area is the 4th character "th" in the string corresponding to the array element A[1], and the end position of the selected area is the 7th character "." in the string corresponding to the array element A[3]. According to the firstNodeId parameter and the lastNodeId parameter, the rich-text component [1] and the rich-text component [3] are determined. The index value corresponding to the rich-text component [1] is taken as the start position, and the index value corresponding to the rich-text component [3] is taken as the end position. The contents of the array elements A[1], A[2], and A[3] from the first row to the third row are extracted, and the firstOffset parameter is taken as the start position to traverse the array element A[1], and the lastOffset parameter is taken as the end position to traverse the array element A[3]. The contents extracted from the array elements A[1] and A[3] and the content corresponding to A[2] are concatenated in order to obtain the partial text selected by the user.
[0060] Preferably, the table element and the unordered list element in the Markdown text are taken as array elements at specified positions, for example, the table element is taken as the first array element, the unordered list element is taken as the second array element, and other text elements are taken as other array elements after being split according to their order in the Markdown text.
[0061] When the identification parameter of the text rendering component corresponding to the first start parameter or the first end parameter obtained by the text selection component is the index value of the array element at the specified position, the entire array element is directly extracted as the partial text. That is, when the user selects the content as a table or an unordered list, the complete table content and unordered list content are extracted to maintain the integrity of the content.
[0062] When the identification parameter of the text rendering component corresponding to the first start parameter or the first end parameter obtained by the text selection component is not the index value of the array element at the specified position, the selected string is extracted from the array element as the partial text according to the second start parameter or the second end parameter obtained by the text selection component. That is, when the user selects the content as pure text, the text selected by the user is extracted.
[0063] In the embodiment, the Markdown text is segmented and stored as array elements, the array elements are converted into executable text rendering, the start parameter and the end parameter of the selected region on the rendering result are obtained by the text selection component, the local text selected by the user is accurately found from the previously stored array according to the identification parameter of the text rendering component corresponding to the obtained start parameter and end parameter, and the corresponding array element can be quickly located, so that the local text is modified, the entire document does not need to be operated, and the Markdown text editing efficiency is improved.
[0064] Based on the first embodiment of the application, in the second embodiment of the application, the same or similar contents as the above embodiment one can be referred to the above introduction, and will not be described in detail. On this basis, the text selection component is nested in the text rendering component, and before step S30, the local editing method of the Markdown text further includes step S50. Step S50, setting the interaction parameter of the text rendering component, so that the text rendering component can respond to the selection operation on the rendering result, and trigger the text selection component to identify the selected region.
[0065] For example, the above selection text selection component and rich-text text rendering component are taken as examples, in order to support the selection operation, the user-select parameter of the rich-text component is set to true, so that it can respond to the touch or click event of the user. The rich-text component is nested in the selection component, so that the rich-text component can respond to the touch or click event of the user to trigger the selection component to obtain the start parameter and the end parameter of the selected region.
[0066] It should be noted that the above selection component and rich-text component are only an example, and in other embodiments, the same effect can also be achieved by other components. For example, the text rendering component can adopt the towxml component, the towxml component provides the events parameter, which can be used to bind the event processing function, so that it can respond to the touch or click event of the user, and support the selection operation. The text selection component can adopt the mp-select-text component, and the bindcopy event thereof can obtain the related information of the selected region.
[0067] Optionally, the user can also write code functions to realize the functions of the above text selection component and text rendering component, and the application does not limit this.
[0068] Based on the above embodiments of the application, in the third embodiment of the application, the same or similar contents as the above embodiments can be referred to the above introduction, and the subsequent will not be described in detail. On this basis, refer to Figure 2 After step S40, the partial editing method of the Markdown text further includes steps S60-S70: Step S60, input the partial text, the position information corresponding to the partial text and the Markdown text into the language model.
[0069] Step S70, after editing the partial text according to the demonstrative word through the language model, receive the new Markdown text output by the language model.
[0070] The user's partial text and its corresponding position information are sorted together with the complete Markdown text as input data. The position information can be determined by the identifier parameter of the text rendering component, which corresponds to the index value of the array element and can accurately locate the position of the partial text in the array.
[0071] The above input data is sent to the language model, and the language model modifies the partial text according to the demonstrative word such as the user's input "modify text style". The language model can consider the partial text content and its context in the overall Markdown text when processing to ensure that the modification result conforms to the context logic. After the modification is completed, the language model outputs a new Markdown text, which contains the modified partial content and the original content that has not been changed, and the output format remains consistent with the original Markdown text, which can be directly used for subsequent display or save operation.
[0072] Optionally, the step of modifying the partial text according to the demonstrative word through the language model includes steps S71-S72: Step S71, replace the modified partial text into the array through the language model according to the position information corresponding to the partial text.
[0073] Step S72, traverse the array through the language model, extract the array elements, and convert the array elements into Markdown format.
[0074] Exemplarily, an index value of a local text corresponding to an array element is extracted from the input data, and according to the position information, the array element needing to be replaced is accurately located in the array storing the Markdown text content. The modified local text replaces the corresponding original element in the array. For example, the replacement is realized by an assignment operation: array[index]=modified_text, where array is the array storing the Markdown content, index is the position information of the local text, and modified_text is the modified text output by the language model.
[0075] Then, each element is accessed in turn from the first element of the array. A complete HTML text is obtained, and the HTML text is converted into a Markdown format to obtain a new Markdown text.
[0076] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the local editing method of the Markdown text of the present application. More forms of simple transformation based on this technical concept are within the protection scope of the present application.
[0077] The present application provides a local editing device for Markdown text, which comprises at least one processor and a memory in communication connection with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the local editing method of the Markdown text in the above-mentioned embodiment one.
[0078] Reference will be made to the following description of the drawings Figure 3 which shows a structural schematic diagram of a local editing device for Markdown text suitable for implementing the embodiments of the present application. The local editing device for Markdown text in the embodiments of the present application can include, but is not limited to, mobile terminals such as notebook computers, tablet computers (PAD, Portable Application Description), and fixed terminals such as desktop computers. Figure 3 The local editing device for Markdown text shown is only an example and should not bring any limitation to the functions and use range of the embodiments of the present application.
[0079] As Figure 3As shown, the partial editing device of Markdown text can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. Various programs and data required for operation of the partial editing device of Markdown text are also stored in the random access memory 1004. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the partial editing device of Markdown text to communicate with other devices wirelessly or by wire to exchange data. Although the partial editing device of Markdown text with various systems is shown in the figure, it should be understood that all the shown systems are not required to be implemented or possessed. More or less systems can be alternatively implemented or possessed.
[0080] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through a communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of embodiments of the present disclosure are performed.
[0081] The partial editing device of the Markdown text provided in the application adopts the partial editing method of the Markdown text in the above embodiment, and can solve the technical problem of low editing efficiency of the Markdown text. Compared with the prior art, the Markdown text partial editing device provided in the application has the same beneficial effects as the Markdown text partial editing method provided in the above embodiment, and other technical features in the Markdown text partial editing device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0082] It should be understood that various parts of the present application can be realized by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0083] The above is merely specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0084] The present application provides a computer readable storage medium having stored thereon computer readable program instructions (i.e. computer programs) for performing the partial editing method of the Markdown text in the above embodiment.
[0085] The computer readable storage medium provided in the present application may, for example, be a U disk, but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present embodiment, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer readable storage medium can be transmitted in any suitable medium, including but not limited to an electrical wire, an optical cable, a radio frequency (RF), and the like, or any suitable combination of the above.
[0086] The above computer readable storage medium can be included in the local editing device of the Markdown text, or can exist separately without being assembled into the local editing device of the Markdown text.
[0087] The above computer readable storage medium carries one or more programs, which, when executed by the local editing device of the Markdown text, enable the local editing device of the Markdown text to write computer program code in one or more programming languages or combinations thereof for executing the operations of the present application. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The program code can be executed entirely on the user computer, partially on the user computer, or as a separate software package, partially on the user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, through an Internet service provider to connect through the Internet).
[0088] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a 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 can 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 and / or flow diagrams, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0089] The modules involved in the embodiments of the present application can be implemented in the form of software or in the form of hardware. In some cases, the name of the module does not constitute a limitation on the unit itself.
[0090] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer programs) for executing the above-mentioned local editing method of Markdown text, and can solve the technical problem of low editing efficiency of Markdown text. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the Markdown text local editing method provided by the above-mentioned embodiments, which will not be repeated here.
[0091] The present application also provides a computer program product comprising a computer program, which, when executed by a processor, implements the steps of the above-mentioned local editing method of Markdown text.
[0092] The computer program product provided by the present application can solve the technical problem of low editing efficiency of Markdown text. Compared with the prior art, the computer program product provided by the present application has the same beneficial effects as the Markdown text local editing method provided by the above-mentioned embodiments, which will not be repeated here.
[0093] The above-mentioned is only part of the embodiments of the present application, and does not limit the patent scope of the present application. Any equivalent structural transformation made by using the content of the present application specification and drawings, or direct / indirect application in other related technical fields is included in the patent protection scope of the present application.
Claims
1. A method of partial editing of Markdown text, characterized by, The local editing of the Markdown text comprises: storing array elements obtained by splitting the received Markdown text in an array, and converting each array element in the array into executable text; generating a text rendering component corresponding to the number of array elements, and displaying the rendering result of the executable text corresponding to each array element in the array on a mini-program interface through the text rendering component; in response to a box selection operation on the rendering result on the mini-program interface, obtaining a start point parameter and an end point parameter of the box selection region through a text selection component; obtaining the local text selected by the user from the array according to the identification parameter of the text rendering component corresponding to the start point parameter and the end point parameter, and editing the local text.
2. The partial editing method of Markdown text according to claim 1, wherein, The step of storing array elements obtained by splitting the received Markdown text in an array comprises: determining table elements and unordered list elements in the Markdown text according to a preset first label rule; splitting text elements in the Markdown text according to a preset second label rule; storing the table elements and the unordered list elements as one array element respectively, and storing each text element obtained by splitting as one array element in the form of a string, to obtain the array.
3. The partial editing method of Markdown text according to claim 2, wherein, The step of rendering the executable text corresponding to each array element through the text rendering component comprises: traversing the array, inputting the executable text corresponding to each array element in the array as a parameter into the text rendering component corresponding to the array element; setting the identification parameter of the text rendering component as the index value of the array element corresponding to the text rendering component.
4. The partial editing method of Markdown text according to claim 3, wherein, The start point parameter comprises a first start point parameter for indicating the starting line of the box selection, and the end point parameter comprises a first end point parameter for indicating the ending line of the box selection, The step of obtaining the local text selected by the user from the array according to the identification parameter of the text rendering component corresponding to the start point parameter and the end point parameter comprises: determining the index value of the start point array element according to the identification parameter of the text rendering component corresponding to the first start point parameter; determining the index value of the end point array element according to the identification parameter of the text rendering component corresponding to the first end point parameter; traversing the array according to the index value of the start point array element and the index value of the end point array element to obtain the local text selected by the user.
5. The partial editing method of Markdown text according to claim 4, wherein, The start point parameter further comprises a second start point parameter for indicating the starting position of the selected area of the starting line of the box selection, and the end point parameter further comprises a second end point parameter for indicating the ending position of the selected area of the ending line of the box selection, The step of obtaining the local text selected by the user from the array according to the identification parameter of the text rendering component corresponding to the start point parameter and the end point parameter further comprises: determining the start point position of the string in the start point array element according to the second start point parameter; determining the end point position of the string in the end point array element according to the second end point parameter; According to the index value of the start array element, the index value of the end array element, the start position of the string in the start array element, and the end position of the string in the end array element, the array is traversed to obtain the framed local text.
6. The partial editing method of Markdown text according to any one of claims 1 to 5, wherein, The text selection component is nested in the text rendering component, and before the step of obtaining the start parameter and the end parameter of the framing area through the text selection component in response to the framing operation of the applet interface, the method further comprises: Setting the interaction parameter of the text rendering component so that the text rendering component can respond to the framing operation on the rendering result and trigger the text selection component to identify the framing area.
7. The partial editing method of Markdown text according to claim 1, wherein, After the step of obtaining the local text framed by the user from the array according to the identification parameter of the text rendering component corresponding to the start parameter and the end parameter, the method further comprises: Inputting the local text, the position information corresponding to the local text, and the Markdown text into a language model; After editing the local text according to the demonstrative word through the language model, receiving the new Markdown text output by the language model.
8. The partial editing method of Markdown text according to claim 7, wherein, The step of editing the local text according to the demonstrative word through the language model comprises: Replacing the modified local text into the array according to the position information corresponding to the local text through the language model; Traversing the array through the language model, extracting the array elements, and converting the array elements into Markdown format.
9. A partial editing device of Markdown text, characterized by, The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the local editing method of the Markdown text according to any one of claims 1 to 8.
10. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the local editing method of the Markdown text according to any one of claims 1 to 8.