{"id":15480309,"url":"https://github.com/andycall/htmlflatten","last_synced_at":"2026-01-06T17:53:34.168Z","repository":{"id":57267962,"uuid":"85840718","full_name":"andycall/htmlflatten","owner":"andycall","description":"Flatten your html source, and generate json text data","archived":false,"fork":false,"pushed_at":"2017-03-23T03:10:43.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T04:31:20.526Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andycall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-22T14:54:11.000Z","updated_at":"2018-05-01T05:09:48.000Z","dependencies_parsed_at":"2022-09-02T02:50:12.231Z","dependency_job_id":null,"html_url":"https://github.com/andycall/htmlflatten","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2Fhtmlflatten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2Fhtmlflatten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2Fhtmlflatten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andycall%2Fhtmlflatten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andycall","download_url":"https://codeload.github.com/andycall/htmlflatten/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246045402,"owners_count":20714773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T04:41:28.018Z","updated_at":"2026-01-06T17:53:34.123Z","avatar_url":"https://github.com/andycall.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htmlflatten\nFlatten your html source, and generate json text data\n\nThis Project is still under development\n\n## Platform\nwritten based on DOM3 API\nso this project can be running in most Browser environment or jsdom.\n\n## What is Used To be\nIf we have some html code\n```html\n\u003cdiv\u003e\n    \u003cp\u003ehelloworld\u003c/p\u003e\n    \u003cspan\u003e\n        text\n        \u003cspan\u003etext3\u003c/span\u003e\n        \u003cspan\u003etext4\u003c/span\u003e\n    \u003c/span\u003e\n    \u003cp\u003e123456\u003cspan\u003e78\u003c/span\u003e90\u003cbr/\u003e\u003cspan\u003e2333333\u003c/span\u003e\u003c/p\u003e\n    \u003cimg width=\"50\" height=\"50\" src=\"https://avatars3.githubusercontent.com/u/4409743?v=3\u0026s=460\"/\u003e\n\u003c/div\u003e\nwwwww\n\u003cspan\u003e12323\u003c/span\u003e\n1232323\n213123123\n\u003cbr /\u003e\n```\nWithout CSS Stylesheets, This code should looking like this:\n\n![image](https://cloud.githubusercontent.com/assets/4409743/24209325/e1985ab4-0f60-11e7-9b24-e2297e3c01a9.png)\n\nThis Project can help to generate json with data and keep the newline of the text;\n\n```javascript\n{ image_num: 1,\n  items:\n   [ { type: 'text', data: 'helloworld' },\n     { type: 'text', data: 'text\\n        text3\\n        text4' },\n     { type: 'text', data: '1234567890' },\n     { type: 'text', data: '2333333' },\n     { type: 'image',\n       data: { src: 'https://avatars3.githubusercontent.com/u/4409743?v=3\u0026s=460' } },\n     { type: 'text', data: 'wwwww123231232323\\n213123123' },\n     [length]: 6 ] }\n```\n\n\n## How to Use\n\n\n```javascript\nlet jsdom = require('jsdom');\nlet html = `\n\u003cdiv\u003e\n    \u003cp\u003ehelloworld\u003c/p\u003e\n    \u003cspan\u003e\n        text\n        \u003cspan\u003etext3\u003c/span\u003e\n        \u003cspan\u003etext4\u003c/span\u003e\n    \u003c/span\u003e\n    \u003cp\u003e123456\u003cspan\u003e78\u003c/span\u003e90\u003cbr/\u003e\u003cspan\u003e2333333\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cimg src=\"https://avatars3.githubusercontent.com/u/4409743?v=3\u0026s=460\"/\u003e\nwwwww\n\u003cspan\u003e12323\u003c/span\u003e\n1232323\n213123123\n\u003cbr /\u003e\n`\n\nlet document = jsdom(html, {\n    features: {\n        FetchExternalResources: false,\n        ProcessExternalResources: false\n    }\n});\nlet DOMParser = require('htmlflatten');\nlet parser = new DOMParser(document.body);\nlet json = parser.toJSON();\n\nconsole.log(json);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycall%2Fhtmlflatten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandycall%2Fhtmlflatten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandycall%2Fhtmlflatten/lists"}