Suggestions on how build an HTML Diff tool?

前端 未结 16 1763
灰色年华
灰色年华 2021-02-02 02:00

In this post I asked if there were any tools that compare the structure (not actual content) of 2 HTML pages. I ask because I receive HTML templates from our designers, and freq

16条回答
  •  粉色の甜心
    2021-02-02 02:31

    I don't know any tool but I know there is a simple way to do this:

    • First, use a regular expression tool to strip off all the text in your HTML file. You can use this regular expression to search for the text (?<=^|>)[^><]+?(?=<|$) and replace them with an empty string (""), i.e. delete all the text. After this step, you will have all HTML markup tags. There are a lot of free regular expression tools out there.
    • Then, you repeat the first step for the original HTML file.
    • Last, you use a diff tool to compare the two sets of HTML markups. This will show what is missing between one set and the other.

提交回复
热议问题