All Projects → ioquatix → Jquery Syntax

ioquatix / Jquery Syntax

Licence: mit
jQuery.Syntax is a light-weight client-side syntax highlighter.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jquery Syntax

Imagelightbox
Image Lightbox, Responsive and Touch‑friendly
Stars: ✭ 121 (-6.2%)
Mutual labels:  jquery
Bootstrap4 Website
Website built with bootstrap 4 Framework
Stars: ✭ 124 (-3.88%)
Mutual labels:  jquery
Jquery.applink
Launch native apps from web page links for mobile and desktop devices
Stars: ✭ 127 (-1.55%)
Mutual labels:  jquery
Water Monitoring System
Water Monitoring System is an IOT based Liquid Level Monitoring system that has mechanisms to keep the user alerted in case of liquid overflow or when tank depletes.
Stars: ✭ 122 (-5.43%)
Mutual labels:  jquery
Ct Material Kit Pro
Premium Bootstrap 4 UI Kit based on Google's Material Design
Stars: ✭ 123 (-4.65%)
Mutual labels:  jquery
Yowish.vim
A dark & yellowish vim colorscheme
Stars: ✭ 125 (-3.1%)
Mutual labels:  syntax-highlighting
Vim Gdscript3
Syntax highlighting and completion for GDScript 3
Stars: ✭ 121 (-6.2%)
Mutual labels:  syntax-highlighting
Involt
Inject hardware interactions directly into HTML layout.
Stars: ✭ 128 (-0.78%)
Mutual labels:  jquery
Charroom
PHP + Swoole 聊天室
Stars: ✭ 125 (-3.1%)
Mutual labels:  jquery
Sidebar
Sidebars for web apps
Stars: ✭ 127 (-1.55%)
Mutual labels:  jquery
Fotorama
A simple, stunning, powerful jQuery gallery.
Stars: ✭ 1,567 (+1114.73%)
Mutual labels:  jquery
Btabs
A jQuery plugin open pages in tab, based on Bootstrap2,3
Stars: ✭ 124 (-3.88%)
Mutual labels:  jquery
Midia
Simple Media manager for your Laravel project
Stars: ✭ 126 (-2.33%)
Mutual labels:  jquery
Femtojs
femtoJS - Really small JavaScript (ES6) library for DOM manipulation.
Stars: ✭ 122 (-5.43%)
Mutual labels:  jquery
Checkboxes.js
☑️ A jQuery plugin that gives you nice powers over your checkboxes.
Stars: ✭ 127 (-1.55%)
Mutual labels:  jquery
Xzoom
jQuery Zoom Gallery plugin
Stars: ✭ 120 (-6.98%)
Mutual labels:  jquery
Widget
A set of widgets based on jQuery&&javascript. 一套基于jquery或javascript的插件库 :轮播、标签页、滚动条、下拉框、对话框、搜索提示、城市选择(城市三级联动)、日历等
Stars: ✭ 1,579 (+1124.03%)
Mutual labels:  jquery
Frontend Hard Mode Interview
《前端内参》,有关于JavaScript、编程范式、设计模式、软件开发的艺术等大前端范畴内的知识分享,旨在帮助前端工程师们夯实技术基础以通过一线互联网企业技术面试。
Stars: ✭ 2,338 (+1712.4%)
Mutual labels:  jquery
Base App
An app to help jumpstart a new Rails 4 app. Features Ruby 2.0, PostgreSQL, jQuery, RSpec, Cucumber, user and admin system built with Devise, Facebook login.
Stars: ✭ 127 (-1.55%)
Mutual labels:  jquery
Thedesk
Mastodon/Misskey Client for PC.
Stars: ✭ 127 (-1.55%)
Mutual labels:  jquery

jQuery.Syntax

jQuery.Syntax is a light-weight client-side syntax highlighter, which dynamically loads external dependencies (JavaScript & CSS) when required. It uses jQuery to make it cross-browser compatible and to simplify integration and integration with other systems.

Motivation

jQuery.Syntax was built at a time when syntax highlighting on the web was a bit of a mess - browser incompatibilities and limitations made it hard to do the right thing consistently. Rather than a single definition of "good", presenting code nicely in a browser was dictated by a set of trade-offs.

At the time, syntax highlighters were often all-or-nothing - this made it cumbersome for sites that only had a few pages with code on them. jQuery.Syntax was designed from the ground up to use dynamic loading of assets when required. On top of that, the implementation was built using a profiler and is fairly efficient.

It's a good library and it's fast, that's why I continue to maintain and develop it.

Isn't jQuery big?

Your right, small is pretty subjective.

jQuery as a dependency is based on a design from 2012. When browsers were a bit less "compatible", this was a good trade-off. These days, it could probably be removed, but it isn't worth the effort and for me personally it's a zero-cost dependency since I use it anyway on most of my sites.

The library is modular and only loads exactly the CSS and JS required. The minimised and gzipped library is 1.6Kbytes, this provide the top-level API and the dynamic loading functionality.

To highlight anything, you need to load the core parser and renderer code. It's 4.1Kbytes minified and gzipped. The CSS and Script files are tiny, most less < 1Kbyte, per language.

Compared to xyz?

All syntax highlighters are pretty good these days. But, there are some key differences worth considering:

  • How much does it load by default, even when not highlighting anything?
  • How efficient/fast is it when highlighting code?
  • How does line wrapping work?
  • Can you embed <span> and <a> elements?
  • Can it handle embedded code (e.g. JavaScript inside HTML)?
  • Is it easy to install?
  • Is it easy to customize?

Installation

jQuery.Syntax is easily installed using bower.

$ bower install jquery-syntax

It has a dist/ directory which follows standard conventions.

Advanced Configuration

jQuery.Syntax compiles and minifies it's code using uses Rake (Ruby) and Sass. Please review the included Rakefile and install.yaml for more details.

Usage

jQuery.Syntax is typically used to highlight both block code elements and inline code elements. To highlight code, you first need to include several scripts in the <head> of your page:

<!-- Put in your head tag -->
<script src="jquery.min.js"></script>
<script src="jquery.syntax.min.js"></script>

<script type="text/javascript">
	// This function is executed when the page has finished loading.
	jQuery(function($) {
		$.syntax({theme: 'bright'});
	});
</script>

<!-- Your code to highlight -->
<pre><code class="language-ruby">puts "Hello World"</code></pre>

Stylesheet Compatibility

The following stylesheet sets some useful defaults and enables responsive tab-size indentation.

html {
	font-size: 16px;
	
	/* Fix odd text-size in `display: flex` elements on Safari iOS */
	text-size-adjust: 100%;
	-webkit-text-size-adjust: 100%;
}

@media (min-width: 40em) {
	html {
		font-size: 18px;
		--tab-size: 4;
	}
}

@media (min-width: 80em) {
	html {
		font-size: 20px;
		--tab-size: 4;
	}
}

pre {
	/* -moz-tab-size is still required by Firefox */
	--tab-size: 2;
	tab-size: var(--tab-size);
	-moz-tab-size: var(--tab-size);
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Released under the MIT license.

Copyright, 2011-2020, by Samuel G. D. Williams.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].