Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="content">
	<h1>Making the <code>&lt;cite&gt;</code> tag sane</h1>
Simple citations is a script to generate a list of citations from citations within the the article. <cite data-source="https://webkit.org/blog/41/introducing-the-web-inspector/" data-date="01/16/06" data-title="Webkit.org - Introducing the Web Inspector"></cite> Each citation uses the under-utilized <code>&lt;cite&gt;&lt;cite&gt;</code> tag. <cite data-source="https://www.w3schools.com/tags/tag_cite.asp" data-title="w3schools - cite" data-date="10/10/18"></cite> <cite data-source="http://www.google.com" data-title="google.com" data-date="10/10/18"></cite> It can even detect duplicate citings as long as the URL is the same.<cite data-source="https://webkit.org/blog/41/introducing-the-web-inspector/" data-date="01/16/06" data-title="Webkit.org - Introducing the Web Inspector"></cite> Each <code>&lt;cite&gt;</code> tag requires a <code>data-date</code>, <code>data-title</code>, and <code>date-source</code>. Somewhere in the article you will a blank <code>&lt;div&gt;&lt;div&gt;</code> with an identifer (class or ID) for the list of sources to be stashed in. I realize there's far more robust plugins for this, but I wanted something light-weight and easy to manage.
	
<p>Filler text. In 1985 Aldus Corporation launched its first desktop publishing program Aldus PageMaker for Apple Macintosh computers, released in 1987 for PCs running Windows 1.0. Both contained the variant lorem ipsum most common today. Laura Perry, then art director with Aldus, modified prior versions of Lorem Ipsum text from typographical specimens; in the 1960s and 1970s it appeared often in lettering catalogs by Letraset. Anecdotal evidence has it that Letraset used Lorem ipsum already from 1970 onwards, eg. for grids (page layouts) for ad agencies. Many early desktop publishing programs, eg. Adobe PageMaker, used it to create template.

	<p>Do you like Cheese Whiz? Spray tan? Fake eyelashes? That's what is Lorem Ipsum to many—it rubs them the wrong way, all the way. It's unreal, uncanny, makes you wonder if something is wrong, it seems to seek your attention for all the wrong reasons. Usually, we prefer the real thing, wine without sulfur based preservatives, real butter, not margarine, and so we'd like our layouts and designs to be filled with real words, with thoughts that count, information that has value.
<p>The toppings you may chose for that TV dinner pizza slice when you forgot to shop for foods, the paint you may slap on your face to impress the new boss is your business. But what about your daily bread? Design comps, layouts, wireframes—will your clients accept that you go about things the facile way? Authorities in our business will tell in no uncertain terms that Lorem Ipsum is that huge, huge no no to forswear forever. Not so fast, I'd say, there are some redeeming factors in favor of greeking text, as its use is merely the symptom of a worse problem to take into consideration.

<p>You begin with a text, you sculpt information, you chisel away what's not needed, you come to the point, make things clear, add value, you're a content person, you like words. Design is no afterthought, far from it, but it comes in a deserved second. Anyway, you still use Lorem Ipsum and rightly so, as it will always have a place in the web workers toolbox, as things happen, not always the way you like it, not always in the preferred order. Even if your less into design and more into content strategy you may find some redeeming value with, wait for it, dummy copy, no less.


<div id="citations"></div>
</div>
              
            
!

CSS

              
                cite { font-size: 11px; padding-right: 3px;}
#citations {font-size: 11px; margin-top: 2em; 
	span { padding-right: 1em;} 
}
code { color: lightgreen}

//formatting
#content { max-width: 800px; margin-left: auto; margin-right: auto; margin-top: 3em; padding-left: 1em; padding-right: 1em;}
html {	background-color: #222;	color: #eee;	font-family: 'Noto Serif SC', serif;	line-height: 1.4em; 	padding-bottom: 1em;
	a {
		color: orange;
	}
	-webkit-font-smoothing: antialiased;	-moz-osx-font-smoothing: grayscale;
}
h1 { line-light: 1.3em}
              
            
!

JS

              
                let i = 0; // set the counter's starting point
let citeArray = [];

let citer = {
	init: (target) => {
		citer.createArray();
		citer.writeToDOM(target);
	},
	createArray: () => {
		$("cite").each( function() { //fat arrow make jQuery this goof
			i = i + 1; //citations do not start at 0 
			let newObj = {
				date :  $(this).data("date"),
				title: $(this).data("title"),
				source: $(this).data("source"),
				i: i
			}
			let duplicate = citer.checkDuplicates(newObj);
			if (duplicate === false) { //only push new instance if URL is different
					citeArray.push(newObj);
			}
		});
	},
	writeToDOM: (target) => {
		citeArray.forEach( (instance)  => {
			const subcite = `<a href="#cite${instance.i}">${instance.i}</a>`;
			const citation = `<a href="${instance.source}" id="cite${instance.i}">${instance.i} ${instance.title}</a>  <span>${instance.date}</span>`
			$(`[data-source="${instance.source}"]`).html(subcite);
			$(target).append(citation);
		});
	},
	checkDuplicates: (newObj) => {
    let duplicate = false;
		citeArray.forEach( (instance) => {
			if ( instance.source === newObj.source  ) {
				duplicate = true;
			}	
 	  });
		return duplicate;
	}
}
citer.init("#citations");
              
            
!
999px

Console