abcnews/spanify

Name: spanify

Owner: ABC News

Description: Wrap text in span tags directly from within CoreMedia + more

Created: 2017-12-19 01:13:23.0

Updated: 2018-01-02 06:32:56.0

Pushed: 2018-01-19 05:32:23.0

Homepage: null

Size: 24

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Spanify

This is just a helper for CoreMedia to turn anchor tags into spans.

In CoreMedia put 3 spaces before the text you want to wrap in a span tag. Then select the middle space with your mouse cursor then insert a link (right-click or format menu) then in the title field type the class name you want the span to have. Do the same after the text you want to wrap, highlighting the middle space character and link it with “end” in the title field.

npm install spanify it into your project, then const spanify = require("spanify").

And then call spanify.spanify() to scan the page for these anchor tags and replace them with spans.

Essentially this script scans the DOM for <a title="whatever"> </a> some text <a title="end"> </a> and converts to <span class="whatever">some text</span>

You can also specify a default class that will be added to the span in addition to any classes specified in CoreMedia by passing an object to the function like this spanify.spanify({ defaultClass: "default" }).

Hashify

Sometimes in CoreMedia we use #hashtag links. If you put a #hastag on its own line it turns into <a name="hashtag"> </a>. This is fine until you want to append content to this element. Any text inside this anchor tag will have link styles applied to it.

To workaround this we can use spanify.hashify() to scan the page for these anchor tags and replace them with <div class="whatever"></div>

You can also specify a default class that will be added to the div in addition to any classes specified in CoreMedia by passing an object to the function like this spanify.hashify({ defaultClass: "default" }).


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.