Browse Source

Update CommonMark spec to 0.15 + emphasis changes

pull/25/head
Alex Kocharin 10 years ago
parent
commit
b7914cb08a
  1. 28
      lib/rules_inline/emphasis.js
  2. 16
      test/fixtures/commonmark/bad.txt
  3. 1263
      test/fixtures/commonmark/good.txt
  4. 662
      test/fixtures/commonmark/spec.txt

28
lib/rules_inline/emphasis.js

@ -2,6 +2,9 @@
'use strict'; 'use strict';
var isWhiteSpace = require('../common/utils').isWhiteSpace;
var isPunctChar = require('../common/utils').isPunctChar;
function isAlphaNum(code) { function isAlphaNum(code) {
return (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) || return (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) ||
@ -13,6 +16,8 @@ function isAlphaNum(code) {
// "start" should point at a valid marker // "start" should point at a valid marker
function scanDelims(state, start) { function scanDelims(state, start) {
var pos = start, lastChar, nextChar, count, var pos = start, lastChar, nextChar, count,
isLastWhiteSpace, isLastPunctChar,
isNextWhiteSpace, isNextPunctChar,
can_open = true, can_open = true,
can_close = true, can_close = true,
max = state.posMax, max = state.posMax,
@ -26,9 +31,26 @@ function scanDelims(state, start) {
nextChar = pos < max ? state.src.charCodeAt(pos) : -1; nextChar = pos < max ? state.src.charCodeAt(pos) : -1;
// check whitespace conditions isLastPunctChar = lastChar >= 0 && isPunctChar(String.fromCharCode(lastChar));
if (nextChar === 0x20 || nextChar === 0x0A) { can_open = false; } isNextPunctChar = nextChar >= 0 && isPunctChar(String.fromCharCode(nextChar));
if (lastChar === 0x20 || lastChar === 0x0A) { can_close = false; } isLastWhiteSpace = lastChar >= 0 && isWhiteSpace(lastChar);
isNextWhiteSpace = nextChar >= 0 && isWhiteSpace(nextChar);
if (isNextWhiteSpace) {
can_open = false;
} else if (isNextPunctChar) {
if (!(isLastWhiteSpace || isLastPunctChar || lastChar === -1)) {
can_open = false;
}
}
if (isLastWhiteSpace) {
can_close = false;
} else if (isLastPunctChar) {
if (!(isNextWhiteSpace || isNextPunctChar || nextChar === -1)) {
can_close = false;
}
}
if (marker === 0x5F /* _ */) { if (marker === 0x5F /* _ */) {
// check if we aren't inside the word // check if we aren't inside the word

16
test/fixtures/commonmark/bad.txt

@ -0,0 +1,16 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4653
.
* a *
.
<p>* a *</p>
.
error:
<ul>
<li>a *</li>
</ul>

1263
test/fixtures/commonmark/good.txt

File diff suppressed because it is too large

662
test/fixtures/commonmark/spec.txt

File diff suppressed because it is too large
Loading…
Cancel
Save