tags around block-level tags. + text = showdown.subParser('hashHTMLBlocks')(text, options, globals); + text = showdown.subParser('paragraphs')(text, options, globals); + + text = globals.converter._dispatch('blockGamut.after', text, options, globals); + + return text; +}); + +showdown.subParser('blockQuotes', function (text, options, globals) { + 'use strict'; + + text = globals.converter._dispatch('blockQuotes.before', text, options, globals); + /* + text = text.replace(/ + ( // Wrap whole match in $1 + ( + ^[ \t]*>[ \t]? // '>' at the start of a line + .+\n // rest of the first line + (.+\n)* // subsequent consecutive lines + \n* // blanks + )+ + ) + /gm, function(){...}); + */ + + text = text.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) { + var bq = m1; + + // attacklab: hack around Konqueror 3.5.4 bug: + // "----------bug".replace(/^-/g,"") == "bug" + bq = bq.replace(/^[ \t]*>[ \t]?/gm, '~0'); // trim one level of quoting + + // attacklab: clean up hack + bq = bq.replace(/~0/g, ''); + + bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines + bq = showdown.subParser('githubCodeBlocks')(bq, options, globals); + bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse + + bq = bq.replace(/(^|\n)/g, '$1 '); + // These leading spaces screw with
content, so we need to fix that:
+ bq = bq.replace(/(\s*[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) {
+ var pre = m1;
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ pre = pre.replace(/^ /mg, '~0');
+ pre = pre.replace(/~0/g, '');
+ return pre;
+ });
+
+ return showdown.subParser('hashBlock')('\n' + bq + '\n
', options, globals);
+ });
+
+ text = globals.converter._dispatch('blockQuotes.after', text, options, globals);
+ return text;
+});
+
+/**
+ * Process Markdown `` blocks.
+ */
+showdown.subParser('codeBlocks', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('codeBlocks.before', text, options, globals);
+ /*
+ text = text.replace(text,
+ /(?:\n\n|^)
+ ( // $1 = the code block -- one or more lines, starting with a space/tab
+ (?:
+ (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
+ .*\n+
+ )+
+ )
+ (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
+ /g,function(){...});
+ */
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += '~0';
+
+ var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
+ text = text.replace(pattern, function (wholeMatch, m1, m2) {
+ var codeblock = m1,
+ nextChar = m2,
+ end = '\n';
+
+ codeblock = showdown.subParser('outdent')(codeblock);
+ codeblock = showdown.subParser('encodeCode')(codeblock);
+ codeblock = showdown.subParser('detab')(codeblock);
+ codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines
+
+ if (options.omitExtraWLInCodeBlocks) {
+ end = '';
+ }
+
+ codeblock = '' + codeblock + end + '
';
+
+ return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
+ });
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/, '');
+
+ text = globals.converter._dispatch('codeBlocks.after', text, options, globals);
+ return text;
+});
+
+/**
+ *
+ * * Backtick quotes are used for spans.
+ *
+ * * You can use multiple backticks as the delimiters if you want to
+ * include literal backticks in the code span. So, this input:
+ *
+ * Just type ``foo `bar` baz`` at the prompt.
+ *
+ * Will translate to:
+ *
+ * Just type foo `bar` baz at the prompt.
+ *
+ * There's no arbitrary limit to the number of backticks you
+ * can use as delimters. If you need three consecutive backticks
+ * in your code, use four for delimiters, etc.
+ *
+ * * You can use spaces to get literal backticks at the edges:
+ *
+ * ... type `` `bar` `` ...
+ *
+ * Turns to:
+ *
+ * ... type `bar` ...
+ */
+showdown.subParser('codeSpans', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('codeSpans.before', text, options, globals);
+
+ /*
+ text = text.replace(/
+ (^|[^\\]) // Character before opening ` can't be a backslash
+ (`+) // $2 = Opening run of `
+ ( // $3 = The code block
+ [^\r]*?
+ [^`] // attacklab: work around lack of lookbehind
+ )
+ \2 // Matching closer
+ (?!`)
+ /gm, function(){...});
+ */
+
+ if (typeof(text) === 'undefined') {
+ text = '';
+ }
+ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
+ function (wholeMatch, m1, m2, m3) {
+ var c = m3;
+ c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
+ c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
+ c = showdown.subParser('encodeCode')(c);
+ return m1 + '' + c + '';
+ }
+ );
+
+ text = globals.converter._dispatch('codeSpans.after', text, options, globals);
+ return text;
+});
+
+/**
+ * Convert all tabs to spaces
+ */
+showdown.subParser('detab', function (text) {
+ 'use strict';
+
+ // expand first n-1 tabs
+ text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width
+
+ // replace the nth with two sentinels
+ text = text.replace(/\t/g, '~A~B');
+
+ // use the sentinel to anchor our regex so it doesn't explode
+ text = text.replace(/~B(.+?)~A/g, function (wholeMatch, m1) {
+ var leadingText = m1,
+ numSpaces = 4 - leadingText.length % 4; // g_tab_width
+
+ // there *must* be a better way to do this:
+ for (var i = 0; i < numSpaces; i++) {
+ leadingText += ' ';
+ }
+
+ return leadingText;
+ });
+
+ // clean up sentinels
+ text = text.replace(/~A/g, ' '); // g_tab_width
+ text = text.replace(/~B/g, '');
+
+ return text;
+
+});
+
+/**
+ * Smart processing for ampersands and angle brackets that need to be encoded.
+ */
+showdown.subParser('encodeAmpsAndAngles', function (text) {
+ 'use strict';
+ // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
+ // http://bumppo.net/projects/amputator/
+ text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&');
+
+ // Encode naked <'s
+ text = text.replace(/<(?![a-z\/?\$!])/gi, '<');
+
+ return text;
+});
+
+/**
+ * Returns the string, with after processing the following backslash escape sequences.
+ *
+ * attacklab: The polite way to do this is with the new escapeCharacters() function:
+ *
+ * text = escapeCharacters(text,"\\",true);
+ * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true);
+ *
+ * ...but we're sidestepping its use of the (slow) RegExp constructor
+ * as an optimization for Firefox. This function gets called a LOT.
+ */
+showdown.subParser('encodeBackslashEscapes', function (text) {
+ 'use strict';
+ text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback);
+ text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, showdown.helper.escapeCharactersCallback);
+ return text;
+});
+
+/**
+ * Encode/escape certain characters inside Markdown code runs.
+ * The point is that in code, these characters are literals,
+ * and lose their special Markdown meanings.
+ */
+showdown.subParser('encodeCode', function (text) {
+ 'use strict';
+
+ // Encode all ampersands; HTML entities are not
+ // entities within a Markdown code span.
+ text = text.replace(/&/g, '&');
+
+ // Do the angle bracket song and dance:
+ text = text.replace(//g, '>');
+
+ // Now, escape characters that are magic in Markdown:
+ text = showdown.helper.escapeCharacters(text, '*_{}[]\\', false);
+
+ // jj the line above breaks this:
+ //---
+ //* Item
+ // 1. Subitem
+ // special char: *
+ // ---
+
+ return text;
+});
+
+/**
+ * Input: an email address, e.g. "foo@example.com"
+ *
+ * Output: the email address as a mailto link, with each character
+ * of the address encoded as either a decimal or hex entity, in
+ * the hopes of foiling most address harvesting spam bots. E.g.:
+ *
+ * foo
+ * @example.com
+ *
+ * Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
+ * mailing list:
+ *
+ */
+showdown.subParser('encodeEmailAddress', function (addr) {
+ 'use strict';
+
+ var encode = [
+ function (ch) {
+ return '' + ch.charCodeAt(0) + ';';
+ },
+ function (ch) {
+ return '' + ch.charCodeAt(0).toString(16) + ';';
+ },
+ function (ch) {
+ return ch;
+ }
+ ];
+
+ addr = 'mailto:' + addr;
+
+ addr = addr.replace(/./g, function (ch) {
+ if (ch === '@') {
+ // this *must* be encoded. I insist.
+ ch = encode[Math.floor(Math.random() * 2)](ch);
+ } else if (ch !== ':') {
+ // leave ':' alone (to spot mailto: later)
+ var r = Math.random();
+ // roughly 10% raw, 45% hex, 45% dec
+ ch = (
+ r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch)
+ );
+ }
+ return ch;
+ });
+
+ addr = '' + addr + '';
+ addr = addr.replace(/">.+:/g, '">'); // strip the mailto: from the visible part
+
+ return addr;
+});
+
+/**
+ * Within tags -- meaning between < and > -- encode [\ ` * _] so they
+ * don't conflict with their use in Markdown for code, italics and strong.
+ */
+showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text) {
+ 'use strict';
+
+ // Build a regex to find HTML tags and comments. See Friedl's
+ // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
+ var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;
+
+ text = text.replace(regex, function (wholeMatch) {
+ var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, '$1`');
+ tag = showdown.helper.escapeCharacters(tag, '\\`*_', false);
+ return tag;
+ });
+
+ return text;
+});
+
+/**
+ * Handle github codeblocks prior to running HashHTML so that
+ * HTML contained within the codeblock gets escaped properly
+ * Example:
+ * ```ruby
+ * def hello_world(x)
+ * puts "Hello, #{x}"
+ * end
+ * ```
+ */
+showdown.subParser('githubCodeBlocks', function (text, options, globals) {
+ 'use strict';
+
+ // early exit if option is not enabled
+ if (!options.ghCodeBlocks) {
+ return text;
+ }
+
+ text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals);
+
+ text += '~0';
+
+ text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, language, codeblock) {
+ var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n';
+
+ // First parse the github code block
+ codeblock = showdown.subParser('encodeCode')(codeblock);
+ codeblock = showdown.subParser('detab')(codeblock);
+ codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
+ codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
+
+ codeblock = '' + codeblock + end + '
';
+
+ codeblock = showdown.subParser('hashBlock')(codeblock, options, globals);
+
+ // Since GHCodeblocks can be false positives, we need to
+ // store the primitive text and the parsed text in a global var,
+ // and then return a token
+ return '\n\n~G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
+ });
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/, '');
+
+ return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals);
+});
+
+showdown.subParser('hashBlock', function (text, options, globals) {
+ 'use strict';
+ text = text.replace(/(^\n+|\n+$)/g, '');
+ return '\n\n~K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n';
+});
+
+showdown.subParser('hashElement', function (text, options, globals) {
+ 'use strict';
+
+ return function (wholeMatch, m1) {
+ var blockText = m1;
+
+ // Undo double lines
+ blockText = blockText.replace(/\n\n/g, '\n');
+ blockText = blockText.replace(/^\n/, '');
+
+ // strip trailing blank lines
+ blockText = blockText.replace(/\n+$/g, '');
+
+ // Replace the element text with a marker ("~KxK" where x is its key)
+ blockText = '\n\n~K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n';
+
+ return blockText;
+ };
+});
+
+showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
+ 'use strict';
+
+ var blockTags = [
+ 'pre',
+ 'div',
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6',
+ 'blockquote',
+ 'table',
+ 'dl',
+ 'ol',
+ 'ul',
+ 'script',
+ 'noscript',
+ 'form',
+ 'fieldset',
+ 'iframe',
+ 'math',
+ 'style',
+ 'section',
+ 'header',
+ 'footer',
+ 'nav',
+ 'article',
+ 'aside',
+ 'address',
+ 'audio',
+ 'canvas',
+ 'figure',
+ 'hgroup',
+ 'output',
+ 'video',
+ 'p'
+ ],
+ repFunc = function (wholeMatch, match, left, right) {
+ var txt = wholeMatch;
+ // check if this html element is marked as markdown
+ // if so, it's contents should be parsed as markdown
+ if (left.search(/\bmarkdown\b/) !== -1) {
+ txt = left + globals.converter.makeHtml(match) + right;
+ }
+ return '\n\n~K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
+ };
+
+ for (var i = 0; i < blockTags.length; ++i) {
+ text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}<' + blockTags[i] + '\\b[^>]*>', '' + blockTags[i] + '>', 'gim');
+ }
+
+ // HR SPECIAL CASE
+ text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,
+ showdown.subParser('hashElement')(text, options, globals));
+
+ // Special case for standalone HTML comments:
+ text = text.replace(/()/g,
+ showdown.subParser('hashElement')(text, options, globals));
+
+ // PHP and ASP-style processor instructions (...?> and <%...%>)
+ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,
+ showdown.subParser('hashElement')(text, options, globals));
+ return text;
+});
+
+/**
+ * Hash span elements that should not be parsed as markdown
+ */
+showdown.subParser('hashHTMLSpans', function (text, config, globals) {
+ 'use strict';
+
+ var matches = showdown.helper.matchRecursiveRegExp(text, ']*>', '', 'gi');
+
+ for (var i = 0; i < matches.length; ++i) {
+ text = text.replace(matches[i][0], '~L' + (globals.gHtmlSpans.push(matches[i][0]) - 1) + 'L');
+ }
+ return text;
+});
+
+/**
+ * Unhash HTML spans
+ */
+showdown.subParser('unhashHTMLSpans', function (text, config, globals) {
+ 'use strict';
+
+ for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
+ text = text.replace('~L' + i + 'L', globals.gHtmlSpans[i]);
+ }
+
+ return text;
+});
+
+/**
+ * Hash span elements that should not be parsed as markdown
+ */
+showdown.subParser('hashPreCodeTags', function (text, config, globals) {
+ 'use strict';
+
+ var repFunc = function (wholeMatch, match, left, right) {
+ // encode html entities
+ var codeblock = left + showdown.subParser('encodeCode')(match) + right;
+ return '\n\n~G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n';
+ };
+
+ text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^(?: |\\t){0,3}]*>\\s*]*>', '^(?: |\\t){0,3}\\s*
', 'gim');
+ return text;
+});
+
+showdown.subParser('headers', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('headers.before', text, options, globals);
+
+ var prefixHeader = options.prefixHeaderId,
+ headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart),
+
+ // Set text-style headers:
+ // Header 1
+ // ========
+ //
+ // Header 2
+ // --------
+ //
+ setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm,
+ setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
+
+ text = text.replace(setextRegexH1, function (wholeMatch, m1) {
+
+ var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+ hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
+ hLevel = headerLevelStart,
+ hashBlock = '' + spanGamut + ' ';
+ return showdown.subParser('hashBlock')(hashBlock, options, globals);
+ });
+
+ text = text.replace(setextRegexH2, function (matchFound, m1) {
+ var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
+ hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
+ hLevel = headerLevelStart + 1,
+ hashBlock = '' + spanGamut + ' ';
+ return showdown.subParser('hashBlock')(hashBlock, options, globals);
+ });
+
+ // atx-style headers:
+ // # Header 1
+ // ## Header 2
+ // ## Header 2 with closing hashes ##
+ // ...
+ // ###### Header 6
+ //
+ text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
+ var span = showdown.subParser('spanGamut')(m2, options, globals),
+ hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
+ hLevel = headerLevelStart - 1 + m1.length,
+ header = '' + span + ' ';
+
+ return showdown.subParser('hashBlock')(header, options, globals);
+ });
+
+ function headerId(m) {
+ var title, escapedId = m.replace(/[^\w]/g, '').toLowerCase();
+
+ if (globals.hashLinkCounts[escapedId]) {
+ title = escapedId + '-' + (globals.hashLinkCounts[escapedId]++);
+ } else {
+ title = escapedId;
+ globals.hashLinkCounts[escapedId] = 1;
+ }
+
+ // Prefix id to prevent causing inadvertent pre-existing style matches.
+ if (prefixHeader === true) {
+ prefixHeader = 'section';
+ }
+
+ if (showdown.helper.isString(prefixHeader)) {
+ return prefixHeader + title;
+ }
+ return title;
+ }
+
+ text = globals.converter._dispatch('headers.after', text, options, globals);
+ return text;
+});
+
+/**
+ * Turn Markdown image shortcuts into
tags.
+ */
+showdown.subParser('images', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('images.before', text, options, globals);
+
+ var inlineRegExp = /!\[(.*?)]\s?\([ \t]*()(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,
+ referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[(.*?)]()()()()()/g;
+
+ function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) {
+
+ var gUrls = globals.gUrls,
+ gTitles = globals.gTitles,
+ gDims = globals.gDimensions;
+
+ linkId = linkId.toLowerCase();
+
+ if (!title) {
+ title = '';
+ }
+
+ if (url === '' || url === null) {
+ if (linkId === '' || linkId === null) {
+ // lower-case and turn embedded newlines into spaces
+ linkId = altText.toLowerCase().replace(/ ?\n/g, ' ');
+ }
+ url = '#' + linkId;
+
+ if (!showdown.helper.isUndefined(gUrls[linkId])) {
+ url = gUrls[linkId];
+ if (!showdown.helper.isUndefined(gTitles[linkId])) {
+ title = gTitles[linkId];
+ }
+ if (!showdown.helper.isUndefined(gDims[linkId])) {
+ width = gDims[linkId].width;
+ height = gDims[linkId].height;
+ }
+ } else {
+ return wholeMatch;
+ }
+ }
+
+ altText = altText.replace(/"/g, '"');
+ altText = showdown.helper.escapeCharacters(altText, '*_', false);
+ url = showdown.helper.escapeCharacters(url, '*_', false);
+ var result = '
';
+ return result;
+ }
+
+ // First, handle reference-style labeled images: ![alt text][id]
+ text = text.replace(referenceRegExp, writeImageTag);
+
+ // Next, handle inline images: 
+ text = text.replace(inlineRegExp, writeImageTag);
+
+ text = globals.converter._dispatch('images.after', text, options, globals);
+ return text;
+});
+
+showdown.subParser('italicsAndBold', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('italicsAndBold.before', text, options, globals);
+
+ if (options.literalMidWordUnderscores) {
+ //underscores
+ // Since we are consuming a \s character, we need to add it
+ text = text.replace(/(^|\s|>|\b)__(?=\S)([\s\S]+?)__(?=\b|<|\s|$)/gm, '$1$2');
+ text = text.replace(/(^|\s|>|\b)_(?=\S)([\s\S]+?)_(?=\b|<|\s|$)/gm, '$1$2');
+ //asterisks
+ text = text.replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g, '$2');
+ text = text.replace(/(\*)(?=\S)([^\r]*?\S)\1/g, '$2');
+
+ } else {
+ // must go first:
+ text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '$2');
+ text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '$2');
+ }
+
+ text = globals.converter._dispatch('italicsAndBold.after', text, options, globals);
+ return text;
+});
+
+/**
+ * Form HTML ordered (numbered) and unordered (bulleted) lists.
+ */
+showdown.subParser('lists', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('lists.before', text, options, globals);
+ /**
+ * Process the contents of a single ordered or unordered list, splitting it
+ * into individual list items.
+ * @param {string} listStr
+ * @param {boolean} trimTrailing
+ * @returns {string}
+ */
+ function processListItems (listStr, trimTrailing) {
+ // The $g_list_level global keeps track of when we're inside a list.
+ // Each time we enter a list, we increment it; when we leave a list,
+ // we decrement. If it's zero, we're not in a list anymore.
+ //
+ // We do this because when we're not inside a list, we want to treat
+ // something like this:
+ //
+ // I recommend upgrading to version
+ // 8. Oops, now this line is treated
+ // as a sub-list.
+ //
+ // As a single paragraph, despite the fact that the second line starts
+ // with a digit-period-space sequence.
+ //
+ // Whereas when we're inside a list (or sub-list), that line will be
+ // treated as the start of a sub-list. What a kludge, huh? This is
+ // an aspect of Markdown's syntax that's hard to parse perfectly
+ // without resorting to mind-reading. Perhaps the solution is to
+ // change the syntax rules such that sub-lists must start with a
+ // starting cardinal number; e.g. "1." or "a.".
+ globals.gListLevel++;
+
+ // trim trailing blank lines:
+ listStr = listStr.replace(/\n{2,}$/, '\n');
+
+ // attacklab: add sentinel to emulate \z
+ listStr += '~0';
+
+ var rgx = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,
+ isParagraphed = (/\n[ \t]*\n(?!~0)/.test(listStr));
+
+ listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
+ checked = (checked && checked.trim() !== '');
+ var item = showdown.subParser('outdent')(m4, options, globals),
+ bulletStyle = '';
+
+ // Support for github tasklists
+ if (taskbtn && options.tasklists) {
+ bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
+ item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () {
+ var otp = '';
+ return otp;
+ });
+ }
+ // m1 - Leading line or
+ // Has a double return (multi paragraph) or
+ // Has sublist
+ if (m1 || (item.search(/\n{2,}/) > -1)) {
+ item = showdown.subParser('githubCodeBlocks')(item, options, globals);
+ item = showdown.subParser('blockGamut')(item, options, globals);
+ } else {
+ // Recursion for sub-lists:
+ item = showdown.subParser('lists')(item, options, globals);
+ item = item.replace(/\n$/, ''); // chomp(item)
+ if (isParagraphed) {
+ item = showdown.subParser('paragraphs')(item, options, globals);
+ } else {
+ item = showdown.subParser('spanGamut')(item, options, globals);
+ }
+ }
+ item = '\n' + item + ' \n';
+ return item;
+ });
+
+ // attacklab: strip sentinel
+ listStr = listStr.replace(/~0/g, '');
+
+ globals.gListLevel--;
+
+ if (trimTrailing) {
+ listStr = listStr.replace(/\s+$/, '');
+ }
+
+ return listStr;
+ }
+
+ /**
+ * Check and parse consecutive lists (better fix for issue #142)
+ * @param {string} list
+ * @param {string} listType
+ * @param {boolean} trimTrailing
+ * @returns {string}
+ */
+ function parseConsecutiveLists(list, listType, trimTrailing) {
+ // check if we caught 2 or more consecutive lists by mistake
+ // we use the counterRgx, meaning if listType is UL we look for UL and vice versa
+ var counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm,
+ subLists = [],
+ result = '';
+
+ if (list.search(counterRxg) !== -1) {
+ (function parseCL(txt) {
+ var pos = txt.search(counterRxg);
+ if (pos !== -1) {
+ // slice
+ result += '\n\n<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '' + listType + '>\n\n';
+
+ // invert counterType and listType
+ listType = (listType === 'ul') ? 'ol' : 'ul';
+ counterRxg = (listType === 'ul') ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm;
+
+ //recurse
+ parseCL(txt.slice(pos));
+ } else {
+ result += '\n\n<' + listType + '>' + processListItems(txt, !!trimTrailing) + '' + listType + '>\n\n';
+ }
+ })(list);
+ for (var i = 0; i < subLists.length; ++i) {
+
+ }
+ } else {
+ result = '\n\n<' + listType + '>' + processListItems(list, !!trimTrailing) + '' + listType + '>\n\n';
+ }
+
+ return result;
+ }
+
+ // attacklab: add sentinel to hack around khtml/safari bug:
+ // http://bugs.webkit.org/show_bug.cgi?id=11231
+ text += '~0';
+
+ // Re-usable pattern to match any entire ul or ol list:
+ var wholeList = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+
+ if (globals.gListLevel) {
+ text = text.replace(wholeList, function (wholeMatch, list, m2) {
+ var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
+ return parseConsecutiveLists(list, listType, true);
+ });
+ } else {
+ wholeList = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+ //wholeList = /(\n\n|^\n?)( {0,3}([*+-]|\d+\.)[ \t]+[\s\S]+?)(?=(~0)|(\n\n(?!\t| {2,}| {0,3}([*+-]|\d+\.)[ \t])))/g;
+ text = text.replace(wholeList, function (wholeMatch, m1, list, m3) {
+
+ var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
+ return parseConsecutiveLists(list, listType);
+ });
+ }
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/, '');
+
+ text = globals.converter._dispatch('lists.after', text, options, globals);
+ return text;
+});
+
+/**
+ * Remove one level of line-leading tabs or spaces
+ */
+showdown.subParser('outdent', function (text) {
+ 'use strict';
+
+ // attacklab: hack around Konqueror 3.5.4 bug:
+ // "----------bug".replace(/^-/g,"") == "bug"
+ text = text.replace(/^(\t|[ ]{1,4})/gm, '~0'); // attacklab: g_tab_width
+
+ // attacklab: clean up hack
+ text = text.replace(/~0/g, '');
+
+ return text;
+});
+
+/**
+ *
+ */
+showdown.subParser('paragraphs', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('paragraphs.before', text, options, globals);
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g, '');
+ text = text.replace(/\n+$/g, '');
+
+ var grafs = text.split(/\n{2,}/g),
+ grafsOut = [],
+ end = grafs.length; // Wrap tags
+
+ for (var i = 0; i < end; i++) {
+ var str = grafs[i];
+ // if this is an HTML marker, copy it
+ if (str.search(/~(K|G)(\d+)\1/g) >= 0) {
+ grafsOut.push(str);
+ } else {
+ str = showdown.subParser('spanGamut')(str, options, globals);
+ str = str.replace(/^([ \t]*)/g, '
');
+ str += '
';
+ grafsOut.push(str);
+ }
+ }
+
+ /** Unhashify HTML blocks */
+ end = grafsOut.length;
+ for (i = 0; i < end; i++) {
+ var blockText = '',
+ grafsOutIt = grafsOut[i],
+ codeFlag = false;
+ // if this is a marker for an html block...
+ while (grafsOutIt.search(/~(K|G)(\d+)\1/) >= 0) {
+ var delim = RegExp.$1,
+ num = RegExp.$2;
+
+ if (delim === 'K') {
+ blockText = globals.gHtmlBlocks[num];
+ } else {
+ // we need to check if ghBlock is a false positive
+ if (codeFlag) {
+ // use encoded version of all text
+ blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text);
+ } else {
+ blockText = globals.ghCodeBlocks[num].codeblock;
+ }
+ }
+ blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs
+
+ grafsOutIt = grafsOutIt.replace(/(\n\n)?~(K|G)\d+\2(\n\n)?/, blockText);
+ // Check if grafsOutIt is a pre->code
+ if (/^]*>\s*]*>/.test(grafsOutIt)) {
+ codeFlag = true;
+ }
+ }
+ grafsOut[i] = grafsOutIt;
+ }
+ text = grafsOut.join('\n\n');
+ // Strip leading and trailing lines:
+ text = text.replace(/^\n+/g, '');
+ text = text.replace(/\n+$/g, '');
+ return globals.converter._dispatch('paragraphs.after', text, options, globals);
+});
+
+/**
+ * Run extension
+ */
+showdown.subParser('runExtension', function (ext, text, options, globals) {
+ 'use strict';
+
+ if (ext.filter) {
+ text = ext.filter(text, globals.converter, options);
+
+ } else if (ext.regex) {
+ // TODO remove this when old extension loading mechanism is deprecated
+ var re = ext.regex;
+ if (!re instanceof RegExp) {
+ re = new RegExp(re, 'g');
+ }
+ text = text.replace(re, ext.replace);
+ }
+
+ return text;
+});
+
+/**
+ * These are all the transformations that occur *within* block-level
+ * tags like paragraphs, headers, and list items.
+ */
+showdown.subParser('spanGamut', function (text, options, globals) {
+ 'use strict';
+
+ text = globals.converter._dispatch('spanGamut.before', text, options, globals);
+ text = showdown.subParser('codeSpans')(text, options, globals);
+ text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals);
+ text = showdown.subParser('encodeBackslashEscapes')(text, options, globals);
+
+ // Process anchor and image tags. Images must come first,
+ // because ![foo][f] looks like an anchor.
+ text = showdown.subParser('images')(text, options, globals);
+ text = showdown.subParser('anchors')(text, options, globals);
+
+ // Make links out of things like ` `
+ // Must come after _DoAnchors(), because you can use < and >
+ // delimiters in inline links like [this]().
+ text = showdown.subParser('autoLinks')(text, options, globals);
+ text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals);
+ text = showdown.subParser('italicsAndBold')(text, options, globals);
+ text = showdown.subParser('strikethrough')(text, options, globals);
+
+ // Do hard breaks:
+ text = text.replace(/ +\n/g, '
\n');
+
+ text = globals.converter._dispatch('spanGamut.after', text, options, globals);
+ return text;
+});
+
+showdown.subParser('strikethrough', function (text, options, globals) {
+ 'use strict';
+
+ if (options.strikethrough) {
+ text = globals.converter._dispatch('strikethrough.before', text, options, globals);
+ text = text.replace(/(?:~T){2}([\s\S]+?)(?:~T){2}/g, '$1');
+ text = globals.converter._dispatch('strikethrough.after', text, options, globals);
+ }
+
+ return text;
+});
+
+/**
+ * Strip any lines consisting only of spaces and tabs.
+ * This makes subsequent regexs easier to write, because we can
+ * match consecutive blank lines with /\n+/ instead of something
+ * contorted like /[ \t]*\n+/
+ */
+showdown.subParser('stripBlankLines', function (text) {
+ 'use strict';
+ return text.replace(/^[ \t]+$/mg, '');
+});
+
+/**
+ * Strips link definitions from text, stores the URLs and titles in
+ * hash references.
+ * Link defs are in the form: ^[id]: url "optional title"
+ *
+ * ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1
+ * [ \t]*
+ * \n? // maybe *one* newline
+ * [ \t]*
+ * (\S+?)>? // url = $2
+ * [ \t]*
+ * \n? // maybe one newline
+ * [ \t]*
+ * (?:
+ * (\n*) // any lines skipped = $3 attacklab: lookbehind removed
+ * ["(]
+ * (.+?) // title = $4
+ * [")]
+ * [ \t]*
+ * )? // title is optional
+ * (?:\n+|$)
+ * /gm,
+ * function(){...});
+ *
+ */
+showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
+ 'use strict';
+
+ var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=~0))/gm;
+
+ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
+ text += '~0';
+
+ text = text.replace(regex, function (wholeMatch, linkId, url, width, height, blankLines, title) {
+ linkId = linkId.toLowerCase();
+ globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url); // Link IDs are case-insensitive
+
+ if (blankLines) {
+ // Oops, found blank lines, so it's not a title.
+ // Put back the parenthetical statement we stole.
+ return blankLines + title;
+
+ } else {
+ if (title) {
+ globals.gTitles[linkId] = title.replace(/"|'/g, '"');
+ }
+ if (options.parseImgDimensions && width && height) {
+ globals.gDimensions[linkId] = {
+ width: width,
+ height: height
+ };
+ }
+ }
+ // Completely remove the definition from the text
+ return '';
+ });
+
+ // attacklab: strip sentinel
+ text = text.replace(/~0/, '');
+
+ return text;
+});
+
+showdown.subParser('tables', function (text, options, globals) {
+ 'use strict';
+
+ if (!options.tables) {
+ return text;
+ }
+
+ var tableRgx = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|~0)/gm;
+
+ function parseStyles(sLine) {
+ if (/^:[ \t]*--*$/.test(sLine)) {
+ return ' style="text-align:left;"';
+ } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
+ return ' style="text-align:right;"';
+ } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
+ return ' style="text-align:center;"';
+ } else {
+ return '';
+ }
+ }
+
+ function parseHeaders(header, style) {
+ var id = '';
+ header = header.trim();
+ if (options.tableHeaderId) {
+ id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"';
+ }
+ header = showdown.subParser('spanGamut')(header, options, globals);
+
+ return '' + header + ' \n';
+ }
+
+ function parseCells(cell, style) {
+ var subText = showdown.subParser('spanGamut')(cell, options, globals);
+ return '' + subText + ' \n';
+ }
+
+ function buildTable(headers, cells) {
+ var tb = '\n\n\n',
+ tblLgn = headers.length;
+
+ for (var i = 0; i < tblLgn; ++i) {
+ tb += headers[i];
+ }
+ tb += ' \n\n\n';
+
+ for (i = 0; i < cells.length; ++i) {
+ tb += '\n';
+ for (var ii = 0; ii < tblLgn; ++ii) {
+ tb += cells[i][ii];
+ }
+ tb += ' \n';
+ }
+ tb += '\n
\n';
+ return tb;
+ }
+
+ text = globals.converter._dispatch('tables.before', text, options, globals);
+
+ text = text.replace(tableRgx, function (rawTable) {
+
+ var i, tableLines = rawTable.split('\n');
+
+ // strip wrong first and last column if wrapped tables are used
+ for (i = 0; i < tableLines.length; ++i) {
+ if (/^[ \t]{0,3}\|/.test(tableLines[i])) {
+ tableLines[i] = tableLines[i].replace(/^[ \t]{0,3}\|/, '');
+ }
+ if (/\|[ \t]*$/.test(tableLines[i])) {
+ tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, '');
+ }
+ }
+
+ var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}),
+ rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}),
+ rawCells = [],
+ headers = [],
+ styles = [],
+ cells = [];
+
+ tableLines.shift();
+ tableLines.shift();
+
+ for (i = 0; i < tableLines.length; ++i) {
+ if (tableLines[i].trim() === '') {
+ continue;
+ }
+ rawCells.push(
+ tableLines[i]
+ .split('|')
+ .map(function (s) {
+ return s.trim();
+ })
+ );
+ }
+
+ if (rawHeaders.length < rawStyles.length) {
+ return rawTable;
+ }
+
+ for (i = 0; i < rawStyles.length; ++i) {
+ styles.push(parseStyles(rawStyles[i]));
+ }
+
+ for (i = 0; i < rawHeaders.length; ++i) {
+ if (showdown.helper.isUndefined(styles[i])) {
+ styles[i] = '';
+ }
+ headers.push(parseHeaders(rawHeaders[i], styles[i]));
+ }
+
+ for (i = 0; i < rawCells.length; ++i) {
+ var row = [];
+ for (var ii = 0; ii < headers.length; ++ii) {
+ if (showdown.helper.isUndefined(rawCells[i][ii])) {
+
+ }
+ row.push(parseCells(rawCells[i][ii], styles[ii]));
+ }
+ cells.push(row);
+ }
+
+ return buildTable(headers, cells);
+ });
+
+ text = globals.converter._dispatch('tables.after', text, options, globals);
+
+ return text;
+});
+
+/**
+ * Swap back in all the special characters we've hidden.
+ */
+showdown.subParser('unescapeSpecialChars', function (text) {
+ 'use strict';
+
+ text = text.replace(/~E(\d+)E/g, function (wholeMatch, m1) {
+ var charCodeToReplace = parseInt(m1);
+ return String.fromCharCode(charCodeToReplace);
+ });
+ return text;
+});
+module.exports = showdown;
diff --git a/native/wxParse/wxDiscode.js b/native/wxParse/wxDiscode.js
new file mode 100644
index 0000000..fca29bb
--- /dev/null
+++ b/native/wxParse/wxDiscode.js
@@ -0,0 +1,207 @@
+// HTML 支持的数学符号
+function strNumDiscode(str){
+ str = str.replace(/∀/g, '∀');
+ str = str.replace(/∂/g, '∂');
+ str = str.replace(/&exists;/g, '∃');
+ str = str.replace(/∅/g, '∅');
+ str = str.replace(/∇/g, '∇');
+ str = str.replace(/∈/g, '∈');
+ str = str.replace(/∉/g, '∉');
+ str = str.replace(/∋/g, '∋');
+ str = str.replace(/∏/g, '∏');
+ str = str.replace(/∑/g, '∑');
+ str = str.replace(/−/g, '−');
+ str = str.replace(/∗/g, '∗');
+ str = str.replace(/√/g, '√');
+ str = str.replace(/∝/g, '∝');
+ str = str.replace(/∞/g, '∞');
+ str = str.replace(/∠/g, '∠');
+ str = str.replace(/∧/g, '∧');
+ str = str.replace(/∨/g, '∨');
+ str = str.replace(/∩/g, '∩');
+ str = str.replace(/∩/g, '∪');
+ str = str.replace(/∫/g, '∫');
+ str = str.replace(/∴/g, '∴');
+ str = str.replace(/∼/g, '∼');
+ str = str.replace(/≅/g, '≅');
+ str = str.replace(/≈/g, '≈');
+ str = str.replace(/≠/g, '≠');
+ str = str.replace(/≤/g, '≤');
+ str = str.replace(/≥/g, '≥');
+ str = str.replace(/⊂/g, '⊂');
+ str = str.replace(/⊃/g, '⊃');
+ str = str.replace(/⊄/g, '⊄');
+ str = str.replace(/⊆/g, '⊆');
+ str = str.replace(/⊇/g, '⊇');
+ str = str.replace(/⊕/g, '⊕');
+ str = str.replace(/⊗/g, '⊗');
+ str = str.replace(/⊥/g, '⊥');
+ str = str.replace(/⋅/g, '⋅');
+ return str;
+}
+
+//HTML 支持的希腊字母
+function strGreeceDiscode(str){
+ str = str.replace(/Α/g, 'Α');
+ str = str.replace(/Β/g, 'Β');
+ str = str.replace(/Γ/g, 'Γ');
+ str = str.replace(/Δ/g, 'Δ');
+ str = str.replace(/Ε/g, 'Ε');
+ str = str.replace(/Ζ/g, 'Ζ');
+ str = str.replace(/Η/g, 'Η');
+ str = str.replace(/Θ/g, 'Θ');
+ str = str.replace(/Ι/g, 'Ι');
+ str = str.replace(/Κ/g, 'Κ');
+ str = str.replace(/Λ/g, 'Λ');
+ str = str.replace(/Μ/g, 'Μ');
+ str = str.replace(/Ν/g, 'Ν');
+ str = str.replace(/Ξ/g, 'Ν');
+ str = str.replace(/Ο/g, 'Ο');
+ str = str.replace(/Π/g, 'Π');
+ str = str.replace(/Ρ/g, 'Ρ');
+ str = str.replace(/Σ/g, 'Σ');
+ str = str.replace(/Τ/g, 'Τ');
+ str = str.replace(/Υ/g, 'Υ');
+ str = str.replace(/Φ/g, 'Φ');
+ str = str.replace(/Χ/g, 'Χ');
+ str = str.replace(/Ψ/g, 'Ψ');
+ str = str.replace(/Ω/g, 'Ω');
+
+ str = str.replace(/α/g, 'α');
+ str = str.replace(/β/g, 'β');
+ str = str.replace(/γ/g, 'γ');
+ str = str.replace(/δ/g, 'δ');
+ str = str.replace(/ε/g, 'ε');
+ str = str.replace(/ζ/g, 'ζ');
+ str = str.replace(/η/g, 'η');
+ str = str.replace(/θ/g, 'θ');
+ str = str.replace(/ι/g, 'ι');
+ str = str.replace(/κ/g, 'κ');
+ str = str.replace(/λ/g, 'λ');
+ str = str.replace(/μ/g, 'μ');
+ str = str.replace(/ν/g, 'ν');
+ str = str.replace(/ξ/g, 'ξ');
+ str = str.replace(/ο/g, 'ο');
+ str = str.replace(/π/g, 'π');
+ str = str.replace(/ρ/g, 'ρ');
+ str = str.replace(/ς/g, 'ς');
+ str = str.replace(/σ/g, 'σ');
+ str = str.replace(/τ/g, 'τ');
+ str = str.replace(/υ/g, 'υ');
+ str = str.replace(/φ/g, 'φ');
+ str = str.replace(/χ/g, 'χ');
+ str = str.replace(/ψ/g, 'ψ');
+ str = str.replace(/ω/g, 'ω');
+ str = str.replace(/ϑ/g, 'ϑ');
+ str = str.replace(/ϒ/g, 'ϒ');
+ str = str.replace(/ϖ/g, 'ϖ');
+ str = str.replace(/·/g, '·');
+ return str;
+}
+
+//
+
+function strcharacterDiscode(str){
+ // 加入常用解析
+ str = str.replace(/ /g, ' ');
+ str = str.replace(/"/g, "'");
+ str = str.replace(/&/g, '&');
+ // str = str.replace(/</g, '‹');
+ // str = str.replace(/>/g, '›');
+
+ str = str.replace(/</g, '<');
+ str = str.replace(/>/g, '>');
+ str = str.replace(/•/g, '•');
+
+ return str;
+}
+
+// HTML 支持的其他实体
+function strOtherDiscode(str){
+ str = str.replace(/Œ/g, 'Œ');
+ str = str.replace(/œ/g, 'œ');
+ str = str.replace(/Š/g, 'Š');
+ str = str.replace(/š/g, 'š');
+ str = str.replace(/Ÿ/g, 'Ÿ');
+ str = str.replace(/ƒ/g, 'ƒ');
+ str = str.replace(/ˆ/g, 'ˆ');
+ str = str.replace(/˜/g, '˜');
+ str = str.replace(/ /g, '');
+ str = str.replace(/ /g, '');
+ str = str.replace(/ /g, '');
+ str = str.replace(//g, '');
+ str = str.replace(//g, '');
+ str = str.replace(//g, '');
+ str = str.replace(//g, '');
+ str = str.replace(/–/g, '–');
+ str = str.replace(/—/g, '—');
+ str = str.replace(/‘/g, '‘');
+ str = str.replace(/’/g, '’');
+ str = str.replace(/‚/g, '‚');
+ str = str.replace(/“/g, '“');
+ str = str.replace(/”/g, '”');
+ str = str.replace(/„/g, '„');
+ str = str.replace(/†/g, '†');
+ str = str.replace(/‡/g, '‡');
+ str = str.replace(/•/g, '•');
+ str = str.replace(/…/g, '…');
+ str = str.replace(/‰/g, '‰');
+ str = str.replace(/′/g, '′');
+ str = str.replace(/″/g, '″');
+ str = str.replace(/‹/g, '‹');
+ str = str.replace(/›/g, '›');
+ str = str.replace(/‾/g, '‾');
+ str = str.replace(/€/g, '€');
+ str = str.replace(/™/g, '™');
+
+ str = str.replace(/←/g, '←');
+ str = str.replace(/↑/g, '↑');
+ str = str.replace(/→/g, '→');
+ str = str.replace(/↓/g, '↓');
+ str = str.replace(/↔/g, '↔');
+ str = str.replace(/↵/g, '↵');
+ str = str.replace(/⌈/g, '⌈');
+ str = str.replace(/⌉/g, '⌉');
+
+ str = str.replace(/⌊/g, '⌊');
+ str = str.replace(/⌋/g, '⌋');
+ str = str.replace(/◊/g, '◊');
+ str = str.replace(/♠/g, '♠');
+ str = str.replace(/♣/g, '♣');
+ str = str.replace(/♥/g, '♥');
+
+ str = str.replace(/♦/g, '♦');
+ str = str.replace(/'/g, '\'');
+ return str;
+}
+
+function strMoreDiscode(str){
+ str = str.replace(/\r\n/g,"");
+ str = str.replace(/\n/g,"");
+
+ str = str.replace(/code/g,"wxxxcode-style");
+ return str;
+}
+
+function strDiscode(str){
+ str = strNumDiscode(str);
+ str = strGreeceDiscode(str);
+ str = strcharacterDiscode(str);
+ str = strOtherDiscode(str);
+ str = strMoreDiscode(str);
+ return str;
+}
+function urlToHttpUrl(url,rep){
+
+ var patt1 = new RegExp("^//");
+ var result = patt1.test(url);
+ if(result){
+ url = rep+":"+url;
+ }
+ return url;
+}
+
+module.exports = {
+ strDiscode:strDiscode,
+ urlToHttpUrl:urlToHttpUrl
+}
\ No newline at end of file
diff --git a/native/wxParse/wxParse.js b/native/wxParse/wxParse.js
new file mode 100644
index 0000000..0c59fac
--- /dev/null
+++ b/native/wxParse/wxParse.js
@@ -0,0 +1,160 @@
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ * 垂直微信小程序开发交流社区
+ *
+Latest commit 405d856 on 9 Nov 2017
+ * github地址: https://github.com/icindy/wxParse
+ *
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+/**
+ * utils函数引入
+ **/
+import showdown from './showdown.js';
+import HtmlToJson from './html2json.js';
+/**
+ * 配置及公有属性
+ **/
+var realWindowWidth = 0;
+var realWindowHeight = 0;
+wx.getSystemInfo({
+ success: function (res) {
+ realWindowWidth = res.windowWidth
+ realWindowHeight = res.windowHeight
+ }
+})
+/**
+ * 主函数入口区
+ **/
+function wxParse(bindName = 'wxParseData', type='html', data='数据不能为空', target,imagePadding) {
+ var that = target;
+ var transData = {};//存放转化后的数据
+ if (type == 'html') {
+ transData = HtmlToJson.html2json(data, bindName);
+ //console.log(JSON.stringify(transData, ' ', ' '));
+ } else if (type == 'md' || type == 'markdown') {
+ var converter = new showdown.Converter();
+ var html = converter.makeHtml(data);
+ transData = HtmlToJson.html2json(html, bindName);
+ //console.log(JSON.stringify(transData, ' ', ' '));
+ }
+ transData.view = {};
+ transData.view.imagePadding = 0;
+ if(typeof(imagePadding) != 'undefined'){
+ transData.view.imagePadding = imagePadding
+ }
+ var bindData = {};
+ bindData[bindName] = transData;
+ that.setData(bindData)
+ that.wxParseImgLoad = wxParseImgLoad;
+ that.wxParseImgTap = wxParseImgTap;
+}
+// 图片点击事件
+function wxParseImgTap(e) {
+ var that = this;
+ var nowImgUrl = e.target.dataset.src;
+ var tagFrom = e.target.dataset.from;
+ if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
+ wx.previewImage({
+ current: nowImgUrl, // 当前显示图片的http链接
+ urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表
+ })
+ }
+}
+
+/**
+ * 图片视觉宽高计算函数区
+ **/
+function wxParseImgLoad(e) {
+ var that = this;
+ var tagFrom = e.target.dataset.from;
+ var idx = e.target.dataset.idx;
+ if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
+ calMoreImageInfo(e, idx, that, tagFrom)
+ }
+}
+// 假循环获取计算图片视觉最佳宽高
+function calMoreImageInfo(e, idx, that, bindName) {
+ var temData = that.data[bindName];
+ if (!temData || temData.images.length == 0) {
+ return;
+ }
+ var temImages = temData.images;
+ //因为无法获取view宽度 需要自定义padding进行计算,稍后处理
+ var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName);
+ // temImages[idx].width = recal.imageWidth;
+ // temImages[idx].height = recal.imageheight;
+ // temData.images = temImages;
+ // var bindData = {};
+ // bindData[bindName] = temData;
+ // that.setData(bindData);
+ var index = temImages[idx].index
+ var key = `${bindName}`
+ for (var i of index.split('.')) key+=`.nodes[${i}]`
+ var keyW = key + '.width'
+ var keyH = key + '.height'
+ that.setData({
+ [keyW]: recal.imageWidth,
+ [keyH]: recal.imageheight,
+ })
+}
+
+// 计算视觉优先的图片宽高
+function wxAutoImageCal(originalWidth, originalHeight,that,bindName) {
+ //获取图片的原始长宽
+ var windowWidth = 0, windowHeight = 0;
+ var autoWidth = 0, autoHeight = 0;
+ var results = {};
+ var padding = that.data[bindName].view.imagePadding;
+ windowWidth = realWindowWidth-2*padding;
+ windowHeight = realWindowHeight;
+ //判断按照那种方式进行缩放
+ // console.log("windowWidth" + windowWidth);
+ if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候
+ autoWidth = windowWidth;
+ // console.log("autoWidth" + autoWidth);
+ autoHeight = (autoWidth * originalHeight) / originalWidth;
+ // console.log("autoHeight" + autoHeight);
+ results.imageWidth = autoWidth;
+ results.imageheight = autoHeight;
+ } else {//否则展示原来的数据
+ results.imageWidth = originalWidth;
+ results.imageheight = originalHeight;
+ }
+ return results;
+}
+
+function wxParseTemArray(temArrayName,bindNameReg,total,that){
+ var array = [];
+ var temData = that.data;
+ var obj = null;
+ for(var i = 0; i < total; i++){
+ var simArr = temData[bindNameReg+i].nodes;
+ array.push(simArr);
+ }
+
+ temArrayName = temArrayName || 'wxParseTemArray';
+ obj = JSON.parse('{"'+ temArrayName +'":""}');
+ obj[temArrayName] = array;
+ that.setData(obj);
+}
+
+/**
+ * 配置emojis
+ *
+ */
+
+function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
+ HtmlToJson.emojisInit(reg,baseSrc,emojis);
+}
+
+module.exports = {
+ wxParse: wxParse,
+ wxParseTemArray:wxParseTemArray,
+ emojisInit:emojisInit
+}
+
+
diff --git a/native/wxParse/wxParse.wxml b/native/wxParse/wxParse.wxml
new file mode 100644
index 0000000..00fa568
--- /dev/null
+++ b/native/wxParse/wxParse.wxml
@@ -0,0 +1,967 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.text}}
+
+
+
+
+
+
+
+
+ \n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/native/wxParse/wxParse.wxss b/native/wxParse/wxParse.wxss
new file mode 100644
index 0000000..6e1d604
--- /dev/null
+++ b/native/wxParse/wxParse.wxss
@@ -0,0 +1,206 @@
+
+/**
+ * author: Di (微信小程序开发工程师)
+ * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
+ * 垂直微信小程序开发交流社区
+ *
+ * github地址: https://github.com/icindy/wxParse
+ *
+ * for: 微信小程序富文本解析
+ * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
+ */
+
+.wxParse{
+ margin: 0 5px;
+ font-family: Helvetica,sans-serif;
+ font-size: 28rpx;
+ color: #666;
+ line-height: 1.8;
+}
+view{
+ word-break:break-all; overflow:auto;
+}
+.wxParse-inline{
+ display: inline;
+ margin: 0;
+ padding: 0;
+}
+/*//标题 */
+.wxParse-div{margin: 0;padding: 0;}
+.wxParse-h1{ font-size:2em; margin: .67em 0 }
+.wxParse-h2{ font-size:1.5em; margin: .75em 0 }
+.wxParse-h3{ font-size:1.17em; margin: .83em 0 }
+.wxParse-h4{ margin: 1.12em 0}
+.wxParse-h5 { font-size:.83em; margin: 1.5em 0 }
+.wxParse-h6{ font-size:.75em; margin: 1.67em 0 }
+
+.wxParse-h1 {
+ font-size: 18px;
+ font-weight: 400;
+ margin-bottom: .9em;
+}
+.wxParse-h2 {
+ font-size: 16px;
+ font-weight: 400;
+ margin-bottom: .34em;
+}
+.wxParse-h3 {
+ font-weight: 400;
+ font-size: 15px;
+ margin-bottom: .34em;
+}
+.wxParse-h4 {
+ font-weight: 400;
+ font-size: 14px;
+ margin-bottom: .24em;
+}
+.wxParse-h5 {
+ font-weight: 400;
+ font-size: 13px;
+ margin-bottom: .14em;
+}
+.wxParse-h6 {
+ font-weight: 400;
+ font-size: 12px;
+ margin-bottom: .04em;
+}
+
+.wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong { font-weight: bolder }
+
+.wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic}
+.wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace}
+.wxParse-pre{white-space:pre}
+.wxParse-big{font-size:1.17em}
+.wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em}
+.wxParse-sub{vertical-align:sub}
+.wxParse-sup{vertical-align:super}
+.wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through}
+/*wxparse-自定义个性化的css样式*/
+/*增加video的css样式*/
+.wxParse-strong,.wxParse-s{display: inline}
+.wxParse-a{
+ color: deepskyblue;
+ word-break:break-all;
+ overflow:auto;
+}
+
+.wxParse-video{
+ text-align: center;
+ margin: 10px 0;
+}
+
+.wxParse-video-video{
+ width:100%;
+}
+
+.wxParse-img{
+ /*background-color: #efefef;*/
+ overflow: hidden;
+}
+
+.wxParse-blockquote {
+ margin: 0;
+ padding:10px 0 10px 5px;
+ font-family:Courier, Calibri,"宋体";
+ background:#f5f5f5;
+ border-left: 3px solid #dbdbdb;
+}
+
+.wxParse-code,.wxParse-wxxxcode-style{
+ display: inline;
+ background:#f5f5f5;
+}
+.wxParse-ul{
+ margin: 20rpx 10rpx;
+}
+
+.wxParse-li,.wxParse-li-inner{
+ display: flex;
+ align-items: baseline;
+ margin: 10rpx 0;
+}
+.wxParse-li-text{
+
+ align-items: center;
+ line-height: 20px;
+}
+
+.wxParse-li-circle{
+ display: inline-flex;
+ width: 5px;
+ height: 5px;
+ background-color: #333;
+ margin-right: 5px;
+}
+
+.wxParse-li-square{
+ display: inline-flex;
+ width: 10rpx;
+ height: 10rpx;
+ background-color: #333;
+ margin-right: 5px;
+}
+.wxParse-li-ring{
+ display: inline-flex;
+ width: 10rpx;
+ height: 10rpx;
+ border: 2rpx solid #333;
+ border-radius: 50%;
+ background-color: #fff;
+ margin-right: 5px;
+}
+
+/*.wxParse-table{
+ width: 100%;
+ height: 400px;
+}
+.wxParse-thead,.wxParse-tfoot,.wxParse-tr{
+ display: flex;
+ flex-direction: row;
+}
+.wxParse-th,.wxParse-td{
+ display: flex;
+ width: 580px;
+ overflow: auto;
+}*/
+
+.wxParse-u {
+ text-decoration: underline;
+}
+.wxParse-hide{
+ display: none;
+}
+.WxEmojiView{
+ align-items: center;
+}
+.wxEmoji{
+ width: 16px;
+ height:16px;
+}
+.wxParse-tr{
+ display: flex;
+ border-right:1px solid #e0e0e0;
+ border-bottom:1px solid #e0e0e0;
+ border-top:1px solid #e0e0e0;
+}
+.wxParse-th,
+.wxParse-td{
+ flex:1;
+ padding:5px;
+ font-size:28rpx;
+ border-left:1px solid #e0e0e0;
+ word-break: break-all;
+}
+.wxParse-td:last{
+ border-top:1px solid #e0e0e0;
+}
+.wxParse-th{
+ background:#f0f0f0;
+ border-top:1px solid #e0e0e0;
+}
+.wxParse-del{
+ display: inline;
+}
+.wxParse-figure {
+ overflow: hidden;
+}
diff --git a/uwsgi.ini b/uwsgi.ini
index 2c8bd3a..3f503b2 100644
--- a/uwsgi.ini
+++ b/uwsgi.ini
@@ -15,3 +15,4 @@ chmod-socket=777
logfile-chmod=644
daemonize=/data/www/logs/order.log
static-map = /static=/data/www/order/web/static
+
diff --git a/uwsgitwo.ini b/uwsgitwo.ini
deleted file mode 100644
index 47c6bef..0000000
--- a/uwsgitwo.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-[uwsgi]
-#源码目录
-chdir=/order
-#python 虚拟环境
-home=/imooc_env
-module=manager
-callable=app
-master=true
-processes=4
-http=0.0.0.0:8889
-socket=/logs/order.sock
-buffer-size=65535
-pidfile=/logs/order.pid
-chmod-socket=777
-logfile-chmod=644
-daemonize=/logs/order.log
-static-map = /static=/order/web/static
\ No newline at end of file
diff --git a/web/controllers/api/.Member.py.swp b/web/controllers/api/.Member.py.swp
new file mode 100644
index 0000000..396aeb6
Binary files /dev/null and b/web/controllers/api/.Member.py.swp differ
diff --git a/web/controllers/api/Member.py b/web/controllers/api/Member.py
index 6c6b560..f180561 100644
--- a/web/controllers/api/Member.py
+++ b/web/controllers/api/Member.py
@@ -1,164 +1,164 @@
-# -*- coding: utf-8 -*-
-from web.controllers.api import route_api
-from flask import request,jsonify,g
-from application import app,db
-import requests,json
-from common.models.member.Member import Member
-from common.models.member.Mendianuserinfo import Mendianuserinfo
-from common.models.member.Memberinfoo import Memberinfoo
-from common.models.member.Membermiya import Membermiya
-from common.models.member.OauthMemberBind import OauthMemberBind
-from common.models.food.WxShareHistory import WxShareHistory
-from common.libs.Helper import getCurrentDate
-from common.libs.member.MemberService import MemberService
-
-@route_api.route("/member/login",methods = [ "GET","POST" ])
-def login():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- req = request.values
- code = req['code'] if 'code' in req else ''
- app.logger.info(code)
- if not code or len(code) < 1:
- resp['code'] = -1
- resp['msg'] = "需要code"
- return jsonify(resp)
- openid = MemberService.getWeChatOpenId(code)
- app.logger.info(openid)
- if openid is None:
- resp['code'] = -1
- resp['msg'] = "调用微信出错"
- return jsonify(resp)
- nickname = req['nickName'] if 'nickName' in req else ''
- sex = req['gender'] if 'gender' in req else 0
- avatar = req['avatarUrl'] if 'avatarUrl' in req else ''
- '''
- 判断是否已经测试过,注册了直接返回一些信息
- '''
- bind_info = OauthMemberBind.query.filter_by(openid=openid, type=1).first()
- if not bind_info:
- model_member = Member()
- model_member.nickname = nickname
- model_member.sex = sex
- model_member.avatar = avatar
- model_member.salt = MemberService.geneSalt()
- model_member.updated_time = model_member.created_time = getCurrentDate()
- db.session.add(model_member)
- db.session.commit()
-
- model_bind = OauthMemberBind()
- model_bind.member_id = model_member.id
- model_bind.type = 1
- model_bind.openid = openid
- model_bind.extra = ''
- model_bind.updated_time = model_bind.created_time = getCurrentDate()
- db.session.add(model_bind)
- db.session.commit()
-
- bind_info = model_bind
- member_info = Member.query.filter_by(id=bind_info.member_id).first()
- token = "%s#%s" % (MemberService.geneAuthCode(member_info), member_info.id)
- resp['data'] = {'token': token}
- return jsonify(resp)
-
-@route_api.route("/member/logintwo",methods = [ "GET","POST" ])
-def logintwo():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- req = request.values
- app.logger.info(req)
- name = req['name'] if 'name' in req else ''
- app.logger.info(name)
- phone = req['phone'] if 'phone' in req else 0
- app.logger.info(phone)
- storename = req['storename'] if 'storename' in req else ''
- app.logger.info(storename)
-
- name_info = Mendianuserinfo.query.filter_by(nickname=name).first()
- if not name_info:
- model_mendianuserinfo = Mendianuserinfo()
- model_mendianuserinfo.nickname = name
- model_mendianuserinfo.mobile = phone
- model_mendianuserinfo.storename = storename
- db.session.add(model_mendianuserinfo)
- db.session.commit()
- return jsonify(resp)
-
-@route_api.route("/member/loginmiya",methods = [ "GET","POST" ])
-def loginmiya():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- req = request.values
- app.logger.info(req)
- name = req['nickname'] if 'nickname' in req else ''
- app.logger.info(name)
- mobile = req['mobile'] if 'mobile' in req else 0
- app.logger.info(mobile)
- token = req['token'] if 'token' in req else ''
- app.logger.info(token)
-
- miya_info = Membermiya.query.filter_by(nickname=name).first()
- if not miya_info:
- model_membermiya = Membermiya()
- model_membermiya.nickname = name
- model_membermiya.mobile = mobile
- model_membermiya.token = token
- db.session.add(model_membermiya)
- db.session.commit()
- return jsonify(resp)
-
-
-@route_api.route("/member/check-reg",methods = [ "GET","POST" ])
-def checkReg():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- req = request.values
- code = req['code'] if 'code' in req else ''
- if not code or len(code) < 1:
- resp['code'] = -1
- resp['msg'] = "需要code"
- return jsonify(resp)
-
- openid = MemberService.getWeChatOpenId(code)
- if openid is None:
- resp['code'] = -1
- resp['msg'] = "调用微信出错"
- return jsonify(resp)
-
- bind_info = OauthMemberBind.query.filter_by(openid=openid, type=1).first()
- if not bind_info:
- resp['code'] = -1
- resp['msg'] = "未绑定"
- return jsonify(resp)
-
- member_info = Member.query.filter_by( id = bind_info.member_id).first()
- if not member_info:
- resp['code'] = -1
- resp['msg'] = "未查询到绑定信息"
- return jsonify(resp)
-
- token = "%s#%s"%( MemberService.geneAuthCode( member_info ),member_info.id )
- resp['data'] = { 'token':token }
- return jsonify(resp)
-
-@route_api.route("/member/share",methods = [ "POST" ])
-def memberShare():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- req = request.values
- url = req['url'] if 'url' in req else ''
- member_info = g.member_info
- model_share = WxShareHistory()
- if member_info:
- model_share.member_id = member_info.id
- model_share.share_url = url
- model_share.created_time = getCurrentDate()
- db.session.add(model_share)
- db.session.commit()
- return jsonify(resp)
-
-
-@route_api.route("/member/info")
-def memberInfo():
- resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
- member_info = g.member_info
- resp['data']['info'] = {
- "nickname":member_info.nickname,
- "avatar_url":member_info.avatar
- }
- return jsonify(resp)
\ No newline at end of file
+# -*- coding: utf-8 -*-
+from web.controllers.api import route_api
+from flask import request,jsonify,g
+from application import app,db
+import requests,json
+from common.models.member.Member import Member
+from common.models.member.Mendianuserinfo import Mendianuserinfo
+from common.models.member.Memberinfoo import Memberinfoo
+from common.models.member.Membermiya import Membermiya
+from common.models.member.OauthMemberBind import OauthMemberBind
+from common.models.food.WxShareHistory import WxShareHistory
+from common.libs.Helper import getCurrentDate
+from common.libs.member.MemberService import MemberService
+
+@route_api.route("/member/login",methods = [ "GET","POST" ])
+def login():
+ resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
+ req = request.values
+ code = req['code'] if 'code' in req else ''
+ app.logger.info(code)
+ if not code or len(code) < 1:
+ resp['code'] = -1
+ resp['msg'] = "需要code"
+ return jsonify(resp)
+ openid = MemberService.getWeChatOpenId(code)
+ app.logger.info(openid)
+ if openid is None:
+ resp['code'] = -1
+ resp['msg'] = "调用微信出错"
+ return jsonify(resp)
+ nickname = req['nickName'] if 'nickName' in req else ''
+ sex = req['gender'] if 'gender' in req else 0
+ avatar = req['avatarUrl'] if 'avatarUrl' in req else ''
+ '''
+ 判断是否已经测试过,注册了直接返回一些信息
+ '''
+ bind_info = OauthMemberBind.query.filter_by(openid=openid, type=1).first()
+ if not bind_info:
+ model_member = Member()
+ model_member.nickname = nickname
+ model_member.sex = sex
+ model_member.avatar = avatar
+ model_member.salt = MemberService.geneSalt()
+ model_member.updated_time = model_member.created_time = getCurrentDate()
+ db.session.add(model_member)
+ db.session.commit()
+
+ model_bind = OauthMemberBind()
+ model_bind.member_id = model_member.id
+ model_bind.type = 1
+ model_bind.openid = openid
+ model_bind.extra = ''
+ model_bind.updated_time = model_bind.created_time = getCurrentDate()
+ db.session.add(model_bind)
+ db.session.commit()
+
+ bind_info = model_bind
+ member_info = Member.query.filter_by(id=bind_info.member_id).first()
+ token = "%s#%s" % (MemberService.geneAuthCode(member_info), member_info.id)
+ resp['data'] = {'token': token}
+ return jsonify(resp)
+
+@route_api.route("/member/logintwo",methods = [ "GET","POST" ])
+def logintwo():
+ resp = {'code': 200, 'msg': 'rb操作成功~', 'data': {}}
+ req = request.values
+ app.logger.info(req)
+ name = req['name'] if 'name' in req else ''
+ app.logger.info(name)
+ phone = req['phone'] if 'phone' in req else 0
+ app.logger.info(phone)
+ storename = req['storename'] if 'storename' in req else ''
+ app.logger.info(storename)
+
+ name_info = Mendianuserinfo.query.filter_by(nickname=name).first()
+ if not name_info:
+ model_mendianuserinfo = Mendianuserinfo()
+ model_mendianuserinfo.nickname = name
+ model_mendianuserinfo.mobile = phone
+ model_mendianuserinfo.storename = storename
+ db.session.add(model_mendianuserinfo)
+ db.session.commit()
+ return jsonify(resp)
+
+@route_api.route("/member/loginmiya",methods = [ "GET","POST" ])
+def loginmiya():
+ resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
+ req = request.values
+ app.logger.info(req)
+ name = req['nickname'] if 'nickname' in req else ''
+ app.logger.info(name)
+ mobile = req['mobile'] if 'mobile' in req else 0
+ app.logger.info(mobile)
+ token = req['token'] if 'token' in req else ''
+ app.logger.info(token)
+
+ miya_info = Membermiya.query.filter_by(nickname=name).first()
+ if not miya_info:
+ model_membermiya = Membermiya()
+ model_membermiya.nickname = name
+ model_membermiya.mobile = mobile
+ model_membermiya.token = token
+ db.session.add(model_membermiya)
+ db.session.commit()
+ return jsonify(resp)
+
+
+@route_api.route("/member/check-reg",methods = [ "GET","POST" ])
+def checkReg():
+ resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
+ req = request.values
+ code = req['code'] if 'code' in req else ''
+ if not code or len(code) < 1:
+ resp['code'] = -1
+ resp['msg'] = "需要code"
+ return jsonify(resp)
+
+ openid = MemberService.getWeChatOpenId(code)
+ if openid is None:
+ resp['code'] = -1
+ resp['msg'] = "调用微信出错"
+ return jsonify(resp)
+
+ bind_info = OauthMemberBind.query.filter_by(openid=openid, type=1).first()
+ if not bind_info:
+ resp['code'] = -1
+ resp['msg'] = "未绑定"
+ return jsonify(resp)
+
+ member_info = Member.query.filter_by( id = bind_info.member_id).first()
+ if not member_info:
+ resp['code'] = -1
+ resp['msg'] = "未查询到绑定信息"
+ return jsonify(resp)
+
+ token = "%s#%s"%( MemberService.geneAuthCode( member_info ),member_info.id )
+ resp['data'] = { 'token':token }
+ return jsonify(resp)
+
+@route_api.route("/member/share",methods = [ "POST" ])
+def memberShare():
+ resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
+ req = request.values
+ url = req['url'] if 'url' in req else ''
+ member_info = g.member_info
+ model_share = WxShareHistory()
+ if member_info:
+ model_share.member_id = member_info.id
+ model_share.share_url = url
+ model_share.created_time = getCurrentDate()
+ db.session.add(model_share)
+ db.session.commit()
+ return jsonify(resp)
+
+
+@route_api.route("/member/info")
+def memberInfo():
+ resp = {'code': 200, 'msg': '操作成功~', 'data': {}}
+ member_info = g.member_info
+ resp['data']['info'] = {
+ "nickname":member_info.nickname,
+ "avatar_url":member_info.avatar
+ }
+ return jsonify(resp)
diff --git a/web/static/plugins/ueditor/dialogs/emotion/emotion.html b/web/static/plugins/ueditor/dialogs/emotion/emotion.html
index fca0850..2188795 100644
--- a/web/static/plugins/ueditor/dialogs/emotion/emotion.html
+++ b/web/static/plugins/ueditor/dialogs/emotion/emotion.html
@@ -46,7 +46,7 @@
tab3:['HI', 'KISS', '不说', '不要', '扯花', '大心', '顶', '大惊', '飞吻', '鬼脸', '害羞', '口水', '狂哭', '来', '泪眼', '流泪', '生气', '吐舌', '喜欢', '旋转', '再见', '抓狂', '汗', '鄙视', '拜', '吐血', '嘘', '打人', '蹦跳', '变脸', '扯肉', '吃To', '吃花', '吹泡泡糖', '大变身', '飞天舞', '回眸', '可怜', '猛抽', '泡泡', '苹果', '亲', '', '骚舞', '烧香', '睡', '套娃娃', '捅捅', '舞倒', '西红柿', '爱慕', '摇', '摇摆', '杂耍', '招财', '被殴', '被球闷', '大惊', '理想', '欧打', '呕吐', '碎', '吐痰'],
tab4:['发财了', '吃西瓜', '套牢', '害羞', '庆祝', '我来了', '敲打', '晕了', '胜利', '臭美', '被打了', '贪吃', '迎接', '酷', '顶', '幸运', '爱心', '躲', '送花', '选择'],
tab5:['微笑', '亲吻', '调皮', '惊讶', '耍酷', '发火', '害羞', '汗水', '大哭', '得意', '鄙视', '困', '夸奖', '晕倒', '疑问', '媒婆', '狂吐', '青蛙', '发愁', '亲吻', '', '爱心', '心碎', '玫瑰', '礼物', '哭', '奸笑', '可爱', '得意', '呲牙', '暴汗', '楚楚可怜', '困', '哭', '生气', '惊讶', '口水', '彩虹', '夜空', '太阳', '钱钱', '灯泡', '咖啡', '蛋糕', '音乐', '爱', '胜利', '赞', '鄙视', 'OK'],
- tab6:['男兜', '女兜', '开心', '乖乖', '偷笑', '大笑', '抽泣', '大哭', '无奈', '滴汗', '叹气', '狂晕', '委屈', '超赞', '??', '疑问', '飞吻', '天使', '撒花', '生气', '被砸', '口水', '泪奔', '吓傻', '吐舌头', '点头', '随意吐', '旋转', '困困', '鄙视', '狂顶', '篮球', '再见', '欢迎光临', '恭喜发财', '稍等', '我在线', '恕不议价', '库房有货', '货在路上']
+ tab6:['男兜', '女兜', '开心', '乖乖', '偷笑', '大笑', '抽泣', '大哭', '无奈', '滴汗', '叹气', '狂晕', '委屈', '超赞', '??', '疑问', '飞吻', '', '撒花', '生气', '被砸', '口水', '泪奔', '吓傻', '吐舌头', '点头', '随意吐', '旋转', '困困', '鄙视', '狂顶', '篮球', '再见', '欢迎光临', '恭喜发财', '稍等', '我在线', '恕不议价', '库房有货', '货在路上']
}
};