{"id":16861176,"url":"https://github.com/limzykenneth/smark","last_synced_at":"2025-03-18T14:46:27.184Z","repository":{"id":36945840,"uuid":"41253352","full_name":"limzykenneth/smark","owner":"limzykenneth","description":"Smark is a small function library built to parse Javascript strings into HTML markup.","archived":false,"fork":false,"pushed_at":"2016-11-24T14:19:37.000Z","size":66,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T11:45:29.664Z","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/limzykenneth.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":"2015-08-23T14:42:21.000Z","updated_at":"2016-03-22T21:30:06.000Z","dependencies_parsed_at":"2022-07-11T14:22:03.714Z","dependency_job_id":null,"html_url":"https://github.com/limzykenneth/smark","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/limzykenneth%2Fsmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limzykenneth%2Fsmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limzykenneth%2Fsmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limzykenneth%2Fsmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limzykenneth","download_url":"https://codeload.github.com/limzykenneth/smark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244245602,"owners_count":20422443,"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-13T14:29:49.936Z","updated_at":"2025-03-18T14:46:27.160Z","avatar_url":"https://github.com/limzykenneth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smark\n## A string to HTML parser\n\n[![Build Status](https://travis-ci.org/limzykenneth/smark.svg?branch=master)](https://travis-ci.org/limzykenneth/smark)\n\nSmark is a tiny function library built to parse Javascript strings into HTML markup. Thus, Smark is aimed at people looking to decouple strings from HTML markup so you don't need to have messy HTML markup in strings or even databases storing data for the page. Smark also do typographic changes so the punctuation is used correctly in paragraphs.\n\nInstead of this:\n\n```\nvar myString = 'Click the following \u003ca href=\"http://www.somewhere.com\"\u003elink\u003c/a\u003e to somewhere.';\n```\n\nYou can just do it like this:\n\n```\nvar myString = 'Click the following [link] (http://www.somewhere.com) to somewhere.';\n```\n\nSmark will parse string with just Youtube or Vimeo links into the embeded code for the respective service.\n\n```\nvar youtubeLink = 'https://www.youtube.com/watch?v=tITwM5GDIAI';\nvar youtubeHTML = smark.generate(youtubeLink).html;\n```\n\nMost types of links from youtube and vimeo will work.\n\n## Behaviours\n\nStrings with image links only will be parsed into \\\u003cimg\u003e tags;\nStrings with Youtube or Vimeo links will be parsed into their respective embed code.\nStrings with links that are not Youtube or Vimeo links will be parsed into an iframe.\n\nThe rest will be treated as paragraphs and put between \\\u003cp\u003e tags. If the string is identified as paragraphs, quote marks that should be “” instead of \"\" or ‘’ instead of '' will be replaced along with other typographic changes.\n\n## Usage\n\nInclude smark.js or smark.min.js in your HTML file. Browserify compatibility is planned but not done yet (pull request is very welcomed!).\n\nTo use smark, use the `generate()` function in the global smark object passing a string as argument.\n\n```\nvar example = \"Sample string.\";\nvar foo = smark.generate(example);\n```\n\nThe function will return an object with two properties: `type` and `html`. `type` is the type of the string passed in ie. youtube, vimeo, paragraph, etc. `html` is the parsed result of the string and can be inserted into the DOM as is.\n\n```\n// An example with jQuery\nvar result = smark.generate(\"[jQuery] (http://www.jquery.com/)\");\n$(\"body\").append(result);\n// result will be \u003ca src=\"http://www.jquery.com/\"\u003ejQuery\u003c/a\u003e\n```\n\nAt the moment you need to look at the source for for usage case since work on documentation is not done yet. The source is heavily comment though so hopefully it shouldn't be too hard to understand.\n\n\n(Note: I would consider smark to be in beta although it has pass 1.0 and I don't plan on releasing any breaking changes until 2.0. The point of it in beta is just because some features I planned might still be missing and the whole library can be more mature.)\n\n## Problems\n\nThis is mostly a note-to-self section. If you have problems using Smark, it might be listed down below, other than that might not be so useful. Some to dos:\n\n1. CLI use\n1. Documentation","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimzykenneth%2Fsmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimzykenneth%2Fsmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimzykenneth%2Fsmark/lists"}