first commit
This commit is contained in:
1351
libraries/framework/vendor/plugins/markdown/bootstrap-markdown.js
vendored
Normal file
1351
libraries/framework/vendor/plugins/markdown/bootstrap-markdown.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ar.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ar.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Arabic translation for bootstrap-markdown
|
||||
* George Ajam <george.ejaam@gmail.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.nl = {
|
||||
'Bold': "غامق",
|
||||
'Italic': "مائل",
|
||||
'Heading': "عنوان",
|
||||
'URL/Link': "URL/رابط",
|
||||
'Image': "صورة",
|
||||
'List': "قائمة",
|
||||
'Preview': "استعراض",
|
||||
'strong text': "نص غامق",
|
||||
'emphasized text': "نص هام",
|
||||
'heading text': "العنوان",
|
||||
'enter link description here': "ادخل وصف الرابط هنا",
|
||||
'Insert Hyperlink': "ادخل الرابط هنا",
|
||||
'enter image description here': "ادخل وصف الصورة هنا",
|
||||
'Insert Image Hyperlink': "ادخل رابط الصورة هنا",
|
||||
'enter image title here': "ادخل عنوان الصورة هنا",
|
||||
'list text here': "اكتب النص هنا"
|
||||
};
|
||||
}(jQuery));
|
||||
27
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.de.js
vendored
Normal file
27
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.de.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* German translation for bootstrap-markdown
|
||||
* Tobias Nitsche <tobias-nitsche@gmx.net>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.de = {
|
||||
'Bold': "Fett",
|
||||
'Italic': "Kursiv",
|
||||
'Heading': "Überschrift",
|
||||
'URL/Link': "Link hinzufügen",
|
||||
'Image': "Bild hinzufügen",
|
||||
'Unordered List': "Unnumerierte Liste",
|
||||
'Ordered List': "Numerierte Liste",
|
||||
'Code': "Quelltext",
|
||||
'Quote': "Zitat",
|
||||
'Preview': "Vorschau",
|
||||
'strong text': "Sehr betonter Text",
|
||||
'emphasized text': "Betonter Text",
|
||||
'heading text': "Überschrift Text",
|
||||
'enter link description here': "Linkbeschreibung",
|
||||
'Insert Hyperlink': "URL",
|
||||
'enter image description here': "Bildbeschreibung",
|
||||
'Insert Image Hyperlink': "Bild-URL",
|
||||
'enter image title here': "Titel des Bildes",
|
||||
'list text here': "Aufzählungs-Text"
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.es.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.es.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Spanish translation for bootstrap-markdown
|
||||
* by Leandro Poblet <leandrodrhouse@gmail.com>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.markdown.messages['es'] = {
|
||||
'Bold': "Negrita",
|
||||
'Italic': "Itálica",
|
||||
'Heading': "Título",
|
||||
'URL/Link': "Inserte un link",
|
||||
'Image': "Inserte una imagen",
|
||||
'List': "Lista de items",
|
||||
'Preview': "Previsualizar",
|
||||
'strong text': "texto importante",
|
||||
'emphasized text': "texto con énfasis",
|
||||
'heading text': "texto titular",
|
||||
'enter link description here': "descripción del link",
|
||||
'Insert Hyperlink': "Inserte un hipervínculo",
|
||||
'enter image description here': "descripción de la imagen",
|
||||
'Insert Image Hyperlink': "Inserte una imagen con un hipervínculo",
|
||||
'enter image title here': "Inserte una imagen con título",
|
||||
'list text here': "lista con texto"
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.fr.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.fr.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* French translation for bootstrap-markdown
|
||||
* Benoît Bourgeois <bierdok@gmail.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.fr = {
|
||||
'Bold': "Gras",
|
||||
'Italic': "Italique",
|
||||
'Heading': "Titre",
|
||||
'URL/Link': "Insérer un lien HTTP",
|
||||
'Image': "Insérer une image",
|
||||
'List': "Liste à puces",
|
||||
'Preview': "Prévisualiser",
|
||||
'strong text': "texte important",
|
||||
'emphasized text': "texte souligné",
|
||||
'heading text': "texte d'entête",
|
||||
'enter link description here': "entrez la description du lien ici",
|
||||
'Insert Hyperlink': "Insérez le lien hypertexte",
|
||||
'enter image description here': "entrez la description de l'image ici",
|
||||
'Insert Image Hyperlink': "Insérez le lien hypertexte de l'image",
|
||||
'enter image title here': "entrez le titre de l'image ici",
|
||||
'list text here': "texte à puce ici"
|
||||
};
|
||||
}(jQuery));
|
||||
29
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ja.js
vendored
Normal file
29
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ja.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Japanese translation for bootstrap-markdown
|
||||
* Kenta Murakami <kntmrkm@gmail.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages['ja'] = {
|
||||
'Bold': "太字",
|
||||
'Italic': "斜体",
|
||||
'Heading': "見出し",
|
||||
'URL/Link': "リンク",
|
||||
'Image': "画像",
|
||||
'Unordered List': "リスト",
|
||||
'Ordered List': "数字リスト",
|
||||
'Code': "コード",
|
||||
'Quote': "引用",
|
||||
'Preview': "プレビュー",
|
||||
'strong text': "太字",
|
||||
'emphasized text': "強調",
|
||||
'heading text': "見出し",
|
||||
'enter link description here': "リンク説明",
|
||||
'Insert Hyperlink': "リンク挿入",
|
||||
'enter image description here': "画像説明",
|
||||
'Insert Image Hyperlink': "画像挿入",
|
||||
'enter image title here': "画像タイトル",
|
||||
'list text here': "リスト挿入",
|
||||
'code text here': "コード",
|
||||
'quote here': "引用挿入"
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.kr.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.kr.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
+ * Korean translation for bootstrap-markdown
|
||||
+ * WoongBi Kim <ssinss@gmail.com>
|
||||
+ */
|
||||
;(function($){
|
||||
$.fn.markdown.messages['kr'] = {
|
||||
'Bold': "진하게",
|
||||
'Italic': "이탤릭체",
|
||||
'Heading': "머리글",
|
||||
'URL/Link': "링크주소",
|
||||
'Image': "이미지",
|
||||
'List': "리스트",
|
||||
'Preview': "미리보기",
|
||||
'strong text': "강한 강조 텍스트",
|
||||
'emphasized text': "강조 텍스트",
|
||||
'heading text': "머리글 텍스트",
|
||||
'enter link description here': "여기에 링크의 설명을 적으세요",
|
||||
'Insert Hyperlink': "하이퍼링크 삽입",
|
||||
'enter image description here': "여기세 이미지 설명을 적으세요",
|
||||
'Insert Image Hyperlink': "이미지 링크 삽입",
|
||||
'enter image title here': "여기에 이미지 제목을 적으세요",
|
||||
'list text here': "리스트 텍스트"
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.nb.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.nb.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Norwegian bokmål translation for bootstrap-markdown
|
||||
* Tobias Bohwalli <hi@futhr.io>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.nb = {
|
||||
'Bold': 'Fet',
|
||||
'Italic': 'Kursiv',
|
||||
'Heading': 'Overskrift',
|
||||
'URL/Link': 'URL/Lenke',
|
||||
'Image': 'Bilde',
|
||||
'List': 'Liste',
|
||||
'Preview': 'Forhåndsvisning',
|
||||
'strong text': 'sterk tekst',
|
||||
'emphasized text': 'streket tekst',
|
||||
'heading text': 'overskriften tekst',
|
||||
'enter link description here': 'Skriv linken beskrivelse her',
|
||||
'Insert Hyperlink': 'Sett inn lenke',
|
||||
'enter image description here': 'Angi bildebeskrivelse her',
|
||||
'Insert Image Hyperlink': 'Sett inn lenke for bilde',
|
||||
'enter image title here': 'Angi bildetittel her',
|
||||
'list text here': 'liste tekst her'
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.nl.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.nl.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Dutch translation for bootstrap-markdown
|
||||
* Jeroen Thora <jeroenthora@gmail.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.nl = {
|
||||
'Bold': "Vet",
|
||||
'Italic': "Cursief",
|
||||
'Heading': "Titel",
|
||||
'URL/Link': "URL/Link",
|
||||
'Image': "Afbeelding",
|
||||
'List': "Lijst",
|
||||
'Preview': "Voorbeeld",
|
||||
'strong text': "vet gedrukte tekst",
|
||||
'emphasized text': "schuin gedrukte tekst",
|
||||
'heading text': "Titel",
|
||||
'enter link description here': "Voer een link beschrijving in",
|
||||
'Insert Hyperlink': "Voer een http link in",
|
||||
'enter image description here': "Voer een afbeelding beschrijving in",
|
||||
'Insert Image Hyperlink': "Voer een afbeelding link in",
|
||||
'enter image title here': "Voer de afbeelding titel in",
|
||||
'list text here': "lijst item"
|
||||
};
|
||||
}(jQuery));
|
||||
27
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.pl.js
vendored
Normal file
27
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.pl.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Polish translation for bootstrap-markdown
|
||||
* Marek Kaput
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.pl = {
|
||||
'Bold': "Pogrubienie",
|
||||
'Italic': "Kursywa",
|
||||
'Heading': "Nagłówek",
|
||||
'URL/Link': "Wstaw link",
|
||||
'Image': "Wstaw obrazek",
|
||||
'Unordered List': "Lista punktowana",
|
||||
'Ordered List': "Lista numerowana",
|
||||
'Code': "Kod źródłowy",
|
||||
'Quote': "Cytat",
|
||||
'Preview': "Podgląd",
|
||||
'strong text': "pogrubiony tekst",
|
||||
'emphasized text': "pochylony tekst",
|
||||
'heading text': "nagłówek",
|
||||
'enter link description here': "opis linka",
|
||||
'Insert Hyperlink': "Wstaw link",
|
||||
'enter image description here': "opis obrazka",
|
||||
'Insert Image Hyperlink': "Wstaw obrazek",
|
||||
'enter image title here': "tytuł obrazka",
|
||||
'list text here': "lista"
|
||||
};
|
||||
}(jQuery));
|
||||
30
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ru.js
vendored
Normal file
30
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ru.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Russian translation for bootstrap-markdown
|
||||
* by Oleg Vivtash <o@vivtash.net>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.markdown.messages['ru'] = {
|
||||
'Bold': "Жирный",
|
||||
'strong text': "выделенный текст",
|
||||
'Italic': "Курсив",
|
||||
'emphasized text': "наклонный текст",
|
||||
'Heading': "Заголовок",
|
||||
'heading text': "текст заголовка",
|
||||
'URL/Link': "Вставьте ссылку",
|
||||
'Insert Hyperlink': "Введите гиперссылку",
|
||||
'enter link description here': "введите описание ссылки",
|
||||
'Image': "Изображение",
|
||||
'enter image description here': "Введите описание изображения",
|
||||
'Insert Image Hyperlink': "Вставьте ссылку на изображение",
|
||||
'enter image title here': "Введите название изображения",
|
||||
'List': "Список",
|
||||
'Unordered List': "Неупорядоченный список",
|
||||
'Ordered List': "Упорядоченный список",
|
||||
'list text here': "текст списка",
|
||||
'Code': "Код",
|
||||
'code text here': "программный код",
|
||||
'Quote': "Цитата",
|
||||
'quote here': "цитируемый текст",
|
||||
'Preview': "Предварительный просмотр"
|
||||
};
|
||||
}(jQuery))
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.sv.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.sv.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Swedish translation for bootstrap-markdown
|
||||
* Tobias Bohwalli <hi@futhr.io>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.sv = {
|
||||
'Bold': 'Fet',
|
||||
'Italic': 'Kursiv',
|
||||
'Heading': 'Rubrik',
|
||||
'URL/Link': 'URL/Länk',
|
||||
'Image': 'Bild',
|
||||
'List': 'Lista',
|
||||
'Preview': 'Förhandsgranska',
|
||||
'strong text': 'fet text',
|
||||
'emphasized text': 'överstruken text',
|
||||
'heading text': 'Rubrik',
|
||||
'enter link description here': 'Ange länk beskrivning här',
|
||||
'Insert Hyperlink': 'Sätt in länk',
|
||||
'enter image description here': 'Ange bild beskrivning här',
|
||||
'Insert Image Hyperlink': 'Sätt in länk för bild',
|
||||
'enter image title here': 'Ange bild rubrik här',
|
||||
'list text here': 'list text'
|
||||
};
|
||||
}(jQuery));
|
||||
31
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.tr.js
vendored
Normal file
31
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.tr.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Turkish translation for bootstrap-markdown
|
||||
* Serkan Algur <info@wpadami.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.tr = {
|
||||
'Bold': "Kalın",
|
||||
'Italic': "İtalik",
|
||||
'Heading': "Başlık",
|
||||
'URL/Link': "Link ekle",
|
||||
'Image': "Resim ekle",
|
||||
'List': "Liste Oluşturun",
|
||||
'Preview': "Önizleme",
|
||||
'strong text': "kalın yazı",
|
||||
'emphasized text': "italik yazı",
|
||||
'heading text': "Başlık Yazısı",
|
||||
'enter link description here': "Link açıklamasını buraya girin",
|
||||
'Insert Hyperlink': "İnternet adresi girin",
|
||||
'enter image description here': "resim açıklamasını buraya ekleyin",
|
||||
'Insert Image Hyperlink': "Resim linkini ekleyin",
|
||||
'enter image title here': "resim başlığını buraya ekleyin",
|
||||
'list text here': "liste yazısı",
|
||||
'Save' : "Kaydet",
|
||||
'Ordered List' : "Numaralı Liste",
|
||||
'Unordered List' : "Madde imli liste",
|
||||
'Quote' : "Alıntı",
|
||||
'quote here' : "alıntıyı buraya ekleyin",
|
||||
'Code' : "Kod",
|
||||
'code text here' : "kodu buraya ekleyin"
|
||||
};
|
||||
}(jQuery));
|
||||
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ua.js
vendored
Normal file
24
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.ua.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Ukrainian translation for bootstrap-markdown
|
||||
* by Oleg Vivtash <o@vivtash.net>
|
||||
*/
|
||||
;(function($){
|
||||
$.fn.markdown.messages['ua'] = {
|
||||
'Bold': "Жирний",
|
||||
'Italic': "Курсів",
|
||||
'Heading': "Заголовок",
|
||||
'URL/Link': "Вставте посилання",
|
||||
'Image': "Зображення",
|
||||
'List': "Список",
|
||||
'Preview': "Попередній перегляд",
|
||||
'strong text': "виділений текст",
|
||||
'emphasized text': "нахилений текст",
|
||||
'heading text': "текст заголовку",
|
||||
'enter link description here': "введіть опис посилання",
|
||||
'Insert Hyperlink': "Введіть гіперпосилання",
|
||||
'enter image description here': "Введіть опис зображення",
|
||||
'Insert Image Hyperlink': "Вставте посилання на зображення",
|
||||
'enter image title here': "Введіть назву зображення",
|
||||
'list text here': "текст списку"
|
||||
};
|
||||
}(jQuery))
|
||||
32
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.zh.js
vendored
Normal file
32
libraries/framework/vendor/plugins/markdown/locale/bootstrap-markdown.zh.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Chinese translation for bootstrap-markdown
|
||||
* benhaile <denghaier@163.com>
|
||||
*/
|
||||
(function ($) {
|
||||
$.fn.markdown.messages.zh = {
|
||||
'Bold': "粗体",
|
||||
'Italic': "斜体",
|
||||
'Heading': "标题",
|
||||
'URL/Link': "链接",
|
||||
'Image': "图片",
|
||||
'List': "列表",
|
||||
'Unordered List': "无序列表",
|
||||
'Ordered List': "有序列表",
|
||||
'Code': "代码",
|
||||
'Quote': "引用",
|
||||
'Preview': "预览",
|
||||
'strong text': "粗体",
|
||||
'emphasized text': "强调",
|
||||
'heading text': "标题",
|
||||
'enter link description here': "输入链接说明",
|
||||
'Insert Hyperlink': "URL地址",
|
||||
'enter image description here': "输入图片说明",
|
||||
'Insert Image Hyperlink': "图片URL地址",
|
||||
'enter image title here': "在这里输入图片标题",
|
||||
'list text here': "这里是列表文本",
|
||||
'code text here': "这里输入代码",
|
||||
'quote here': "这里输入引用文本"
|
||||
|
||||
|
||||
};
|
||||
}(jQuery));
|
||||
1616
libraries/framework/vendor/plugins/markdown/markdown.js
vendored
Normal file
1616
libraries/framework/vendor/plugins/markdown/markdown.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
184
libraries/framework/vendor/plugins/markdown/to-markdown.js
vendored
Normal file
184
libraries/framework/vendor/plugins/markdown/to-markdown.js
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* to-markdown - an HTML to Markdown converter
|
||||
*
|
||||
* Copyright 2011, Dom Christie
|
||||
* Licenced under the MIT licence
|
||||
*
|
||||
*/
|
||||
|
||||
var toMarkdown = function(string) {
|
||||
|
||||
var ELEMENTS = [
|
||||
{
|
||||
patterns: 'p',
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
return innerHTML ? '\n\n' + innerHTML + '\n' : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: 'br',
|
||||
type: 'void',
|
||||
replacement: '\n'
|
||||
},
|
||||
{
|
||||
patterns: 'h([1-6])',
|
||||
replacement: function(str, hLevel, attrs, innerHTML) {
|
||||
var hPrefix = '';
|
||||
for(var i = 0; i < hLevel; i++) {
|
||||
hPrefix += '#';
|
||||
}
|
||||
return '\n\n' + hPrefix + ' ' + innerHTML + '\n';
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: 'hr',
|
||||
type: 'void',
|
||||
replacement: '\n\n* * *\n'
|
||||
},
|
||||
{
|
||||
patterns: 'a',
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
var href = attrs.match(attrRegExp('href')),
|
||||
title = attrs.match(attrRegExp('title'));
|
||||
return href ? '[' + innerHTML + ']' + '(' + href[1] + (title && title[1] ? ' "' + title[1] + '"' : '') + ')' : str;
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: ['b', 'strong'],
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
return innerHTML ? '**' + innerHTML + '**' : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: ['i', 'em'],
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
return innerHTML ? '_' + innerHTML + '_' : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: 'code',
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
return innerHTML ? '`' + innerHTML + '`' : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
patterns: 'img',
|
||||
type: 'void',
|
||||
replacement: function(str, attrs, innerHTML) {
|
||||
var src = attrs.match(attrRegExp('src')),
|
||||
alt = attrs.match(attrRegExp('alt')),
|
||||
title = attrs.match(attrRegExp('title'));
|
||||
return '![' + (alt && alt[1] ? alt[1] : '') + ']' + '(' + src[1] + (title && title[1] ? ' "' + title[1] + '"' : '') + ')';
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
for(var i = 0, len = ELEMENTS.length; i < len; i++) {
|
||||
if(typeof ELEMENTS[i].patterns === 'string') {
|
||||
string = replaceEls(string, { tag: ELEMENTS[i].patterns, replacement: ELEMENTS[i].replacement, type: ELEMENTS[i].type });
|
||||
}
|
||||
else {
|
||||
for(var j = 0, pLen = ELEMENTS[i].patterns.length; j < pLen; j++) {
|
||||
string = replaceEls(string, { tag: ELEMENTS[i].patterns[j], replacement: ELEMENTS[i].replacement, type: ELEMENTS[i].type });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function replaceEls(html, elProperties) {
|
||||
var pattern = elProperties.type === 'void' ? '<' + elProperties.tag + '\\b([^>]*)\\/?>' : '<' + elProperties.tag + '\\b([^>]*)>([\\s\\S]*?)<\\/' + elProperties.tag + '>',
|
||||
regex = new RegExp(pattern, 'gi'),
|
||||
markdown = '';
|
||||
if(typeof elProperties.replacement === 'string') {
|
||||
markdown = html.replace(regex, elProperties.replacement);
|
||||
}
|
||||
else {
|
||||
markdown = html.replace(regex, function(str, p1, p2, p3) {
|
||||
return elProperties.replacement.call(this, str, p1, p2, p3);
|
||||
});
|
||||
}
|
||||
return markdown;
|
||||
}
|
||||
|
||||
function attrRegExp(attr) {
|
||||
return new RegExp(attr + '\\s*=\\s*["\']?([^"\']*)["\']?', 'i');
|
||||
}
|
||||
|
||||
// Pre code blocks
|
||||
|
||||
string = string.replace(/<pre\b[^>]*>`([\s\S]*)`<\/pre>/gi, function(str, innerHTML) {
|
||||
innerHTML = innerHTML.replace(/^\t+/g, ' '); // convert tabs to spaces (you know it makes sense)
|
||||
innerHTML = innerHTML.replace(/\n/g, '\n ');
|
||||
return '\n\n ' + innerHTML + '\n';
|
||||
});
|
||||
|
||||
// Lists
|
||||
|
||||
// Escape numbers that could trigger an ol
|
||||
// If there are more than three spaces before the code, it would be in a pre tag
|
||||
// Make sure we are escaping the period not matching any character
|
||||
string = string.replace(/^(\s{0,3}\d+)\. /g, '$1\\. ');
|
||||
|
||||
// Converts lists that have no child lists (of same type) first, then works it's way up
|
||||
var noChildrenRegex = /<(ul|ol)\b[^>]*>(?:(?!<ul|<ol)[\s\S])*?<\/\1>/gi;
|
||||
while(string.match(noChildrenRegex)) {
|
||||
string = string.replace(noChildrenRegex, function(str) {
|
||||
return replaceLists(str);
|
||||
});
|
||||
}
|
||||
|
||||
function replaceLists(html) {
|
||||
|
||||
html = html.replace(/<(ul|ol)\b[^>]*>([\s\S]*?)<\/\1>/gi, function(str, listType, innerHTML) {
|
||||
var lis = innerHTML.split('</li>');
|
||||
lis.splice(lis.length - 1, 1);
|
||||
|
||||
for(i = 0, len = lis.length; i < len; i++) {
|
||||
if(lis[i]) {
|
||||
var prefix = (listType === 'ol') ? (i + 1) + ". " : "* ";
|
||||
lis[i] = lis[i].replace(/\s*<li[^>]*>([\s\S]*)/i, function(str, innerHTML) {
|
||||
|
||||
innerHTML = innerHTML.replace(/^\s+/, '');
|
||||
innerHTML = innerHTML.replace(/\n\n/g, '\n\n ');
|
||||
// indent nested lists
|
||||
innerHTML = innerHTML.replace(/\n([ ]*)+(\*|\d+\.) /g, '\n$1 $2 ');
|
||||
return prefix + innerHTML;
|
||||
});
|
||||
}
|
||||
}
|
||||
return lis.join('\n');
|
||||
});
|
||||
return '\n\n' + html.replace(/[ \t]+\n|\s+$/g, '');
|
||||
}
|
||||
|
||||
// Blockquotes
|
||||
var deepest = /<blockquote\b[^>]*>((?:(?!<blockquote)[\s\S])*?)<\/blockquote>/gi;
|
||||
while(string.match(deepest)) {
|
||||
string = string.replace(deepest, function(str) {
|
||||
return replaceBlockquotes(str);
|
||||
});
|
||||
}
|
||||
|
||||
function replaceBlockquotes(html) {
|
||||
html = html.replace(/<blockquote\b[^>]*>([\s\S]*?)<\/blockquote>/gi, function(str, inner) {
|
||||
inner = inner.replace(/^\s+|\s+$/g, '');
|
||||
inner = cleanUp(inner);
|
||||
inner = inner.replace(/^/gm, '> ');
|
||||
inner = inner.replace(/^(>([ \t]{2,}>)+)/gm, '> >');
|
||||
return inner;
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
function cleanUp(string) {
|
||||
string = string.replace(/^[\t\r\n]+|[\t\r\n]+$/g, ''); // trim leading/trailing whitespace
|
||||
string = string.replace(/\n\s+\n/g, '\n\n');
|
||||
string = string.replace(/\n{3,}/g, '\n\n'); // limit consecutive linebreaks to 2
|
||||
return string;
|
||||
}
|
||||
|
||||
return cleanUp(string);
|
||||
};
|
||||
|
||||
if (typeof exports === 'object') {
|
||||
exports.toMarkdown = toMarkdown;
|
||||
}
|
||||
Reference in New Issue
Block a user