Skip to content

Commit

Permalink
SWC-3029: reset when state source changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Apr 19, 2016
1 parent 638eb64 commit bd37005
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
10 changes: 6 additions & 4 deletions dist/markdown-it-emphasis-alt.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
/*! markdown-it-emphasis-alt 1.0.7 https://github.com/jay-hodgson/markdown-it-emphasis-alt @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.markdownitEmphasisAlt = 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){
/*! markdown-it-emphasis-alt 1.0.8 https://github.com/jay-hodgson/markdown-it-emphasis-alt @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.markdownitEmphasisAlt = 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){
// Process emphasis

'use strict';
// single or double marker is toggled
var isSingleOpen;
var isDoubleOpen;
var newlinePos;
var newlinePosSrc;
var initialized = false;
var WORD_CHAR_TEST_RE = /[a-zA-Z0-9]/;

function reset(_newlinePos) {
function reset(_newSrc, _newlinePos) {
isSingleOpen = false;
isDoubleOpen = false;
if (_newlinePos) {
newlinePos = _newlinePos;
} else {
newlinePos = 0;
}
newlinePosSrc = _newSrc;
}

function tokenize(state, silent) {
Expand Down Expand Up @@ -50,8 +52,8 @@ function tokenize(state, silent) {
}
nextNewlinePos++;
}
if (nextNewlinePos > newlinePos) {
reset(nextNewlinePos);
if (state.src !== newlinePosSrc || nextNewlinePos > newlinePos) {
reset(state.src, nextNewlinePos);
}

token = state.push('text', '', 0);
Expand Down
4 changes: 2 additions & 2 deletions dist/markdown-it-emphasis-alt.min.js

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

8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
var isSingleOpen;
var isDoubleOpen;
var newlinePos;
var newlinePosSrc;
var initialized = false;
var WORD_CHAR_TEST_RE = /[a-zA-Z0-9]/;

function reset(_newlinePos) {
function reset(_newSrc, _newlinePos) {
isSingleOpen = false;
isDoubleOpen = false;
if (_newlinePos) {
newlinePos = _newlinePos;
} else {
newlinePos = 0;
}
newlinePosSrc = _newSrc;
}

function tokenize(state, silent) {
Expand Down Expand Up @@ -49,8 +51,8 @@ function tokenize(state, silent) {
}
nextNewlinePos++;
}
if (nextNewlinePos > newlinePos) {
reset(nextNewlinePos);
if (state.src !== newlinePosSrc || nextNewlinePos > newlinePos) {
reset(state.src, nextNewlinePos);
}

token = state.push('text', '', 0);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-it-emphasis-alt",
"version": "1.0.7",
"version": "1.0.8",
"description": "tag for markdown-it markdown parser.",
"main": "index.js",
"keywords": [
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ __clear*Science*__
.
<p><strong>clear<em>Science</em></strong></p>
.

Unclosed marker should not mess up the rest of the document
.
**This unclosed bold messes up the rest of the page?!

**This should be bold in a heading**
.
<p>**This unclosed bold messes up the rest of the page?!</p>
<p><strong>This should be bold in a heading</strong></p>
.

0 comments on commit bd37005

Please sign in to comment.