Skip to content

Commit

Permalink
Synced to eab9043
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Aug 30, 2015
1 parent c687d30 commit 848b1ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s9e/text-formatter",
"version": "0.2.1-dev",
"version": "0.2.1",
"type": "library",
"description": "Multi-purpose text formatting and markup library. Plugins offer support for BBCodes, Markdown, emoticons, HTML, embedding media (YouTube, etc...), enhanced typography and more.",
"homepage": "https://github.com/s9e/TextFormatter/",
Expand Down
13 changes: 9 additions & 4 deletions src/Plugins/Litedown/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ function matchBlockLevelMarkup()
continuation,
endTag,
ignoreLen,
indentStr,
indentLen,
lfPos,
listIndex,
maxIndent,
Expand Down Expand Up @@ -361,13 +363,12 @@ function matchBlockLevelMarkup()

// Compute the width of the indentation
var indentWidth = 0,
indentPos = 0,
indentStr,
indentLen;
indentPos = 0;
if (m[2])
{
indentStr = m[2];
indentLen = indentStr.length;
maxIndent = (codeFence) ? 0 : codeIndent;

do
{
Expand All @@ -380,7 +381,7 @@ function matchBlockLevelMarkup()
indentWidth = (indentWidth + 4) & ~3;
}
}
while (++indentPos < indentLen && indentWidth < codeIndent);
while (++indentPos < indentLen && indentWidth < maxIndent);
}

// Test whether we're out of a code block
Expand Down Expand Up @@ -801,6 +802,10 @@ function matchInlineLinks()
tag.setAttribute('title', decode(m[3]));
}

// Give the link a slightly better priority to give it precedence over
// possible BBCodes such as [b](https://en.wikipedia.org/wiki/B)
tag.setSortPriority(-1);

// Overwrite the markup without touching the link's text
overwrite(startTagPos, startTagLen);
overwrite(endTagPos, endTagLen);
Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/Litedown/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,15 @@ protected function matchBlockLevelMarkup()
{
$indentStr = $m[2][0];
$indentLen = \strlen($indentStr);
$maxIndent = ($codeFence) ? 0 : $codeIndent;
do
{
if ($indentStr[$indentPos] === ' ')
++$indentWidth;
else
$indentWidth = ($indentWidth + 4) & ~3;
}
while (++$indentPos < $indentLen && $indentWidth < $codeIndent);
while (++$indentPos < $indentLen && $indentWidth < $maxIndent);
}
if (isset($codeTag) && !$codeFence && $indentWidth < $codeIndent && !$lineIsEmpty)
$newContext = \true;
Expand Down Expand Up @@ -475,6 +476,7 @@ protected function matchInlineLinks()
$tag->setAttribute('url', $this->decode($m[2][0]));
if (isset($m[3]) && $m[3][0] !== '')
$tag->setAttribute('title', $this->decode($m[3][0]));
$tag->setSortPriority(-1);
$this->overwrite($startTagPos, $startTagLen);
$this->overwrite($endTagPos, $endTagLen);
}
Expand Down

0 comments on commit 848b1ac

Please sign in to comment.