X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fcebe%2Fmarkdown%2FGithubMarkdown.php;fp=vendor%2Fcebe%2Fmarkdown%2FGithubMarkdown.php;h=ff206c6453f15dfa14b9200c77cba6bc5d10cd24;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad
diff --git a/vendor/cebe/markdown/GithubMarkdown.php b/vendor/cebe/markdown/GithubMarkdown.php
new file mode 100644
index 000000000..ff206c645
--- /dev/null
+++ b/vendor/cebe/markdown/GithubMarkdown.php
@@ -0,0 +1,99 @@
+
+ */
+class GithubMarkdown extends Markdown
+{
+ // include block element parsing using traits
+ use block\TableTrait;
+ use block\FencedCodeTrait;
+
+ // include inline element parsing using traits
+ use inline\StrikeoutTrait;
+ use inline\UrlLinkTrait;
+
+ /**
+ * @var boolean whether to interpret newlines as `
`-tags.
+ * This feature is useful for comments where newlines are often meant to be real new lines.
+ */
+ public $enableNewlines = false;
+
+ /**
+ * @inheritDoc
+ */
+ protected $escapeCharacters = [
+ // from Markdown
+ '\\', // backslash
+ '`', // backtick
+ '*', // asterisk
+ '_', // underscore
+ '{', '}', // curly braces
+ '[', ']', // square brackets
+ '(', ')', // parentheses
+ '#', // hash mark
+ '+', // plus sign
+ '-', // minus sign (hyphen)
+ '.', // dot
+ '!', // exclamation mark
+ '<', '>',
+ // added by GithubMarkdown
+ ':', // colon
+ '|', // pipe
+ ];
+
+
+
+ /**
+ * Consume lines for a paragraph
+ *
+ * Allow headlines, lists and code to break paragraphs
+ */
+ protected function consumeParagraph($lines, $current)
+ {
+ // consume until newline
+ $content = [];
+ for ($i = $current, $count = count($lines); $i < $count; $i++) {
+ $line = $lines[$i];
+ if (!empty($line) && ltrim($line) !== '' &&
+ !($line[0] === "\t" || $line[0] === " " && strncmp($line, ' ', 4) === 0) &&
+ !$this->identifyHeadline($line, $lines, $i) &&
+ !$this->identifyUl($line, $lines, $i) &&
+ !$this->identifyOl($line, $lines, $i))
+ {
+ $content[] = $line;
+ } else {
+ break;
+ }
+ }
+ $block = [
+ 'paragraph',
+ 'content' => $this->parseInline(implode("\n", $content)),
+ ];
+ return [$block, --$i];
+ }
+
+ /**
+ * @inheritdocs
+ *
+ * Parses a newline indicated by two spaces on the end of a markdown line.
+ */
+ protected function renderText($text)
+ {
+ if ($this->enableNewlines) {
+ $br = $this->html5 ? "
\n" : "
\n";
+ return strtr($text[1], [" \n" => $br, "\n" => $br]);
+ } else {
+ return parent::renderText($text);
+ }
+ }
+}