Skip to content

Commit

Permalink
Browser files rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Mar 12, 2015
1 parent 17043b5 commit d43867e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 40 deletions.
62 changes: 24 additions & 38 deletions dist/markdown-it-abbr.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! markdown-it-abbr 0.1.0 https://github.com//markdown-it/markdown-it-abbr @license MIT */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.markdownitAbbr=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/*! markdown-it-abbr 1.0.0 https://github.com//markdown-it/markdown-it-abbr @license MIT */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitAbbr = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// Enclose abbreviations in <abbr> tags
//
'use strict';
Expand All @@ -9,14 +9,7 @@ var PUNCT_CHARS = ' \n()[]\'".,!?-';

module.exports = function sub_plugin(md) {
var escapeRE = md.utils.escapeRE,
arrayReplaceAt = md.utils.arrayReplaceAt,
replaceEntities = md.utils.replaceEntities,
escapeHtml = md.utils.replaceEntities;

md.renderer.rules.abbr_open = function abbr_open(tokens, idx) {
return '<abbr title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '">';
};
md.renderer.rules.abbr_close = function abbr_close() { return '</abbr>'; };
arrayReplaceAt = md.utils.arrayReplaceAt;


function abbr_def(state, startLine, endLine, silent) {
Expand Down Expand Up @@ -64,7 +57,8 @@ module.exports = function sub_plugin(md) {


function abbr_replace(state) {
var i, j, l, tokens, token, text, nodes, pos, level, reg, m, regText,
var i, j, l, tokens, token, text, nodes, pos, reg, m, regText,
currentToken,
blockTokens = state.tokens;

if (!state.env.abbreviations) { return; }
Expand All @@ -86,49 +80,41 @@ module.exports = function sub_plugin(md) {

// We scan from the end, to keep position when new tags added.
for (i = tokens.length - 1; i >= 0; i--) {
token = tokens[i];
if (token.type !== 'text') { continue; }
currentToken = tokens[i];
if (currentToken.type !== 'text') { continue; }

pos = 0;
text = token.content;
text = currentToken.content;
reg.lastIndex = 0;
level = token.level;
nodes = [];

while ((m = reg.exec(text))) {
if (reg.lastIndex > pos) {
nodes.push({
type: 'text',
content: text.slice(pos, m.index + m[1].length),
level: level
});
token = new state.Token('text', '', 0);
token.content = text.slice(pos, m.index + m[1].length);
nodes.push(token);
}

nodes.push({
type: 'abbr_open',
title: state.env.abbreviations[':' + m[2]],
level: level++
});
nodes.push({
type: 'text',
content: m[2],
level: level
});
nodes.push({
type: 'abbr_close',
level: --level
});
token = new state.Token('abbr_open', 'abbr', 1);
token.attrs = [ [ 'title', state.env.abbreviations[':' + m[2]] ] ];
nodes.push(token);

token = new state.Token('text', '', 0);
token.content = m[2];
nodes.push(token);

token = new state.Token('abbr_close', 'abbr', -1);
nodes.push(token);

pos = reg.lastIndex - m[3].length;
}

if (!nodes.length) { continue; }

if (pos < text.length) {
nodes.push({
type: 'text',
content: text.slice(pos),
level: level
});
token = new state.Token('text', '', 0);
token.content = text.slice(pos);
nodes.push(token);
}

// replace current node
Expand Down
4 changes: 2 additions & 2 deletions dist/markdown-it-abbr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d43867e

Please sign in to comment.