Giter Club home page Giter Club logo

x-rayhtml's Introduction

X-rayHTML

A little something to help build documentation pages.

Instead of dropping in a block of markup to render as a demo, then copying and pasting it into a pre/code block, then escaping it—then going back and updating both the rendered code and the escaped code should something change: now you just wrap the code you’re rendering in a div and it generates a copy/pastable source snippet. Credit to @ugomobi for the original idea, which is in use on the jQuery Mobile docs.

Demos

Here’s the plugin in action.

The second demo uses the plugin’s “create” event (create.view-source by default, but configurable) to bolt on the Prism.js syntax highlighter, the third demo uses ZeroClipboard to add a quick “copy to clipboard” button, and the last demo uses both.

Getting Started

Download the production version or the development version, and the structural CSS.

In your page:

<script src="jquery.js"></script>
<script src="X-rayHTML.min.js"></script>

and

<link href="X-rayHTML.css" rel="stylesheet">

There are some config options up at the top of X-rayHTML.js:

var o = {
	pluginName: "view-source",
	text: {
		open: "View Source",
		close: "View Demo"
	},
	classes: {
		button: "btn btn-small",
		open: "view-source",
		sourcepanel: "source-panel"
	},
	initSelector: ".source"
}

By default, functionality is hooked to the class source. A pre/code block gets dropped into place, so whitespace inside of .source counts the same way. For example:

<div class="source"><aside>
	<blockquote>
		<p>It is the unofficial force—the Baker Street irregulars.</p>
	</blockquote>
	<address>Sherlock Holmes</address>
	<cite>Sign of Four</cite>
</aside></div>

x-rayhtml's People

Contributors

wilto avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.