![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Smark 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.
Instead of this:
var myString = 'Click the following <a href="http://www.somewhere.com">link</a> to somewhere.';
You can just do it like this:
var myString = 'Click the following [link] (http://www.somewhere.com) to somewhere.';
Smark will parse string with just Youtube or Vimeo links into the embeded code for the respective service.
var youtubeLink = 'https://www.youtube.com/watch?v=tITwM5GDIAI';
var youtubeHTML = smark.generate(youtubeLink).html;
Most types of links from youtube and vimeo will work.
Strings with image links only will be parsed into <img> tags; Strings with Youtube or Vimeo links will be parsed into their respective embed code. Strings with links that are not Youtube or Vimeo links will be parsed into an iframe.
The rest will be treated as paragraphs and put between <p> 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.
Include smark.js or smark.min.js in your HTML file. Browserify compatibility is planned but not done yet (pull request is very welcomed!).
To use smark, use the generate()
function in the global smark object passing a string as argument.
var example = "Sample string.";
var foo = smark.generate(example);
The 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.
// An example with jQuery
var result = smark.generate("[jQuery] (http://www.jquery.com/)");
$("body").append(result);
// result will be <a src="http://www.jquery.com/">jQuery</a>
At 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.
(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.)
This 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:
Expected problems:
FAQs
Smart parser from strings into HTML
The npm package smark receives a total of 1 weekly downloads. As such, smark popularity was classified as not popular.
We found that smark demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.