{"id":22474660,"url":"https://github.com/smartface/html-to-text","last_synced_at":"2025-03-27T16:46:54.516Z","repository":{"id":57161071,"uuid":"131401879","full_name":"smartface/html-to-text","owner":"smartface","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-29T11:45:22.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-03T09:02:56.312Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/smartface.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":"2018-04-28T10:57:47.000Z","updated_at":"2021-04-29T11:45:24.000Z","dependencies_parsed_at":"2022-08-24T08:11:17.956Z","dependency_job_id":null,"html_url":"https://github.com/smartface/html-to-text","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartface%2Fhtml-to-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartface%2Fhtml-to-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartface%2Fhtml-to-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartface%2Fhtml-to-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartface","download_url":"https://codeload.github.com/smartface/html-to-text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245888014,"owners_count":20688893,"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-12-06T13:09:38.981Z","updated_at":"2025-03-27T16:46:54.499Z","avatar_url":"https://github.com/smartface.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Twitter: @Smartface_io](https://img.shields.io/badge/contact-@Smartface_io-blue.svg?style=flat)](https://twitter.com/smartface_io)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/smartface/html-to-text/blob/master/LICENSE)\n![npm version](https://img.shields.io/npm/v/@smartface/html-to-text.svg?style=flat)\n[![Build Status](https://travis-ci.org/smartface/html-to-text.svg?branch=master)](https://travis-ci.org/smartface/html-to-text)\n\n# ⛔️ DEPRECATED\nThis repository is only used internally via smartface services and will not receive new versions anymore. To use the conversion on Smartface Projects, refer to [this link](https://github.com/smartface/sf-extension-utils/blob/master/doc/html-to-text.md)\n\n# html-to-text\n\nYou can convert html string to attributed strings for your textview component with this module\n\n## Installation\n    \n    npm i --save @smartface/html-to-text\n    \n## Usage \u0026 Example\n\n```javascript\n    const TextView = require('sf-core/ui/textview');\n    const AttributedString = require(\"sf-core/ui/attributedstring\");\n    const createAttributedStrings = require(\"@smartface/html-to-text\");\n    const propFactory = require(\"@smartface/contx/lib/smartface/sfCorePropFactory\").default;\n    \n    var textView = new TextView();\n    var htmlSource = \"\u003cspan style=\\\"font-size: 24px; color: rgb(0, 0, 0); text-decoration-color: rgb(0, 0, 0);\\\"\u003e\u003cspan style=\\\"font-family: Nunito-LightItalic; font-size: 24px; background-color: transparent; color: rgb(0, 0, 0); text-decoration-color: rgb(0, 0, 0);\\\"\u003eYour \u003c/span\u003e\u003cfont face=\\\"ios-Default-Bold\\\" style=\\\"font-size: 24px; font-family: ios-Default-Regular; background-color: transparent; color: rgb(0, 0, 0); text-decoration-color: rgb(0, 0, 0);\\\"\u003eattributed \u003c/font\u003e\u003cspan style=\\\"text-decoration-line: underline; color: rgb(139, 87, 42); font-size: 24px; font-family: ios-Default-Regular; background-color: transparent; text-decoration-color: rgb(0, 0, 0);\\\"\u003eStri\u003cspan style=\\\"color: rgb(139, 87, 42); text-decoration-line: underline ; text-decoration-color: rgb(0, 0, 0); font-size: 24px; font-family: ios-Default-Regular; background-color: transparent;\\\"\u003engs\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cdiv\u003e\u003cspan style=\\\"font-size: 16px; font-family: ios-Default-Regular; text-decoration-color: rgb(0, 0, 0);\\\"\u003e\u003cspan style=\\\"text-decoration-line: underline; font-size: 16px; font-family: ios-Default-Regular; text-decoration-color: rgb(0, 0, 0);\\\"\u003e\u003cspan style=\\\"text-decoration-line: underline; text-decoration-color: rgb(0, 0, 0); font-size: 24px; font-family: ios-Default-Regular; background-color: rgb(189, 16, 224);\\\"\u003esecond\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cspan style=\\\"font-size: 16px; font-family: ios-Default-Regular; text-decoration-color: rgb(0, 0, 0);\\\"\u003e\u003cspan style=\\\"text-decoration-line: underline; font-size: 16px; font-family: ios-Default-Regular; text-decoration-color: rgb(0, 0, 0);\\\"\u003e\u003cspan style=\\\"text-decoration-line: underline; text-decoration-color: rgb(0, 0, 0); font-size: 16px; font-family: ios-Default-Regular; background-color: rgb(189, 16, 224); color: rgb(248, 231, 28);\\\"\u003eThird\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\";\n    var attributedStrings = createAttributedStrings(htmlSource);\n    textView.attributedText = attributedStrings.map(s =\u003e new AttributedString(propFactory(s)));\n```\n\n## Limitations \u0026 Rules\n\n1. If you want to write **newline** character, you can use these tags **\\\u003cbr\\\u003e**, **\\\u003cdiv\\\u003e** or use \"\\n\".\n    - \"attributed \\\u003cbr\\\u003e string\"\n    - \"attributed \\\u003cdiv\\\u003e string\\\u003c/div\\\u003e\"\n    - \"attributed \\n string\"\n\n\n2. You can use following html tags \n    - **br**     → newline\n    - **div**    → newline and general tag for styling\n    - **span**   → general tag for styling\n    - **font**   → has attribute as color(**color**), size(**font-size**) and face(**font-family**)\n    - **b**      → bold style\n    - **u**      → underline style\n    - **i**      → italic style \n    - **a**      → has attribute **href** for link.\n    - **s**      → line-through\n    - **strike** → line-through\n\n\n3. You can only use following css styles\n    - font.family-style      → **font-family** → ```\"font-family: Nunito-ExtraBold;\"```\n    - font.italic            → **font-style** → ```\"font-style: italic;\"```\n    - font.size              → **font-size** → ```\"font-size: 24px;\" (24pt, 24dp)```\n    - font.bold              → **font-weight** → ```\"font-weight: bold;\"```\n    - foregroundColor        → **color** → ```\"color: rgb(127, 125, 127);\"```\n    - backgroundColor        → **background-color** → ```\"background-color: rgb(255, 125, 127);\"```\n    - underline              → **text-decoration-line** → ```\"text-decoration-line: underline;\"```\n    - strikethrough          → **text-decoration-line** → ```\"text-decoration-line: line-through;\"```\n    - link                   → **href** → ```\"click \u003ca href=\\\"https://smartface.io\\\"\u003e here \u003c/a\u003e \"```\n    - ios.underlineColor     → **text-decoration-color** → ```\"text-decoration-color: rgba(255, 125, 128);\"```\n    - ios.strikethroughColor → **text-decoration-color** → ```\"text-decoration-color: rgba(24, 126, 168);\"```\n\n\n4. ⚠️ If you give **font-family** style, this style can overwrite **font-weight** and **font-style**.\n    - font-family: **Nunito-ExtraLightItalic**; → this overwrite **font-weight** as normal.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartface%2Fhtml-to-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartface%2Fhtml-to-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartface%2Fhtml-to-text/lists"}