The syntax currently used by the SF community is derived from wiki and markdown. More than one person has mentioned this with me, I want to solve this problem when the number of problems is not that large. That is, to replace it with the standard Markdown syntax. Its Syntax Parsing is completely blank... the syntax currently used by the SF community is derived from wiki and markdown. More than one person has mentioned this with me, I want to solve this problem when the number of problems is not that large. That is, to replace it with the standard Markdown syntax. Its Syntax Parsing is completely free, and there are mature parsing libraries on the Internet.
But how can we convert the current syntax format into a standard markdown? I hope you can provide a complete solution.
Is to have a php implementationclass
Orfunction
, Enter the current syntax text to output the Markdown format text
Reply content:
The syntax currently used by the SF community is derived from wiki and markdown. More than one person has mentioned this with me, I want to solve this problem when the number of problems is not that large. That is, to replace it with the standard Markdown syntax. Its Syntax Parsing is completely free, and there are mature parsing libraries on the Internet.
But how can we convert the current syntax format into a standard markdown? I hope you can provide a complete solution.
Is to have a php implementationclass
Orfunction
, Enter the current syntax text to output the Markdown format text
I remember the idea I mentioned before that is to identify through meta tags, similar to vim's modeline.
From a certain point in time, the old Content Header is added in a uniform way like "!". Syntax: sgwiki "is used to differentiate the old wiki syntax. New content is written using markdown by default. Of course, you can also support more lightweight syntax tags, not limited to markdown, as long as the header has a corresponding meta tag. For example, "! Syntax: markdown ""!! Syntax: multimarkdown "and so on.
It is not recommended to perform automatic syntax conversion. This is like parsing HTML with RegEx, because you will never be able to consider all the situations, and it is best to keep the user's input intact, only compatible devices are available. This is the simplest solution.
Instead of performing conversion, it is better to add a syntax attribute to each text entry. the old entries are recorded as the old syntax by default, and the new entries are recorded as markdown. when outputting the page, you can call different resolution libraries based on the syntax attributes. of course, more syntaxes will be supported in the future, but it doesn't make much sense. markdown is enough for the public.
Btw, recommended GFM https://help.github.com/articles/gith...
Solution: html is rendered on the interface. What if I convert the html on the interface after the current syntax is rendered to markdown? Then wash the database.
The final result is as follows: the editor with the markdown syntax is provided on the interface. After the new editor is launched, when you click 'edit', The markdown syntax format is displayed. You can also use the markdown syntax to edit new data.
If so:
- It is most appropriate to use the above solution to wash the previous data database, and the user does not feel the pain of function change.
- UsePrevious syntaxThe rendered html converts the tml into markdown format data, and then cleans the old data in the database to ensure that the style does not change much.
- You do not need to add two sets of editor syntax and conversion programs on the interface.
The workload of database washing is also very large. It is the easiest to support cough di Xiaoyu. It can be done in a few steps, and the function expansion is better than Data Reconstruction.