it got caught by the HTML
+ // tag parser and hashed. Need to reverse the process before using
+ // the URL.
+ $unhashed = $this->unhash($url);
+ if ($unhashed !== $url)
+ $url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
+
+ $url = $this->encodeURLAttribute($url);
+
+ $result = "encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+
+ $link_text = $this->runSpanGamut($link_text);
+ $result .= ">$link_text ";
+
+ return $this->hashPart($result);
+ }
+
+ /**
+ * Turn Markdown image shortcuts into tags.
+ * @param string $text
+ * @return string
+ */
+ protected function doImages($text) {
+ // First, handle reference-style labeled images: ![alt text][id]
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ ('.$this->nested_brackets_re.') # alt text = $2
+ \]
+
+ [ ]? # one optional space
+ (?:\n[ ]*)? # one optional newline followed by spaces
+
+ \[
+ (.*?) # id = $3
+ \]
+
+ )
+ }xs',
+ array($this, '_doImages_reference_callback'), $text);
+
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ ('.$this->nested_brackets_re.') # alt text = $2
+ \]
+ \s? # One optional whitespace character
+ \( # literal paren
+ [ \n]*
+ (?:
+ <(\S*)> # src url = $3
+ |
+ ('.$this->nested_url_parenthesis_re.') # src url = $4
+ )
+ [ \n]*
+ ( # $5
+ ([\'"]) # quote char = $6
+ (.*?) # title = $7
+ \6 # matching quote
+ [ \n]*
+ )? # title is optional
+ \)
+ )
+ }xs',
+ array($this, '_doImages_inline_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback to parse references image tags
+ * @param array $matches
+ * @return string
+ */
+ protected function _doImages_reference_callback($matches) {
+ $whole_match = $matches[1];
+ $alt_text = $matches[2];
+ $link_id = strtolower($matches[3]);
+
+ if ($link_id == "") {
+ $link_id = strtolower($alt_text); // for shortcut links like ![this][].
+ }
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ if (isset($this->urls[$link_id])) {
+ $url = $this->encodeURLAttribute($this->urls[$link_id]);
+ $result = " titles[$link_id])) {
+ $title = $this->titles[$link_id];
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ $result .= $this->empty_element_suffix;
+ $result = $this->hashPart($result);
+ } else {
+ // If there's no such link ID, leave intact:
+ $result = $whole_match;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Callback to parse inline image tags
+ * @param array $matches
+ * @return string
+ */
+ protected function _doImages_inline_callback($matches) {
+ $whole_match = $matches[1];
+ $alt_text = $matches[2];
+ $url = $matches[3] == '' ? $matches[4] : $matches[3];
+ $title =& $matches[7];
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ $url = $this->encodeURLAttribute($url);
+ $result = " encodeAttribute($title);
+ $result .= " title=\"$title\""; // $title already quoted
+ }
+ $result .= $this->empty_element_suffix;
+
+ return $this->hashPart($result);
+ }
+
+ /**
+ * Parse Markdown heading elements to HTML
+ * @param string $text
+ * @return string
+ */
+ protected function doHeaders($text) {
+ /**
+ * Setext-style headers:
+ * Header 1
+ * ========
+ *
+ * Header 2
+ * --------
+ */
+ $text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx',
+ array($this, '_doHeaders_callback_setext'), $text);
+
+ /**
+ * atx-style headers:
+ * # Header 1
+ * ## Header 2
+ * ## Header 2 with closing hashes ##
+ * ...
+ * ###### Header 6
+ */
+ $text = preg_replace_callback('{
+ ^(\#{1,6}) # $1 = string of #\'s
+ [ ]*
+ (.+?) # $2 = Header text
+ [ ]*
+ \#* # optional closing #\'s (not counted)
+ \n+
+ }xm',
+ array($this, '_doHeaders_callback_atx'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Setext header parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doHeaders_callback_setext($matches) {
+ // Terrible hack to check we haven't found an empty list item.
+ if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) {
+ return $matches[0];
+ }
+
+ $level = $matches[2][0] == '=' ? 1 : 2;
+
+ // ID attribute generation
+ $idAtt = $this->_generateIdFromHeaderValue($matches[1]);
+
+ $block = "".$this->runSpanGamut($matches[1])." ";
+ return "\n" . $this->hashBlock($block) . "\n\n";
+ }
+
+ /**
+ * ATX header parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doHeaders_callback_atx($matches) {
+ // ID attribute generation
+ $idAtt = $this->_generateIdFromHeaderValue($matches[2]);
+
+ $level = strlen($matches[1]);
+ $block = "".$this->runSpanGamut($matches[2])." ";
+ return "\n" . $this->hashBlock($block) . "\n\n";
+ }
+
+ /**
+ * If a header_id_func property is set, we can use it to automatically
+ * generate an id attribute.
+ *
+ * This method returns a string in the form id="foo", or an empty string
+ * otherwise.
+ * @param string $headerValue
+ * @return string
+ */
+ protected function _generateIdFromHeaderValue($headerValue) {
+ if (!is_callable($this->header_id_func)) {
+ return "";
+ }
+
+ $idValue = call_user_func($this->header_id_func, $headerValue);
+ if (!$idValue) {
+ return "";
+ }
+
+ return ' id="' . $this->encodeAttribute($idValue) . '"';
+ }
+
+ /**
+ * Form HTML ordered (numbered) and unordered (bulleted) lists.
+ * @param string $text
+ * @return string
+ */
+ protected function doLists($text) {
+ $less_than_tab = $this->tab_width - 1;
+
+ // Re-usable patterns to match list item bullets and number markers:
+ $marker_ul_re = '[*+-]';
+ $marker_ol_re = '\d+[\.]';
+
+ $markers_relist = array(
+ $marker_ul_re => $marker_ol_re,
+ $marker_ol_re => $marker_ul_re,
+ );
+
+ foreach ($markers_relist as $marker_re => $other_marker_re) {
+ // Re-usable pattern to match any entirel ul or ol list:
+ $whole_list_re = '
+ ( # $1 = whole list
+ ( # $2
+ ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces
+ ('.$marker_re.') # $4 = first list item marker
+ [ ]+
+ )
+ (?s:.+?)
+ ( # $5
+ \z
+ |
+ \n{2,}
+ (?=\S)
+ (?! # Negative lookahead for another list item marker
+ [ ]*
+ '.$marker_re.'[ ]+
+ )
+ |
+ (?= # Lookahead for another kind of list
+ \n
+ \3 # Must have the same indentation
+ '.$other_marker_re.'[ ]+
+ )
+ )
+ )
+ '; // mx
+
+ // We use a different prefix before nested lists than top-level lists.
+ //See extended comment in _ProcessListItems().
+
+ if ($this->list_level) {
+ $text = preg_replace_callback('{
+ ^
+ '.$whole_list_re.'
+ }mx',
+ array($this, '_doLists_callback'), $text);
+ } else {
+ $text = preg_replace_callback('{
+ (?:(?<=\n)\n|\A\n?) # Must eat the newline
+ '.$whole_list_re.'
+ }mx',
+ array($this, '_doLists_callback'), $text);
+ }
+ }
+
+ return $text;
+ }
+
+ /**
+ * List parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doLists_callback($matches) {
+ // Re-usable patterns to match list item bullets and number markers:
+ $marker_ul_re = '[*+-]';
+ $marker_ol_re = '\d+[\.]';
+ $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
+ $marker_ol_start_re = '[0-9]+';
+
+ $list = $matches[1];
+ $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
+
+ $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );
+
+ $list .= "\n";
+ $result = $this->processListItems($list, $marker_any_re);
+
+ $ol_start = 1;
+ if ($this->enhanced_ordered_list) {
+ // Get the start number for ordered list.
+ if ($list_type == 'ol') {
+ $ol_start_array = array();
+ $ol_start_check = preg_match("/$marker_ol_start_re/", $matches[4], $ol_start_array);
+ if ($ol_start_check){
+ $ol_start = $ol_start_array[0];
+ }
+ }
+ }
+
+ if ($ol_start > 1 && $list_type == 'ol'){
+ $result = $this->hashBlock("<$list_type start=\"$ol_start\">\n" . $result . "$list_type>");
+ } else {
+ $result = $this->hashBlock("<$list_type>\n" . $result . "$list_type>");
+ }
+ return "\n". $result ."\n\n";
+ }
+
+ /**
+ * Nesting tracker for list levels
+ * @var integer
+ */
+ protected $list_level = 0;
+
+ /**
+ * Process the contents of a single ordered or unordered list, splitting it
+ * into individual list items.
+ * @param string $list_str
+ * @param string $marker_any_re
+ * @return string
+ */
+ protected function processListItems($list_str, $marker_any_re) {
+ /**
+ * The $this->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.".
+ */
+ $this->list_level++;
+
+ // Trim trailing blank lines:
+ $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);
+
+ $list_str = preg_replace_callback('{
+ (\n)? # leading line = $1
+ (^[ ]*) # leading whitespace = $2
+ ('.$marker_any_re.' # list marker and space = $3
+ (?:[ ]+|(?=\n)) # space only required if item is not empty
+ )
+ ((?s:.*?)) # list item text = $4
+ (?:(\n+(?=\n))|\n) # tailing blank line = $5
+ (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
+ }xm',
+ array($this, '_processListItems_callback'), $list_str);
+
+ $this->list_level--;
+ return $list_str;
+ }
+
+ /**
+ * List item parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _processListItems_callback($matches) {
+ $item = $matches[4];
+ $leading_line =& $matches[1];
+ $leading_space =& $matches[2];
+ $marker_space = $matches[3];
+ $tailing_blank_line =& $matches[5];
+
+ if ($leading_line || $tailing_blank_line ||
+ preg_match('/\n{2,}/', $item))
+ {
+ // Replace marker with the appropriate whitespace indentation
+ $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
+ $item = $this->runBlockGamut($this->outdent($item)."\n");
+ } else {
+ // Recursion for sub-lists:
+ $item = $this->doLists($this->outdent($item));
+ $item = $this->formParagraphs($item, false);
+ }
+
+ return "" . $item . " \n";
+ }
+
+ /**
+ * Process Markdown `` blocks.
+ * @param string $text
+ * @return string
+ */
+ protected function doCodeBlocks($text) {
+ $text = preg_replace_callback('{
+ (?:\n\n|\A\n?)
+ ( # $1 = the code block -- one or more lines, starting with a space/tab
+ (?>
+ [ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces
+ .*\n+
+ )+
+ )
+ ((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
+ }xm',
+ array($this, '_doCodeBlocks_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Code block parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doCodeBlocks_callback($matches) {
+ $codeblock = $matches[1];
+
+ $codeblock = $this->outdent($codeblock);
+ if (is_callable($this->code_block_content_func)) {
+ $codeblock = call_user_func($this->code_block_content_func, $codeblock, "");
+ } else {
+ $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
+ }
+
+ # trim leading newlines and trailing newlines
+ $codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
+
+ $codeblock = "$codeblock\n
";
+ return "\n\n" . $this->hashBlock($codeblock) . "\n\n";
+ }
+
+ /**
+ * Create a code span markup for $code. Called from handleSpanToken.
+ * @param string $code
+ * @return string
+ */
+ protected function makeCodeSpan($code) {
+ if (is_callable($this->code_span_content_func)) {
+ $code = call_user_func($this->code_span_content_func, $code);
+ } else {
+ $code = htmlspecialchars(trim($code), ENT_NOQUOTES);
+ }
+ return $this->hashPart("$code
");
+ }
+
+ /**
+ * Define the emphasis operators with their regex matches
+ * @var array
+ */
+ protected $em_relist = array(
+ '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(?em_relist as $em => $em_re) {
+ foreach ($this->strong_relist as $strong => $strong_re) {
+ // Construct list of allowed token expressions.
+ $token_relist = array();
+ if (isset($this->em_strong_relist["$em$strong"])) {
+ $token_relist[] = $this->em_strong_relist["$em$strong"];
+ }
+ $token_relist[] = $em_re;
+ $token_relist[] = $strong_re;
+
+ // Construct master expression from list.
+ $token_re = '{(' . implode('|', $token_relist) . ')}';
+ $this->em_strong_prepared_relist["$em$strong"] = $token_re;
+ }
+ }
+ }
+
+ /**
+ * Convert Markdown italics (emphasis) and bold (strong) to HTML
+ * @param string $text
+ * @return string
+ */
+ protected function doItalicsAndBold($text) {
+ if ($this->in_emphasis_processing) {
+ return $text; // avoid reentrency
+ }
+ $this->in_emphasis_processing = true;
+
+ $token_stack = array('');
+ $text_stack = array('');
+ $em = '';
+ $strong = '';
+ $tree_char_em = false;
+
+ while (1) {
+ // Get prepared regular expression for seraching emphasis tokens
+ // in current context.
+ $token_re = $this->em_strong_prepared_relist["$em$strong"];
+
+ // Each loop iteration search for the next emphasis token.
+ // Each token is then passed to handleSpanToken.
+ $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
+ $text_stack[0] .= $parts[0];
+ $token =& $parts[1];
+ $text =& $parts[2];
+
+ if (empty($token)) {
+ // Reached end of text span: empty stack without emitting.
+ // any more emphasis.
+ while ($token_stack[0]) {
+ $text_stack[1] .= array_shift($token_stack);
+ $text_stack[0] .= array_shift($text_stack);
+ }
+ break;
+ }
+
+ $token_len = strlen($token);
+ if ($tree_char_em) {
+ // Reached closing marker while inside a three-char emphasis.
+ if ($token_len == 3) {
+ // Three-char closing marker, close em and strong.
+ array_shift($token_stack);
+ $span = array_shift($text_stack);
+ $span = $this->runSpanGamut($span);
+ $span = "$span ";
+ $text_stack[0] .= $this->hashPart($span);
+ $em = '';
+ $strong = '';
+ } else {
+ // Other closing marker: close one em or strong and
+ // change current token state to match the other
+ $token_stack[0] = str_repeat($token[0], 3-$token_len);
+ $tag = $token_len == 2 ? "strong" : "em";
+ $span = $text_stack[0];
+ $span = $this->runSpanGamut($span);
+ $span = "<$tag>$span$tag>";
+ $text_stack[0] = $this->hashPart($span);
+ $$tag = ''; // $$tag stands for $em or $strong
+ }
+ $tree_char_em = false;
+ } else if ($token_len == 3) {
+ if ($em) {
+ // Reached closing marker for both em and strong.
+ // Closing strong marker:
+ for ($i = 0; $i < 2; ++$i) {
+ $shifted_token = array_shift($token_stack);
+ $tag = strlen($shifted_token) == 2 ? "strong" : "em";
+ $span = array_shift($text_stack);
+ $span = $this->runSpanGamut($span);
+ $span = "<$tag>$span$tag>";
+ $text_stack[0] .= $this->hashPart($span);
+ $$tag = ''; // $$tag stands for $em or $strong
+ }
+ } else {
+ // Reached opening three-char emphasis marker. Push on token
+ // stack; will be handled by the special condition above.
+ $em = $token[0];
+ $strong = "$em$em";
+ array_unshift($token_stack, $token);
+ array_unshift($text_stack, '');
+ $tree_char_em = true;
+ }
+ } else if ($token_len == 2) {
+ if ($strong) {
+ // Unwind any dangling emphasis marker:
+ if (strlen($token_stack[0]) == 1) {
+ $text_stack[1] .= array_shift($token_stack);
+ $text_stack[0] .= array_shift($text_stack);
+ $em = '';
+ }
+ // Closing strong marker:
+ array_shift($token_stack);
+ $span = array_shift($text_stack);
+ $span = $this->runSpanGamut($span);
+ $span = "$span ";
+ $text_stack[0] .= $this->hashPart($span);
+ $strong = '';
+ } else {
+ array_unshift($token_stack, $token);
+ array_unshift($text_stack, '');
+ $strong = $token;
+ }
+ } else {
+ // Here $token_len == 1
+ if ($em) {
+ if (strlen($token_stack[0]) == 1) {
+ // Closing emphasis marker:
+ array_shift($token_stack);
+ $span = array_shift($text_stack);
+ $span = $this->runSpanGamut($span);
+ $span = "$span ";
+ $text_stack[0] .= $this->hashPart($span);
+ $em = '';
+ } else {
+ $text_stack[0] .= $token;
+ }
+ } else {
+ array_unshift($token_stack, $token);
+ array_unshift($text_stack, '');
+ $em = $token;
+ }
+ }
+ }
+ $this->in_emphasis_processing = false;
+ return $text_stack[0];
+ }
+
+ /**
+ * Parse Markdown blockquotes to HTML
+ * @param string $text
+ * @return string
+ */
+ protected function doBlockQuotes($text) {
+ $text = preg_replace_callback('/
+ ( # Wrap whole match in $1
+ (?>
+ ^[ ]*>[ ]? # ">" at the start of a line
+ .+\n # rest of the first line
+ (.+\n)* # subsequent consecutive lines
+ \n* # blanks
+ )+
+ )
+ /xm',
+ array($this, '_doBlockQuotes_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Blockquote parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doBlockQuotes_callback($matches) {
+ $bq = $matches[1];
+ // trim one level of quoting - trim whitespace-only lines
+ $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq);
+ $bq = $this->runBlockGamut($bq); // recurse
+
+ $bq = preg_replace('/^/m', " ", $bq);
+ // These leading spaces cause problem with content,
+ // so we need to fix that:
+ $bq = preg_replace_callback('{(\s*.+? )}sx',
+ array($this, '_doBlockQuotes_callback2'), $bq);
+
+ return "\n" . $this->hashBlock("\n$bq\n ") . "\n\n";
+ }
+
+ /**
+ * Blockquote parsing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doBlockQuotes_callback2($matches) {
+ $pre = $matches[1];
+ $pre = preg_replace('/^ /m', '', $pre);
+ return $pre;
+ }
+
+ /**
+ * Parse paragraphs
+ *
+ * @param string $text String to process in paragraphs
+ * @param boolean $wrap_in_p Whether paragraphs should be wrapped in tags
+ * @return string
+ */
+ protected function formParagraphs($text, $wrap_in_p = true) {
+ // Strip leading and trailing lines:
+ $text = preg_replace('/\A\n+|\n+\z/', '', $text);
+
+ $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
+
+ // Wrap
tags and unhashify HTML blocks
+ foreach ($grafs as $key => $value) {
+ if (!preg_match('/^B\x1A[0-9]+B$/', $value)) {
+ // Is a paragraph.
+ $value = $this->runSpanGamut($value);
+ if ($wrap_in_p) {
+ $value = preg_replace('/^([ ]*)/', "
", $value);
+ $value .= "
";
+ }
+ $grafs[$key] = $this->unhash($value);
+ } else {
+ // Is a block.
+ // Modify elements of @grafs in-place...
+ $graf = $value;
+ $block = $this->html_hashes[$graf];
+ $graf = $block;
+// if (preg_match('{
+// \A
+// ( # $1 = tag
+//
]*
+// \b
+// markdown\s*=\s* ([\'"]) # $2 = attr quote char
+// 1
+// \2
+// [^>]*
+// >
+// )
+// ( # $3 = contents
+// .*
+// )
+// (
) # $4 = closing tag
+// \z
+// }xs', $block, $matches))
+// {
+// list(, $div_open, , $div_content, $div_close) = $matches;
+//
+// // We can't call Markdown(), because that resets the hash;
+// // that initialization code should be pulled into its own sub, though.
+// $div_content = $this->hashHTMLBlocks($div_content);
+//
+// // Run document gamut methods on the content.
+// foreach ($this->document_gamut as $method => $priority) {
+// $div_content = $this->$method($div_content);
+// }
+//
+// $div_open = preg_replace(
+// '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open);
+//
+// $graf = $div_open . "\n" . $div_content . "\n" . $div_close;
+// }
+ $grafs[$key] = $graf;
+ }
+ }
+
+ return implode("\n\n", $grafs);
+ }
+
+ /**
+ * Encode text for a double-quoted HTML attribute. This function
+ * is *not* suitable for attributes enclosed in single quotes.
+ * @param string $text
+ * @return string
+ */
+ protected function encodeAttribute($text) {
+ $text = $this->encodeAmpsAndAngles($text);
+ $text = str_replace('"', '"', $text);
+ return $text;
+ }
+
+ /**
+ * Encode text for a double-quoted HTML attribute containing a URL,
+ * applying the URL filter if set. Also generates the textual
+ * representation for the URL (removing mailto: or tel:) storing it in $text.
+ * This function is *not* suitable for attributes enclosed in single quotes.
+ *
+ * @param string $url
+ * @param string $text Passed by reference
+ * @return string URL
+ */
+ protected function encodeURLAttribute($url, &$text = null) {
+ if (is_callable($this->url_filter_func)) {
+ $url = call_user_func($this->url_filter_func, $url);
+ }
+
+ if (preg_match('{^mailto:}i', $url)) {
+ $url = $this->encodeEntityObfuscatedAttribute($url, $text, 7);
+ } else if (preg_match('{^tel:}i', $url)) {
+ $url = $this->encodeAttribute($url);
+ $text = substr($url, 4);
+ } else {
+ $url = $this->encodeAttribute($url);
+ $text = $url;
+ }
+
+ return $url;
+ }
+
+ /**
+ * Smart processing for ampersands and angle brackets that need to
+ * be encoded. Valid character entities are left alone unless the
+ * no-entities mode is set.
+ * @param string $text
+ * @return string
+ */
+ protected function encodeAmpsAndAngles($text) {
+ if ($this->no_entities) {
+ $text = str_replace('&', '&', $text);
+ } else {
+ // Ampersand-encoding based entirely on Nat Irons's Amputator
+ // MT plugin:
+ $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
+ '&', $text);
+ }
+ // Encode remaining <'s
+ $text = str_replace('<', '<', $text);
+
+ return $text;
+ }
+
+ /**
+ * Parse Markdown automatic links to anchor HTML tags
+ * @param string $text
+ * @return string
+ */
+ protected function doAutoLinks($text) {
+ $text = preg_replace_callback('{<((https?|ftp|dict|tel):[^\'">\s]+)>}i',
+ array($this, '_doAutoLinks_url_callback'), $text);
+
+ // Email addresses:
+ $text = preg_replace_callback('{
+ <
+ (?:mailto:)?
+ (
+ (?:
+ [-!#$%&\'*+/=?^_`.{|}~\w\x80-\xFF]+
+ |
+ ".*?"
+ )
+ \@
+ (?:
+ [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+
+ |
+ \[[\d.a-fA-F:]+\] # IPv4 & IPv6
+ )
+ )
+ >
+ }xi',
+ array($this, '_doAutoLinks_email_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Parse URL callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doAutoLinks_url_callback($matches) {
+ $url = $this->encodeURLAttribute($matches[1], $text);
+ $link = "$text ";
+ return $this->hashPart($link);
+ }
+
+ /**
+ * Parse email address callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _doAutoLinks_email_callback($matches) {
+ $addr = $matches[1];
+ $url = $this->encodeURLAttribute("mailto:$addr", $text);
+ $link = "$text ";
+ return $this->hashPart($link);
+ }
+
+ /**
+ * Input: some text to obfuscate, e.g. "mailto:foo@example.com"
+ *
+ * Output: the same text but with most characters encoded as either a
+ * decimal or hex entity, in the hopes of foiling most address
+ * harvesting spam bots. E.g.:
+ *
+ * mailto:foo
+ * @example.co
+ * m
+ *
+ * Note: the additional output $tail is assigned the same value as the
+ * ouput, minus the number of characters specified by $head_length.
+ *
+ * Based by a filter by Matthew Wickline, posted to BBEdit-Talk.
+ * With some optimizations by Milian Wolff. Forced encoding of HTML
+ * attribute special characters by Allan Odgaard.
+ *
+ * @param string $text
+ * @param string $tail Passed by reference
+ * @param integer $head_length
+ * @return string
+ */
+ protected function encodeEntityObfuscatedAttribute($text, &$tail = null, $head_length = 0) {
+ if ($text == "") {
+ return $tail = "";
+ }
+
+ $chars = preg_split('/(? $char) {
+ $ord = ord($char);
+ // Ignore non-ascii chars.
+ if ($ord < 128) {
+ $r = ($seed * (1 + $key)) % 100; // Pseudo-random function.
+ // roughly 10% raw, 45% hex, 45% dec
+ // '@' *must* be encoded. I insist.
+ // '"' and '>' have to be encoded inside the attribute
+ if ($r > 90 && strpos('@"&>', $char) === false) {
+ /* do nothing */
+ } else if ($r < 45) {
+ $chars[$key] = ''.dechex($ord).';';
+ } else {
+ $chars[$key] = ''.$ord.';';
+ }
+ }
+ }
+
+ $text = implode('', $chars);
+ $tail = $head_length ? implode('', array_slice($chars, $head_length)) : $text;
+
+ return $text;
+ }
+
+ /**
+ * Take the string $str and parse it into tokens, hashing embeded HTML,
+ * escaped characters and handling code spans.
+ * @param string $str
+ * @return string
+ */
+ protected function parseSpan($str) {
+ $output = '';
+
+ $span_re = '{
+ (
+ \\\\'.$this->escape_chars_re.'
+ |
+ (?no_markup ? '' : '
+ |
+ # comment
+ |
+ <\?.*?\?> | <%.*?%> # processing instruction
+ |
+ <[!$]?[-a-zA-Z0-9:_]+ # regular tags
+ (?>
+ \s
+ (?>[^"\'>]+|"[^"]*"|\'[^\']*\')*
+ )?
+ >
+ |
+ <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag
+ |
+ [-a-zA-Z0-9:_]+\s*> # closing tag
+ ').'
+ )
+ }xs';
+
+ while (1) {
+ // Each loop iteration seach for either the next tag, the next
+ // openning code span marker, or the next escaped character.
+ // Each token is then passed to handleSpanToken.
+ $parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE);
+
+ // Create token from text preceding tag.
+ if ($parts[0] != "") {
+ $output .= $parts[0];
+ }
+
+ // Check if we reach the end.
+ if (isset($parts[1])) {
+ $output .= $this->handleSpanToken($parts[1], $parts[2]);
+ $str = $parts[2];
+ } else {
+ break;
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Handle $token provided by parseSpan by determining its nature and
+ * returning the corresponding value that should replace it.
+ * @param string $token
+ * @param string $str Passed by reference
+ * @return string
+ */
+ protected function handleSpanToken($token, &$str) {
+ switch ($token[0]) {
+ case "\\":
+ return $this->hashPart("". ord($token[1]). ";");
+ case "`":
+ // Search for end marker in remaining text.
+ if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
+ $str, $matches))
+ {
+ $str = $matches[2];
+ $codespan = $this->makeCodeSpan($matches[1]);
+ return $this->hashPart($codespan);
+ }
+ return $token; // Return as text since no ending marker found.
+ default:
+ return $this->hashPart($token);
+ }
+ }
+
+ /**
+ * Remove one level of line-leading tabs or spaces
+ * @param string $text
+ * @return string
+ */
+ protected function outdent($text) {
+ return preg_replace('/^(\t|[ ]{1,' . $this->tab_width . '})/m', '', $text);
+ }
+
+
+ /**
+ * String length function for detab. `_initDetab` will create a function to
+ * handle UTF-8 if the default function does not exist.
+ * @var string
+ */
+ protected $utf8_strlen = 'mb_strlen';
+
+ /**
+ * Replace tabs with the appropriate amount of spaces.
+ *
+ * For each line we separate the line in blocks delemited by tab characters.
+ * Then we reconstruct every line by adding the appropriate number of space
+ * between each blocks.
+ *
+ * @param string $text
+ * @return string
+ */
+ protected function detab($text) {
+ $text = preg_replace_callback('/^.*\t.*$/m',
+ array($this, '_detab_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Replace tabs callback
+ * @param string $matches
+ * @return string
+ */
+ protected function _detab_callback($matches) {
+ $line = $matches[0];
+ $strlen = $this->utf8_strlen; // strlen function for UTF-8.
+
+ // Split in blocks.
+ $blocks = explode("\t", $line);
+ // Add each blocks to the line.
+ $line = $blocks[0];
+ unset($blocks[0]); // Do not add first block twice.
+ foreach ($blocks as $block) {
+ // Calculate amount of space, insert spaces, insert block.
+ $amount = $this->tab_width -
+ $strlen($line, 'UTF-8') % $this->tab_width;
+ $line .= str_repeat(" ", $amount) . $block;
+ }
+ return $line;
+ }
+
+ /**
+ * Check for the availability of the function in the `utf8_strlen` property
+ * (initially `mb_strlen`). If the function is not available, create a
+ * function that will loosely count the number of UTF-8 characters with a
+ * regular expression.
+ * @return void
+ */
+ protected function _initDetab() {
+
+ if (function_exists($this->utf8_strlen)) {
+ return;
+ }
+
+ $this->utf8_strlen = function($text) {
+ return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
+ };
+ }
+
+ /**
+ * Swap back in all the tags hashed by _HashHTMLBlocks.
+ * @param string $text
+ * @return string
+ */
+ protected function unhash($text) {
+ return preg_replace_callback('/(.)\x1A[0-9]+\1/',
+ array($this, '_unhash_callback'), $text);
+ }
+
+ /**
+ * Unhashing callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _unhash_callback($matches) {
+ return $this->html_hashes[$matches[0]];
+ }
+}
+
+class MarkdownExtraParser extends MarkdownParser {
+ /**
+ * Configuration variables
+ */
+
+ /**
+ * Prefix for footnote ids.
+ * @var string
+ */
+ public $fn_id_prefix = "";
+
+ /**
+ * Optional title attribute for footnote links.
+ * @var string
+ */
+ public $fn_link_title = "";
+
+ /**
+ * Optional class attribute for footnote links and backlinks.
+ * @var string
+ */
+ public $fn_link_class = "footnote-ref";
+ public $fn_backlink_class = "footnote-backref";
+
+ /**
+ * Content to be displayed within footnote backlinks. The default is '↩';
+ * the U+FE0E on the end is a Unicode variant selector used to prevent iOS
+ * from displaying the arrow character as an emoji.
+ * Optionally use '^^' and '%%' to refer to the footnote number and
+ * reference number respectively. {@see parseFootnotePlaceholders()}
+ * @var string
+ */
+ public $fn_backlink_html = '↩︎';
+
+ /**
+ * Optional title and aria-label attributes for footnote backlinks for
+ * added accessibility (to ensure backlink uniqueness).
+ * Use '^^' and '%%' to refer to the footnote number and reference number
+ * respectively. {@see parseFootnotePlaceholders()}
+ * @var string
+ */
+ public $fn_backlink_title = "";
+ public $fn_backlink_label = "";
+
+ /**
+ * Class name for table cell alignment (%% replaced left/center/right)
+ * For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center'
+ * If empty, the align attribute is used instead of a class name.
+ * @var string
+ */
+ public $table_align_class_tmpl = '';
+
+ /**
+ * Optional class prefix for fenced code block.
+ * @var string
+ */
+ public $code_class_prefix = "";
+
+ /**
+ * Class attribute for code blocks goes on the `code` tag;
+ * setting this to true will put attributes on the `pre` tag instead.
+ * @var boolean
+ */
+ public $code_attr_on_pre = false;
+
+ /**
+ * Predefined abbreviations.
+ * @var array
+ */
+ public $predef_abbr = array();
+
+ /**
+ * Only convert atx-style headers if there's a space between the header and #
+ * @var boolean
+ */
+ public $hashtag_protection = false;
+
+ /**
+ * Determines whether footnotes should be appended to the end of the document.
+ * If true, footnote html can be retrieved from $this->footnotes_assembled.
+ * @var boolean
+ */
+ public $omit_footnotes = false;
+
+
+ /**
+ * After parsing, the HTML for the list of footnotes appears here.
+ * This is available only if $omit_footnotes == true.
+ *
+ * Note: when placing the content of `footnotes_assembled` on the page,
+ * consider adding the attribute `role="doc-endnotes"` to the `div` or
+ * `section` that will enclose the list of footnotes so they are
+ * reachable to accessibility tools the same way they would be with the
+ * default HTML output.
+ * @var null|string
+ */
+ public $footnotes_assembled = null;
+
+ /**
+ * Parser implementation
+ */
+
+ /**
+ * Constructor function. Initialize the parser object.
+ * @return void
+ */
+ public function __construct() {
+ // Add extra escapable characters before parent constructor
+ // initialize the table.
+ $this->escape_chars .= ':|';
+
+ // Insert extra document, block, and span transformations.
+ // Parent constructor will do the sorting.
+ $this->document_gamut += array(
+ "doFencedCodeBlocks" => 5,
+ "stripFootnotes" => 15,
+ "stripAbbreviations" => 25,
+ "appendFootnotes" => 50,
+ );
+ $this->block_gamut += array(
+ "doFencedCodeBlocks" => 5,
+ "doTables" => 15,
+ "doDefLists" => 45,
+ );
+ $this->span_gamut += array(
+ "doFootnotes" => 5,
+ "doAbbreviations" => 70,
+ );
+
+ $this->enhanced_ordered_list = true;
+ parent::__construct();
+ }
+
+
+ /**
+ * Extra variables used during extra transformations.
+ * @var array
+ */
+ protected $footnotes = array();
+ protected $footnotes_ordered = array();
+ protected $footnotes_ref_count = array();
+ protected $footnotes_numbers = array();
+ protected $abbr_desciptions = array();
+ /** @var string */
+ protected $abbr_word_re = '';
+
+ /**
+ * Give the current footnote number.
+ * @var integer
+ */
+ protected $footnote_counter = 1;
+
+ /**
+ * Ref attribute for links
+ * @var array
+ */
+ protected $ref_attr = array();
+
+ /**
+ * Setting up Extra-specific variables.
+ */
+ protected function setup() {
+ parent::setup();
+
+ $this->footnotes = array();
+ $this->footnotes_ordered = array();
+ $this->footnotes_ref_count = array();
+ $this->footnotes_numbers = array();
+ $this->abbr_desciptions = array();
+ $this->abbr_word_re = '';
+ $this->footnote_counter = 1;
+ $this->footnotes_assembled = null;
+
+ foreach ($this->predef_abbr as $abbr_word => $abbr_desc) {
+ if ($this->abbr_word_re)
+ $this->abbr_word_re .= '|';
+ $this->abbr_word_re .= preg_quote($abbr_word);
+ $this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
+ }
+ }
+
+ /**
+ * Clearing Extra-specific variables.
+ */
+ protected function teardown() {
+ $this->footnotes = array();
+ $this->footnotes_ordered = array();
+ $this->footnotes_ref_count = array();
+ $this->footnotes_numbers = array();
+ $this->abbr_desciptions = array();
+ $this->abbr_word_re = '';
+
+ if ( ! $this->omit_footnotes )
+ $this->footnotes_assembled = null;
+
+ parent::teardown();
+ }
+
+
+ /**
+ * Extra attribute parser
+ */
+
+ /**
+ * Expression to use to catch attributes (includes the braces)
+ * @var string
+ */
+ protected $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
+
+ /**
+ * Expression to use when parsing in a context when no capture is desired
+ * @var string
+ */
+ protected $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
+
+ /**
+ * Parse attributes caught by the $this->id_class_attr_catch_re expression
+ * and return the HTML-formatted list of attributes.
+ *
+ * Currently supported attributes are .class and #id.
+ *
+ * In addition, this method also supports supplying a default Id value,
+ * which will be used to populate the id attribute in case it was not
+ * overridden.
+ * @param string $tag_name
+ * @param string $attr
+ * @param mixed $defaultIdValue
+ * @param array $classes
+ * @return string
+ */
+ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array()) {
+ if (empty($attr) && !$defaultIdValue && empty($classes)) {
+ return "";
+ }
+
+ // Split on components
+ preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches);
+ $elements = $matches[0];
+
+ // Handle classes and IDs (only first ID taken into account)
+ $attributes = array();
+ $id = false;
+ foreach ($elements as $element) {
+ if ($element[0] === '.') {
+ $classes[] = substr($element, 1);
+ } else if ($element[0] === '#') {
+ if ($id === false) $id = substr($element, 1);
+ } else if (strpos($element, '=') > 0) {
+ $parts = explode('=', $element, 2);
+ $attributes[] = $parts[0] . '="' . $parts[1] . '"';
+ }
+ }
+
+ if ($id === false || $id === '') {
+ $id = $defaultIdValue;
+ }
+
+ // Compose attributes as string
+ $attr_str = "";
+ if (!empty($id)) {
+ $attr_str .= ' id="'.$this->encodeAttribute($id) .'"';
+ }
+ if (!empty($classes)) {
+ $attr_str .= ' class="'. implode(" ", $classes) . '"';
+ }
+ if (!$this->no_markup && !empty($attributes)) {
+ $attr_str .= ' '.implode(" ", $attributes);
+ }
+ return $attr_str;
+ }
+
+ /**
+ * Strips link definitions from text, stores the URLs and titles in
+ * hash references.
+ * @param string $text
+ * @return string
+ */
+ protected function stripLinkDefinitions($text) {
+ $less_than_tab = $this->tab_width - 1;
+
+ // Link defs are in the form: ^[id]: url "optional title"
+ $text = preg_replace_callback('{
+ ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1
+ [ ]*
+ \n? # maybe *one* newline
+ [ ]*
+ (?:
+ <(.+?)> # url = $2
+ |
+ (\S+?) # url = $3
+ )
+ [ ]*
+ \n? # maybe one newline
+ [ ]*
+ (?:
+ (?<=\s) # lookbehind for whitespace
+ ["(]
+ (.*?) # title = $4
+ [")]
+ [ ]*
+ )? # title is optional
+ (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr
+ (?:\n+|\Z)
+ }xm',
+ array($this, '_stripLinkDefinitions_callback'),
+ $text);
+ return $text;
+ }
+
+ /**
+ * Strip link definition callback
+ * @param array $matches
+ * @return string
+ */
+ protected function _stripLinkDefinitions_callback($matches) {
+ $link_id = strtolower($matches[1]);
+ $url = $matches[2] == '' ? $matches[3] : $matches[2];
+ $this->urls[$link_id] = $url;
+ $this->titles[$link_id] =& $matches[4];
+ $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
+ return ''; // String that will replace the block
+ }
+
+
+ /**
+ * HTML block parser
+ */
+
+ /**
+ * Tags that are always treated as block tags
+ * @var string
+ */
+ protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure';
+
+ /**
+ * Tags treated as block tags only if the opening tag is alone on its line
+ * @var string
+ */
+ protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
+
+ /**
+ * Tags where markdown="1" default to span mode:
+ * @var string
+ */
+ protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
+
+ /**
+ * Tags which must not have their contents modified, no matter where
+ * they appear
+ * @var string
+ */
+ protected $clean_tags_re = 'script|style|math|svg';
+
+ /**
+ * Tags that do not need to be closed.
+ * @var string
+ */
+ protected $auto_close_tags_re = 'hr|img|param|source|track';
+
+ /**
+ * Hashify HTML Blocks and "clean tags".
+ *
+ * We only want to do this for block-level HTML tags, such as headers,
+ * lists, and tables. That's because we still want to wrap s around
+ * "paragraphs" that are wrapped in non-block-level tags, such as anchors,
+ * phrase emphasis, and spans. The list of tags we're looking for is
+ * hard-coded.
+ *
+ * This works by calling _HashHTMLBlocks_InMarkdown, which then calls
+ * _HashHTMLBlocks_InHTML when it encounter block tags. When the markdown="1"
+ * attribute is found within a tag, _HashHTMLBlocks_InHTML calls back
+ * _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag.
+ * These two functions are calling each other. It's recursive!
+ * @param string $text
+ * @return string
+ */
+ protected function hashHTMLBlocks($text) {
+ if ($this->no_markup) {
+ return $text;
+ }
+
+ // Call the HTML-in-Markdown hasher.
+ list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text);
+
+ return $text;
+ }
+
+ /**
+ * Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags.
+ *
+ * * $indent is the number of space to be ignored when checking for code
+ * blocks. This is important because if we don't take the indent into
+ * account, something like this (which looks right) won't work as expected:
+ *
+ *
+ *
+ * Hello World. <-- Is this a Markdown code block or text?
+ *
<-- Is this a Markdown code block or a real tag?
+ *
+ *
+ * If you don't like this, just don't indent the tag on which
+ * you apply the markdown="1" attribute.
+ *
+ * * If $enclosing_tag_re is not empty, stops at the first unmatched closing
+ * tag with that name. Nested tags supported.
+ *
+ * * If $span is true, text inside must treated as span. So any double
+ * newline will be replaced by a single newline so that it does not create
+ * paragraphs.
+ *
+ * Returns an array of that form: ( processed text , remaining text )
+ *
+ * @param string $text
+ * @param integer $indent
+ * @param string $enclosing_tag_re
+ * @param boolean $span
+ * @return array
+ */
+ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
+ $enclosing_tag_re = '', $span = false)
+ {
+
+ if ($text === '') return array('', '');
+
+ // Regex to check for the presense of newlines around a block tag.
+ $newline_before_re = '/(?:^\n?|\n\n)*$/';
+ $newline_after_re =
+ '{
+ ^ # Start of text following the tag.
+ (?>[ ]*)? # Optional comment.
+ [ ]*\n # Must be followed by newline.
+ }xs';
+
+ // Regex to match any tag.
+ $block_tag_re =
+ '{
+ ( # $2: Capture whole tag.
+ ? # Any opening or closing tag.
+ (?> # Tag name.
+ ' . $this->block_tags_re . ' |
+ ' . $this->context_block_tags_re . ' |
+ ' . $this->clean_tags_re . ' |
+ (?!\s)'.$enclosing_tag_re . '
+ )
+ (?:
+ (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name.
+ (?>
+ ".*?" | # Double quotes (can contain `>`)
+ \'.*?\' | # Single quotes (can contain `>`)
+ .+? # Anything but quotes and `>`.
+ )*?
+ )?
+ > # End of tag.
+ |
+ # HTML Comment
+ |
+ <\?.*?\?> | <%.*?%> # Processing instruction
+ |
+ # CData Block
+ ' . ( !$span ? ' # If not in span.
+ |
+ # Indented code block
+ (?: ^[ ]*\n | ^ | \n[ ]*\n )
+ [ ]{' . ($indent + 4) . '}[^\n]* \n
+ (?>
+ (?: [ ]{' . ($indent + 4) . '}[^\n]* | [ ]* ) \n
+ )*
+ |
+ # Fenced code block marker
+ (?<= ^ | \n )
+ [ ]{0,' . ($indent + 3) . '}(?:~{3,}|`{3,})
+ [ ]*
+ (?: \.?[-_:a-zA-Z0-9]+ )? # standalone class name
+ [ ]*
+ (?: ' . $this->id_class_attr_nocatch_re . ' )? # extra attributes
+ [ ]*
+ (?= \n )
+ ' : '' ) . ' # End (if not is span).
+ |
+ # Code span marker
+ # Note, this regex needs to go after backtick fenced
+ # code blocks but it should also be kept outside of the
+ # "if not in span" condition adding backticks to the parser
+ `+
+ )
+ }xs';
+
+
+ $depth = 0; // Current depth inside the tag tree.
+ $parsed = ""; // Parsed text that will be returned.
+
+ // Loop through every tag until we find the closing tag of the parent
+ // or loop until reaching the end of text if no parent tag specified.
+ do {
+ // Split the text using the first $tag_match pattern found.
+ // Text before pattern will be first in the array, text after
+ // pattern will be at the end, and between will be any catches made
+ // by the pattern.
+ $parts = preg_split($block_tag_re, $text, 2,
+ PREG_SPLIT_DELIM_CAPTURE);
+
+ // If in Markdown span mode, add a empty-string span-level hash
+ // after each newline to prevent triggering any block element.
+ if ($span) {
+ $void = $this->hashPart("", ':');
+ $newline = "\n$void";
+ $parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void;
+ }
+
+ $parsed .= $parts[0]; // Text before current tag.
+
+ // If end of $text has been reached. Stop loop.
+ if (count($parts) < 3) {
+ $text = "";
+ break;
+ }
+
+ $tag = $parts[1]; // Tag to handle.
+ $text = $parts[2]; // Remaining text after current tag.
+
+ // Check for: Fenced code block marker.
+ // Note: need to recheck the whole tag to disambiguate backtick
+ // fences from code spans
+ if (preg_match('{^\n?([ ]{0,' . ($indent + 3) . '})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+)?[ ]*(?:' . $this->id_class_attr_nocatch_re . ')?[ ]*\n?$}', $tag, $capture)) {
+ // Fenced code block marker: find matching end marker.
+ $fence_indent = strlen($capture[1]); // use captured indent in re
+ $fence_re = $capture[2]; // use captured fence in re
+ if (preg_match('{^(?>.*\n)*?[ ]{' . ($fence_indent) . '}' . $fence_re . '[ ]*(?:\n|$)}', $text,
+ $matches))
+ {
+ // End marker found: pass text unchanged until marker.
+ $parsed .= $tag . $matches[0];
+ $text = substr($text, strlen($matches[0]));
+ }
+ else {
+ // No end marker: just skip it.
+ $parsed .= $tag;
+ }
+ }
+ // Check for: Indented code block.
+ else if ($tag[0] === "\n" || $tag[0] === " ") {
+ // Indented code block: pass it unchanged, will be handled
+ // later.
+ $parsed .= $tag;
+ }
+ // Check for: Code span marker
+ // Note: need to check this after backtick fenced code blocks
+ else if ($tag[0] === "`") {
+ // Find corresponding end marker.
+ $tag_re = preg_quote($tag);
+ if (preg_match('{^(?>.+?|\n(?!\n))*?(?block_tags_re . ')\b}', $tag) ||
+ ( preg_match('{^<(?:' . $this->context_block_tags_re . ')\b}', $tag) &&
+ preg_match($newline_before_re, $parsed) &&
+ preg_match($newline_after_re, $text) )
+ )
+ {
+ // Need to parse tag and following text using the HTML parser.
+ list($block_text, $text) =
+ $this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true);
+
+ // Make sure it stays outside of any paragraph by adding newlines.
+ $parsed .= "\n\n$block_text\n\n";
+ }
+ // Check for: Clean tag (like script, math)
+ // HTML Comments, processing instructions.
+ else if (preg_match('{^<(?:' . $this->clean_tags_re . ')\b}', $tag) ||
+ $tag[1] === '!' || $tag[1] === '?')
+ {
+ // Need to parse tag and following text using the HTML parser.
+ // (don't check for markdown attribute)
+ list($block_text, $text) =
+ $this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false);
+
+ $parsed .= $block_text;
+ }
+ // Check for: Tag with same name as enclosing tag.
+ else if ($enclosing_tag_re !== '' &&
+ // Same name as enclosing tag.
+ preg_match('{^?(?:' . $enclosing_tag_re . ')\b}', $tag))
+ {
+ // Increase/decrease nested tag count.
+ if ($tag[1] === '/') {
+ $depth--;
+ } else if ($tag[strlen($tag)-2] !== '/') {
+ $depth++;
+ }
+
+ if ($depth < 0) {
+ // Going out of parent element. Clean up and break so we
+ // return to the calling function.
+ $text = $tag . $text;
+ break;
+ }
+
+ $parsed .= $tag;
+ }
+ else {
+ $parsed .= $tag;
+ }
+ } while ($depth >= 0);
+
+ return array($parsed, $text);
+ }
+
+ /**
+ * Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
+ *
+ * * Calls $hash_method to convert any blocks.
+ * * Stops when the first opening tag closes.
+ * * $md_attr indicate if the use of the `markdown="1"` attribute is allowed.
+ * (it is not inside clean tags)
+ *
+ * Returns an array of that form: ( processed text , remaining text )
+ * @param string $text
+ * @param string $hash_method
+ * @param bool $md_attr Handle `markdown="1"` attribute
+ * @return array
+ */
+ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
+ if ($text === '') return array('', '');
+
+ // Regex to match `markdown` attribute inside of a tag.
+ $markdown_attr_re = '
+ {
+ \s* # Eat whitespace before the `markdown` attribute
+ markdown
+ \s*=\s*
+ (?>
+ (["\']) # $1: quote delimiter
+ (.*?) # $2: attribute value
+ \1 # matching delimiter
+ |
+ ([^\s>]*) # $3: unquoted attribute value
+ )
+ () # $4: make $3 always defined (avoid warnings)
+ }xs';
+
+ // Regex to match any tag.
+ $tag_re = '{
+ ( # $2: Capture whole tag.
+ ? # Any opening or closing tag.
+ [\w:$]+ # Tag name.
+ (?:
+ (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name.
+ (?>
+ ".*?" | # Double quotes (can contain `>`)
+ \'.*?\' | # Single quotes (can contain `>`)
+ .+? # Anything but quotes and `>`.
+ )*?
+ )?
+ > # End of tag.
+ |
+ # HTML Comment
+ |
+ <\?.*?\?> | <%.*?%> # Processing instruction
+ |
+ # CData Block
+ )
+ }xs';
+
+ $original_text = $text; // Save original text in case of faliure.
+
+ $depth = 0; // Current depth inside the tag tree.
+ $block_text = ""; // Temporary text holder for current text.
+ $parsed = ""; // Parsed text that will be returned.
+ $base_tag_name_re = '';
+
+ // Get the name of the starting tag.
+ // (This pattern makes $base_tag_name_re safe without quoting.)
+ if (preg_match('/^<([\w:$]*)\b/', $text, $matches))
+ $base_tag_name_re = $matches[1];
+
+ // Loop through every tag until we find the corresponding closing tag.
+ do {
+ // Split the text using the first $tag_match pattern found.
+ // Text before pattern will be first in the array, text after
+ // pattern will be at the end, and between will be any catches made
+ // by the pattern.
+ $parts = preg_split($tag_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
+
+ if (count($parts) < 3) {
+ // End of $text reached with unbalenced tag(s).
+ // In that case, we return original text unchanged and pass the
+ // first character as filtered to prevent an infinite loop in the
+ // parent function.
+ return array($original_text[0], substr($original_text, 1));
+ }
+
+ $block_text .= $parts[0]; // Text before current tag.
+ $tag = $parts[1]; // Tag to handle.
+ $text = $parts[2]; // Remaining text after current tag.
+
+ // Check for: Auto-close tag (like
)
+ // Comments and Processing Instructions.
+ if (preg_match('{^?(?:' . $this->auto_close_tags_re . ')\b}', $tag) ||
+ $tag[1] === '!' || $tag[1] === '?')
+ {
+ // Just add the tag to the block as if it was text.
+ $block_text .= $tag;
+ }
+ else {
+ // Increase/decrease nested tag count. Only do so if
+ // the tag's name match base tag's.
+ if (preg_match('{^?' . $base_tag_name_re . '\b}', $tag)) {
+ if ($tag[1] === '/') {
+ $depth--;
+ } else if ($tag[strlen($tag)-2] !== '/') {
+ $depth++;
+ }
+ }
+
+ // Check for `markdown="1"` attribute and handle it.
+ if ($md_attr &&
+ preg_match($markdown_attr_re, $tag, $attr_m) &&
+ preg_match('/^1|block|span$/', $attr_m[2] . $attr_m[3]))
+ {
+ // Remove `markdown` attribute from opening tag.
+ $tag = preg_replace($markdown_attr_re, '', $tag);
+
+ // Check if text inside this tag must be parsed in span mode.
+ $mode = $attr_m[2] . $attr_m[3];
+ $span_mode = $mode === 'span' || ($mode !== 'block' &&
+ preg_match('{^<(?:' . $this->contain_span_tags_re . ')\b}', $tag));
+
+ // Calculate indent before tag.
+ if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) {
+ $strlen = $this->utf8_strlen;
+ $indent = $strlen($matches[1], 'UTF-8');
+ } else {
+ $indent = 0;
+ }
+
+ // End preceding block with this tag.
+ $block_text .= $tag;
+ $parsed .= $this->$hash_method($block_text);
+
+ // Get enclosing tag name for the ParseMarkdown function.
+ // (This pattern makes $tag_name_re safe without quoting.)
+ preg_match('/^<([\w:$]*)\b/', $tag, $matches);
+ $tag_name_re = $matches[1];
+
+ // Parse the content using the HTML-in-Markdown parser.
+ list ($block_text, $text)
+ = $this->_hashHTMLBlocks_inMarkdown($text, $indent,
+ $tag_name_re, $span_mode);
+
+ // Outdent markdown text.
+ if ($indent > 0) {
+ $block_text = preg_replace("/^[ ]{1,$indent}/m", "",
+ $block_text);
+ }
+
+ // Append tag content to parsed text.
+ if (!$span_mode) {
+ $parsed .= "\n\n$block_text\n\n";
+ } else {
+ $parsed .= (string) $block_text;
+ }
+
+ // Start over with a new block.
+ $block_text = "";
+ }
+ else $block_text .= $tag;
+ }
+
+ } while ($depth > 0);
+
+ // Hash last block text that wasn't processed inside the loop.
+ $parsed .= $this->$hash_method($block_text);
+
+ return array($parsed, $text);
+ }
+
+ /**
+ * Called whenever a tag must be hashed when a function inserts a "clean" tag
+ * in $text, it passes through this function and is automaticaly escaped,
+ * blocking invalid nested overlap.
+ * @param string $text
+ * @return string
+ */
+ protected function hashClean($text) {
+ return $this->hashPart($text, 'C');
+ }
+
+ /**
+ * Turn Markdown link shortcuts into XHTML
tags.
+ * @param string $text
+ * @return string
+ */
+ protected function doAnchors($text) {
+ if ($this->in_anchor) {
+ return $text;
+ }
+ $this->in_anchor = true;
+
+ // First, handle reference-style links: [link text] [id]
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ (' . $this->nested_brackets_re . ') # link text = $2
+ \]
+
+ [ ]? # one optional space
+ (?:\n[ ]*)? # one optional newline followed by spaces
+
+ \[
+ (.*?) # id = $3
+ \]
+ )
+ }xs',
+ array($this, '_doAnchors_reference_callback'), $text);
+
+ // Next, inline-style links: [link text](url "optional title")
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ (' . $this->nested_brackets_re . ') # link text = $2
+ \]
+ \( # literal paren
+ [ \n]*
+ (?:
+ <(.+?)> # href = $3
+ |
+ (' . $this->nested_url_parenthesis_re . ') # href = $4
+ )
+ [ \n]*
+ ( # $5
+ ([\'"]) # quote char = $6
+ (.*?) # Title = $7
+ \6 # matching quote
+ [ \n]* # ignore any spaces/tabs between closing quote and )
+ )? # title is optional
+ \)
+ (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes
+ )
+ }xs',
+ array($this, '_doAnchors_inline_callback'), $text);
+
+ // Last, handle reference-style shortcuts: [link text]
+ // These must come last in case you've also got [link text][1]
+ // or [link text](/foo)
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ ([^\[\]]+) # link text = $2; can\'t contain [ or ]
+ \]
+ )
+ }xs',
+ array($this, '_doAnchors_reference_callback'), $text);
+
+ $this->in_anchor = false;
+ return $text;
+ }
+
+ /**
+ * Callback for reference anchors
+ * @param array $matches
+ * @return string
+ */
+ protected function _doAnchors_reference_callback($matches) {
+ $whole_match = $matches[1];
+ $link_text = $matches[2];
+ $link_id =& $matches[3];
+
+ if ($link_id == "") {
+ // for shortcut links like [this][] or [this].
+ $link_id = $link_text;
+ }
+
+ // lower-case and turn embedded newlines into spaces
+ $link_id = strtolower($link_id);
+ $link_id = preg_replace('{[ ]?\n}', ' ', $link_id);
+
+ if (isset($this->urls[$link_id])) {
+ $url = $this->urls[$link_id];
+ $url = $this->encodeURLAttribute($url);
+
+ $result = " titles[$link_id] ) ) {
+ $title = $this->titles[$link_id];
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ if (isset($this->ref_attr[$link_id]))
+ $result .= $this->ref_attr[$link_id];
+
+ $link_text = $this->runSpanGamut($link_text);
+ $result .= ">$link_text ";
+ $result = $this->hashPart($result);
+ }
+ else {
+ $result = $whole_match;
+ }
+ return $result;
+ }
+
+ /**
+ * Callback for inline anchors
+ * @param array $matches
+ * @return string
+ */
+ protected function _doAnchors_inline_callback($matches) {
+ $link_text = $this->runSpanGamut($matches[2]);
+ $url = $matches[3] === '' ? $matches[4] : $matches[3];
+ $title =& $matches[7];
+ $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
+
+ // if the URL was of the form
it got caught by the HTML
+ // tag parser and hashed. Need to reverse the process before using the URL.
+ $unhashed = $this->unhash($url);
+ if ($unhashed !== $url)
+ $url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
+
+ $url = $this->encodeURLAttribute($url);
+
+ $result = "encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ $result .= $attr;
+
+ $link_text = $this->runSpanGamut($link_text);
+ $result .= ">$link_text ";
+
+ return $this->hashPart($result);
+ }
+
+ /**
+ * Turn Markdown image shortcuts into tags.
+ * @param string $text
+ * @return string
+ */
+ protected function doImages($text) {
+ // First, handle reference-style labeled images: ![alt text][id]
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ (' . $this->nested_brackets_re . ') # alt text = $2
+ \]
+
+ [ ]? # one optional space
+ (?:\n[ ]*)? # one optional newline followed by spaces
+
+ \[
+ (.*?) # id = $3
+ \]
+
+ )
+ }xs',
+ array($this, '_doImages_reference_callback'), $text);
+
+ // Next, handle inline images: 
+ // Don't forget: encode * and _
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ (' . $this->nested_brackets_re . ') # alt text = $2
+ \]
+ \s? # One optional whitespace character
+ \( # literal paren
+ [ \n]*
+ (?:
+ <(\S*)> # src url = $3
+ |
+ (' . $this->nested_url_parenthesis_re . ') # src url = $4
+ )
+ [ \n]*
+ ( # $5
+ ([\'"]) # quote char = $6
+ (.*?) # title = $7
+ \6 # matching quote
+ [ \n]*
+ )? # title is optional
+ \)
+ (?:[ ]? ' . $this->id_class_attr_catch_re . ' )? # $8 = id/class attributes
+ )
+ }xs',
+ array($this, '_doImages_inline_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback for referenced images
+ * @param array $matches
+ * @return string
+ */
+ protected function _doImages_reference_callback($matches) {
+ $whole_match = $matches[1];
+ $alt_text = $matches[2];
+ $link_id = strtolower($matches[3]);
+
+ if ($link_id === "") {
+ $link_id = strtolower($alt_text); // for shortcut links like ![this][].
+ }
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ if (isset($this->urls[$link_id])) {
+ $url = $this->encodeURLAttribute($this->urls[$link_id]);
+ $result = " titles[$link_id])) {
+ $title = $this->titles[$link_id];
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ if (isset($this->ref_attr[$link_id])) {
+ $result .= $this->ref_attr[$link_id];
+ }
+ $result .= $this->empty_element_suffix;
+ $result = $this->hashPart($result);
+ }
+ else {
+ // If there's no such link ID, leave intact:
+ $result = $whole_match;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Callback for inline images
+ * @param array $matches
+ * @return string
+ */
+ protected function _doImages_inline_callback($matches) {
+ $alt_text = $matches[2];
+ $url = $matches[3] === '' ? $matches[4] : $matches[3];
+ $title =& $matches[7];
+ $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ $url = $this->encodeURLAttribute($url);
+ $result = " encodeAttribute($title);
+ $result .= " title=\"$title\""; // $title already quoted
+ }
+ $result .= $attr;
+ $result .= $this->empty_element_suffix;
+
+ return $this->hashPart($result);
+ }
+
+ /**
+ * Process markdown headers. Redefined to add ID and class attribute support.
+ * @param string $text
+ * @return string
+ */
+ protected function doHeaders($text) {
+ // Setext-style headers:
+ // Header 1 {#header1}
+ // ========
+ //
+ // Header 2 {#header2 .class1 .class2}
+ // --------
+ //
+ $text = preg_replace_callback(
+ '{
+ (^.+?) # $1: Header text
+ (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes
+ [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer
+ }mx',
+ array($this, '_doHeaders_callback_setext'), $text);
+
+ // atx-style headers:
+ // # Header 1 {#header1}
+ // ## Header 2 {#header2}
+ // ## Header 2 with closing hashes ## {#header3.class1.class2}
+ // ...
+ // ###### Header 6 {.class2}
+ //
+ $text = preg_replace_callback('{
+ ^(\#{1,6}) # $1 = string of #\'s
+ [ ]'.($this->hashtag_protection ? '+' : '*').'
+ (.+?) # $2 = Header text
+ [ ]*
+ \#* # optional closing #\'s (not counted)
+ (?:[ ]+ ' . $this->id_class_attr_catch_re . ' )? # $3 = id/class attributes
+ [ ]*
+ \n+
+ }xm',
+ array($this, '_doHeaders_callback_atx'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback for setext headers
+ * @param array $matches
+ * @return string
+ */
+ protected function _doHeaders_callback_setext($matches) {
+ if ($matches[3] === '-' && preg_match('{^- }', $matches[1])) {
+ return $matches[0];
+ }
+
+ $level = $matches[3][0] === '=' ? 1 : 2;
+
+ $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
+
+ $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2], $defaultId);
+ $block = "" . $this->runSpanGamut($matches[1]) . " ";
+ return "\n" . $this->hashBlock($block) . "\n\n";
+ }
+
+ /**
+ * Callback for atx headers
+ * @param array $matches
+ * @return string
+ */
+ protected function _doHeaders_callback_atx($matches) {
+ $level = strlen($matches[1]);
+
+ $defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[2]) : null;
+ $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3], $defaultId);
+ $block = "" . $this->runSpanGamut($matches[2]) . " ";
+ return "\n" . $this->hashBlock($block) . "\n\n";
+ }
+
+ /**
+ * Form HTML tables.
+ * @param string $text
+ * @return string
+ */
+ protected function doTables($text) {
+ $less_than_tab = $this->tab_width - 1;
+ // Find tables with leading pipe.
+ //
+ // | Header 1 | Header 2
+ // | -------- | --------
+ // | Cell 1 | Cell 2
+ // | Cell 3 | Cell 4
+ $text = preg_replace_callback('
+ {
+ ^ # Start of a line
+ [ ]{0,' . $less_than_tab . '} # Allowed whitespace.
+ [|] # Optional leading pipe (present)
+ (.+) \n # $1: Header row (at least one pipe)
+
+ [ ]{0,' . $less_than_tab . '} # Allowed whitespace.
+ [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline
+
+ ( # $3: Cells
+ (?>
+ [ ]* # Allowed whitespace.
+ [|] .* \n # Row content.
+ )*
+ )
+ (?=\n|\Z) # Stop at final double newline.
+ }xm',
+ array($this, '_doTable_leadingPipe_callback'), $text);
+
+ // Find tables without leading pipe.
+ //
+ // Header 1 | Header 2
+ // -------- | --------
+ // Cell 1 | Cell 2
+ // Cell 3 | Cell 4
+ $text = preg_replace_callback('
+ {
+ ^ # Start of a line
+ [ ]{0,' . $less_than_tab . '} # Allowed whitespace.
+ (\S.*[|].*) \n # $1: Header row (at least one pipe)
+
+ [ ]{0,' . $less_than_tab . '} # Allowed whitespace.
+ ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline
+
+ ( # $3: Cells
+ (?>
+ .* [|] .* \n # Row content
+ )*
+ )
+ (?=\n|\Z) # Stop at final double newline.
+ }xm',
+ array($this, '_DoTable_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback for removing the leading pipe for each row
+ * @param array $matches
+ * @return string
+ */
+ protected function _doTable_leadingPipe_callback($matches) {
+ $head = $matches[1];
+ $underline = $matches[2];
+ $content = $matches[3];
+
+ $content = preg_replace('/^ *[|]/m', '', $content);
+
+ return $this->_doTable_callback(array($matches[0], $head, $underline, $content));
+ }
+
+ /**
+ * Make the align attribute in a table
+ * @param string $alignname
+ * @return string
+ */
+ protected function _doTable_makeAlignAttr($alignname) {
+ if (empty($this->table_align_class_tmpl)) {
+ return " align=\"$alignname\"";
+ }
+
+ $classname = str_replace('%%', $alignname, $this->table_align_class_tmpl);
+ return " class=\"$classname\"";
+ }
+
+ /**
+ * Calback for processing tables
+ * @param array $matches
+ * @return string
+ */
+ protected function _doTable_callback($matches) {
+ $head = $matches[1];
+ $underline = $matches[2];
+ $content = $matches[3];
+
+ // Remove any tailing pipes for each line.
+ $head = preg_replace('/[|] *$/m', '', $head);
+ $underline = preg_replace('/[|] *$/m', '', $underline);
+ $content = preg_replace('/[|] *$/m', '', $content);
+
+ // Reading alignement from header underline.
+ $separators = preg_split('/ *[|] */', $underline);
+ foreach ($separators as $n => $s) {
+ if (preg_match('/^ *-+: *$/', $s))
+ $attr[$n] = $this->_doTable_makeAlignAttr('right');
+ else if (preg_match('/^ *:-+: *$/', $s))
+ $attr[$n] = $this->_doTable_makeAlignAttr('center');
+ else if (preg_match('/^ *:-+ *$/', $s))
+ $attr[$n] = $this->_doTable_makeAlignAttr('left');
+ else
+ $attr[$n] = '';
+ }
+
+ // Parsing span elements, including code spans, character escapes,
+ // and inline HTML tags, so that pipes inside those gets ignored.
+ $head = $this->parseSpan($head);
+ $headers = preg_split('/ *[|] */', $head);
+ $col_count = count($headers);
+ $attr = array_pad($attr, $col_count, '');
+
+ // Write column headers.
+ $text = "\n";
+ $text .= "\n";
+ $text .= "\n";
+ foreach ($headers as $n => $header) {
+ $text .= " " . $this->runSpanGamut(trim($header)) . " \n";
+ }
+ $text .= " \n";
+ $text .= " \n";
+
+ // Split content by row.
+ $rows = explode("\n", trim($content, "\n"));
+
+ $text .= "\n";
+ foreach ($rows as $row) {
+ // Parsing span elements, including code spans, character escapes,
+ // and inline HTML tags, so that pipes inside those gets ignored.
+ $row = $this->parseSpan($row);
+
+ // Split row by cell.
+ $row_cells = preg_split('/ *[|] */', $row, $col_count);
+ $row_cells = array_pad($row_cells, $col_count, '');
+
+ $text .= "\n";
+ foreach ($row_cells as $n => $cell) {
+ $text .= " " . $this->runSpanGamut(trim($cell)) . " \n";
+ }
+ $text .= " \n";
+ }
+ $text .= " \n";
+ $text .= "
";
+
+ return $this->hashBlock($text) . "\n";
+ }
+
+ /**
+ * Form HTML definition lists.
+ * @param string $text
+ * @return string
+ */
+ protected function doDefLists($text) {
+ $less_than_tab = $this->tab_width - 1;
+
+ // Re-usable pattern to match any entire dl list:
+ $whole_list_re = '(?>
+ ( # $1 = whole list
+ ( # $2
+ [ ]{0,' . $less_than_tab . '}
+ ((?>.*\S.*\n)+) # $3 = defined term
+ \n?
+ [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
+ )
+ (?s:.+?)
+ ( # $4
+ \z
+ |
+ \n{2,}
+ (?=\S)
+ (?! # Negative lookahead for another term
+ [ ]{0,' . $less_than_tab . '}
+ (?: \S.*\n )+? # defined term
+ \n?
+ [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
+ )
+ (?! # Negative lookahead for another definition
+ [ ]{0,' . $less_than_tab . '}:[ ]+ # colon starting definition
+ )
+ )
+ )
+ )'; // mx
+
+ $text = preg_replace_callback('{
+ (?>\A\n?|(?<=\n\n))
+ ' . $whole_list_re . '
+ }mx',
+ array($this, '_doDefLists_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback for processing definition lists
+ * @param array $matches
+ * @return string
+ */
+ protected function _doDefLists_callback($matches) {
+ // Re-usable patterns to match list item bullets and number markers:
+ $list = $matches[1];
+
+ // Turn double returns into triple returns, so that we can make a
+ // paragraph for the last item in a list, if necessary:
+ $result = trim($this->processDefListItems($list));
+ $result = "\n" . $result . "\n ";
+ return $this->hashBlock($result) . "\n\n";
+ }
+
+ /**
+ * Process the contents of a single definition list, splitting it
+ * into individual term and definition list items.
+ * @param string $list_str
+ * @return string
+ */
+ protected function processDefListItems($list_str) {
+
+ $less_than_tab = $this->tab_width - 1;
+
+ // Trim trailing blank lines:
+ $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);
+
+ // Process definition terms.
+ $list_str = preg_replace_callback('{
+ (?>\A\n?|\n\n+) # leading line
+ ( # definition terms = $1
+ [ ]{0,' . $less_than_tab . '} # leading whitespace
+ (?!\:[ ]|[ ]) # negative lookahead for a definition
+ # mark (colon) or more whitespace.
+ (?> \S.* \n)+? # actual term (not whitespace).
+ )
+ (?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed
+ # with a definition mark.
+ }xm',
+ array($this, '_processDefListItems_callback_dt'), $list_str);
+
+ // Process actual definitions.
+ $list_str = preg_replace_callback('{
+ \n(\n+)? # leading line = $1
+ ( # marker space = $2
+ [ ]{0,' . $less_than_tab . '} # whitespace before colon
+ \:[ ]+ # definition mark (colon)
+ )
+ ((?s:.+?)) # definition text = $3
+ (?= \n+ # stop at next definition mark,
+ (?: # next term or end of text
+ [ ]{0,' . $less_than_tab . '} \:[ ] |
+ | \z
+ )
+ )
+ }xm',
+ array($this, '_processDefListItems_callback_dd'), $list_str);
+
+ return $list_str;
+ }
+
+ /**
+ * Callback for elements in definition lists
+ * @param array $matches
+ * @return string
+ */
+ protected function _processDefListItems_callback_dt($matches) {
+ $terms = explode("\n", trim($matches[1]));
+ $text = '';
+ foreach ($terms as $term) {
+ $term = $this->runSpanGamut(trim($term));
+ $text .= "\n" . $term . " ";
+ }
+ return $text . "\n";
+ }
+
+ /**
+ * Callback for elements in definition lists
+ * @param array $matches
+ * @return string
+ */
+ protected function _processDefListItems_callback_dd($matches) {
+ $leading_line = $matches[1];
+ $marker_space = $matches[2];
+ $def = $matches[3];
+
+ if ($leading_line || preg_match('/\n{2,}/', $def)) {
+ // Replace marker with the appropriate whitespace indentation
+ $def = str_repeat(' ', strlen($marker_space)) . $def;
+ $def = $this->runBlockGamut($this->outdent($def . "\n\n"));
+ $def = "\n". $def ."\n";
+ }
+ else {
+ $def = rtrim($def);
+ $def = $this->runSpanGamut($this->outdent($def));
+ }
+
+ return "\n" . $def . " \n";
+ }
+
+ /**
+ * Adding the fenced code block syntax to regular Markdown:
+ *
+ * ~~~
+ * Code block
+ * ~~~
+ *
+ * @param string $text
+ * @return string
+ */
+ protected function doFencedCodeBlocks($text) {
+
+ $text = preg_replace_callback('{
+ (?:\n|\A)
+ # 1: Opening marker
+ (
+ (?:~{3,}|`{3,}) # 3 or more tildes/backticks.
+ )
+ [ ]*
+ (?:
+ \.?([-_:a-zA-Z0-9]+) # 2: standalone class name
+ )?
+ [ ]*
+ (?:
+ ' . $this->id_class_attr_catch_re . ' # 3: Extra attributes
+ )?
+ [ ]* \n # Whitespace and newline following marker.
+
+ # 4: Content
+ (
+ (?>
+ (?!\1 [ ]* \n) # Not a closing marker.
+ .*\n+
+ )+
+ )
+
+ # Closing marker.
+ \1 [ ]* (?= \n )
+ }xm',
+ array($this, '_doFencedCodeBlocks_callback'), $text);
+
+ return $text;
+ }
+
+ /**
+ * Callback to process fenced code blocks
+ * @param array $matches
+ * @return string
+ */
+ protected function _doFencedCodeBlocks_callback($matches) {
+ $classname =& $matches[2];
+ $attrs =& $matches[3];
+ $codeblock = $matches[4];
+
+ if ($this->code_block_content_func) {
+ $codeblock = call_user_func($this->code_block_content_func, $codeblock, $classname);
+ } else {
+ $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
+ }
+
+ $codeblock = preg_replace_callback('/^\n+/',
+ array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
+
+ $classes = array();
+ if ($classname !== "") {
+ if ($classname[0] === '.') {
+ $classname = substr($classname, 1);
+ }
+ $classes[] = $this->code_class_prefix . $classname;
+ }
+ $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
+ $pre_attr_str = $this->code_attr_on_pre ? $attr_str : '';
+ $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
+ $codeblock = "$codeblock
";
+
+ return "\n\n".$this->hashBlock($codeblock)."\n\n";
+ }
+
+ /**
+ * Replace new lines in fenced code blocks
+ * @param array $matches
+ * @return string
+ */
+ protected function _doFencedCodeBlocks_newlines($matches) {
+ return str_repeat(" empty_element_suffix",
+ strlen($matches[0]));
+ }
+
+ /**
+ * Redefining emphasis markers so that emphasis by underscore does not
+ * work in the middle of a word.
+ * @var array
+ */
+ protected $em_relist = array(
+ '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(? tags
+ * @return string HTML output
+ */
+ protected function formParagraphs($text, $wrap_in_p = true) {
+ // Strip leading and trailing lines:
+ $text = preg_replace('/\A\n+|\n+\z/', '', $text);
+
+ $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
+
+ // Wrap tags and unhashify HTML blocks
+ foreach ($grafs as $key => $value) {
+ $value = trim($this->runSpanGamut($value));
+
+ // Check if this should be enclosed in a paragraph.
+ // Clean tag hashes & block tag hashes are left alone.
+ $is_p = $wrap_in_p && !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value);
+
+ if ($is_p) {
+ $value = "
$value
";
+ }
+ $grafs[$key] = $value;
+ }
+
+ // Join grafs in one text, then unhash HTML tags.
+ $text = implode("\n\n", $grafs);
+
+ // Finish by removing any tag hashes still present in $text.
+ $text = $this->unhash($text);
+
+ return $text;
+ }
+
+
+ /**
+ * Footnotes - Strips link definitions from text, stores the URLs and
+ * titles in hash references.
+ * @param string $text
+ * @return string
+ */
+ protected function stripFootnotes($text) {
+ $less_than_tab = $this->tab_width - 1;
+
+ // Link defs are in the form: [^id]: url "optional title"
+ $text = preg_replace_callback('{
+ ^[ ]{0,' . $less_than_tab . '}\[\^(.+?)\][ ]?: # note_id = $1
+ [ ]*
+ \n? # maybe *one* newline
+ ( # text = $2 (no blank lines allowed)
+ (?:
+ .+ # actual text
+ |
+ \n # newlines but
+ (?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker.
+ (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed
+ # by non-indented content
+ )*
+ )
+ }xm',
+ array($this, '_stripFootnotes_callback'),
+ $text);
+ return $text;
+ }
+
+ /**
+ * Callback for stripping footnotes
+ * @param array $matches
+ * @return string
+ */
+ protected function _stripFootnotes_callback($matches) {
+ $note_id = $this->fn_id_prefix . $matches[1];
+ $this->footnotes[$note_id] = $this->outdent($matches[2]);
+ return ''; // String that will replace the block
+ }
+
+ /**
+ * Replace footnote references in $text [^id] with a special text-token
+ * which will be replaced by the actual footnote marker in appendFootnotes.
+ * @param string $text
+ * @return string
+ */
+ protected function doFootnotes($text) {
+ if (!$this->in_anchor) {
+ $text = preg_replace('{\[\^(.+?)\]}', "F\x1Afn:\\1\x1A:", $text);
+ }
+ return $text;
+ }
+
+ /**
+ * Append footnote list to text
+ * @param string $text
+ * @return string
+ */
+ protected function appendFootnotes($text) {
+ $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
+ array($this, '_appendFootnotes_callback'), $text);
+
+ if ( ! empty( $this->footnotes_ordered ) ) {
+ $this->_doFootnotes();
+ if ( ! $this->omit_footnotes ) {
+ $text .= "\n\n";
+ $text .= "";
+ }
+ }
+ return $text;
+ }
+
+
+ /**
+ * Generates the HTML for footnotes. Called by appendFootnotes, even if
+ * footnotes are not being appended.
+ * @return void
+ */
+ protected function _doFootnotes() {
+ $attr = array();
+ if ($this->fn_backlink_class !== "") {
+ $class = $this->fn_backlink_class;
+ $class = $this->encodeAttribute($class);
+ $attr['class'] = " class=\"$class\"";
+ }
+ $attr['role'] = " role=\"doc-backlink\"";
+ $num = 0;
+
+ $text = "\n\n";
+ while (!empty($this->footnotes_ordered)) {
+ $footnote = reset($this->footnotes_ordered);
+ $note_id = key($this->footnotes_ordered);
+ unset($this->footnotes_ordered[$note_id]);
+ $ref_count = $this->footnotes_ref_count[$note_id];
+ unset($this->footnotes_ref_count[$note_id]);
+ unset($this->footnotes[$note_id]);
+
+ $footnote .= "\n"; // Need to append newline before parsing.
+ $footnote = $this->runBlockGamut("$footnote\n");
+ $footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}',
+ array($this, '_appendFootnotes_callback'), $footnote);
+
+ $num++;
+ $note_id = $this->encodeAttribute($note_id);
+
+ // Prepare backlink, multiple backlinks if multiple references
+ // Do not create empty backlinks if the html is blank
+ $backlink = "";
+ if (!empty($this->fn_backlink_html)) {
+ for ($ref_num = 1; $ref_num <= $ref_count; ++$ref_num) {
+ if (!empty($this->fn_backlink_title)) {
+ $attr['title'] = ' title="' . $this->encodeAttribute($this->fn_backlink_title) . '"';
+ }
+ if (!empty($this->fn_backlink_label)) {
+ $attr['label'] = ' aria-label="' . $this->encodeAttribute($this->fn_backlink_label) . '"';
+ }
+ $parsed_attr = $this->parseFootnotePlaceholders(
+ implode('', $attr),
+ $num,
+ $ref_num
+ );
+ $backlink_text = $this->parseFootnotePlaceholders(
+ $this->fn_backlink_html,
+ $num,
+ $ref_num
+ );
+ $ref_count_mark = $ref_num > 1 ? $ref_num : '';
+ $backlink .= " $backlink_text ";
+ }
+ $backlink = trim($backlink);
+ }
+
+ // Add backlink to last paragraph; create new paragraph if needed.
+ if (!empty($backlink)) {
+ if (preg_match('{$}', $footnote)) {
+ $footnote = substr($footnote, 0, -4) . " $backlink";
+ } else {
+ $footnote .= "\n\n$backlink
";
+ }
+ }
+
+ $text .= "\n";
+ $text .= $footnote . "\n";
+ $text .= " \n\n";
+ }
+ $text .= " \n";
+
+ $this->footnotes_assembled = $text;
+ }
+
+ /**
+ * Callback for appending footnotes
+ * @param array $matches
+ * @return string
+ */
+ protected function _appendFootnotes_callback($matches) {
+ $node_id = $this->fn_id_prefix . $matches[1];
+
+ // Create footnote marker only if it has a corresponding footnote *and*
+ // the footnote hasn't been used by another marker.
+ if (isset($this->footnotes[$node_id])) {
+ $num =& $this->footnotes_numbers[$node_id];
+ if (!isset($num)) {
+ // Transfer footnote content to the ordered list and give it its
+ // number
+ $this->footnotes_ordered[$node_id] = $this->footnotes[$node_id];
+ $this->footnotes_ref_count[$node_id] = 1;
+ $num = $this->footnote_counter++;
+ $ref_count_mark = '';
+ } else {
+ $ref_count_mark = $this->footnotes_ref_count[$node_id] += 1;
+ }
+
+ $attr = "";
+ if ($this->fn_link_class !== "") {
+ $class = $this->fn_link_class;
+ $class = $this->encodeAttribute($class);
+ $attr .= " class=\"$class\"";
+ }
+ if ($this->fn_link_title !== "") {
+ $title = $this->fn_link_title;
+ $title = $this->encodeAttribute($title);
+ $attr .= " title=\"$title\"";
+ }
+ $attr .= " role=\"doc-noteref\"";
+
+ $attr = str_replace("%%", $num, $attr);
+ $node_id = $this->encodeAttribute($node_id);
+
+ return
+ "".
+ "$num ".
+ " ";
+ }
+
+ return "[^" . $matches[1] . "]";
+ }
+
+ /**
+ * Build footnote label by evaluating any placeholders.
+ * - ^^ footnote number
+ * - %% footnote reference number (Nth reference to footnote number)
+ * @param string $label
+ * @param int $footnote_number
+ * @param int $reference_number
+ * @return string
+ */
+ protected function parseFootnotePlaceholders($label, $footnote_number, $reference_number) {
+ return str_replace(
+ array('^^', '%%'),
+ array($footnote_number, $reference_number),
+ $label
+ );
+ }
+
+
+ /**
+ * Abbreviations - strips abbreviations from text, stores titles in hash
+ * references.
+ * @param string $text
+ * @return string
+ */
+ protected function stripAbbreviations($text) {
+ $less_than_tab = $this->tab_width - 1;
+
+ // Link defs are in the form: [id]*: url "optional title"
+ $text = preg_replace_callback('{
+ ^[ ]{0,' . $less_than_tab . '}\*\[(.+?)\][ ]?: # abbr_id = $1
+ (.*) # text = $2 (no blank lines allowed)
+ }xm',
+ array($this, '_stripAbbreviations_callback'),
+ $text);
+ return $text;
+ }
+
+ /**
+ * Callback for stripping abbreviations
+ * @param array $matches
+ * @return string
+ */
+ protected function _stripAbbreviations_callback($matches) {
+ $abbr_word = $matches[1];
+ $abbr_desc = $matches[2];
+ if ($this->abbr_word_re) {
+ $this->abbr_word_re .= '|';
+ }
+ $this->abbr_word_re .= preg_quote($abbr_word);
+ $this->abbr_desciptions[$abbr_word] = trim($abbr_desc);
+ return ''; // String that will replace the block
+ }
+
+ /**
+ * Find defined abbreviations in text and wrap them in elements.
+ * @param string $text
+ * @return string
+ */
+ protected function doAbbreviations($text) {
+ if ($this->abbr_word_re) {
+ // cannot use the /x modifier because abbr_word_re may
+ // contain significant spaces:
+ $text = preg_replace_callback('{' .
+ '(?abbr_word_re . ')' .
+ '(?![\w\x1A])' .
+ '}',
+ array($this, '_doAbbreviations_callback'), $text);
+ }
+ return $text;
+ }
+
+ /**
+ * Callback for processing abbreviations
+ * @param array $matches
+ * @return string
+ */
+ protected function _doAbbreviations_callback($matches) {
+ $abbr = $matches[0];
+ if (isset($this->abbr_desciptions[$abbr])) {
+ $desc = $this->abbr_desciptions[$abbr];
+ if (empty($desc)) {
+ return $this->hashPart("$abbr ");
+ }
+ $desc = $this->encodeAttribute($desc);
+ return $this->hashPart("$abbr ");
+ }
+ return $matches[0];
+ }
+}
+
+// Markdown parser, Copyright Datenstrom, License GPLv2
+
+class YellowMarkdownParser extends MarkdownExtraParser {
+ public $yellow; // access to API
+ public $page; // access to page
+ public $idAttributes; // id attributes
+ public $noticeLevel; // recursive level
+
+ public function __construct($yellow, $page) {
+ $this->yellow = $yellow;
+ $this->page = $page;
+ $this->idAttributes = array();
+ $this->noticeLevel = 0;
+ $this->url_filter_func = function($url) use ($yellow, $page) {
+ return $yellow->lookup->normaliseLocation($url, $page->location);
+ };
+ $this->span_gamut += array("doStrikethrough" => 55);
+ $this->block_gamut += array("doNoticeBlocks" => 65);
+ $this->escape_chars .= "~";
+ parent::__construct();
+ }
+
+ // Handle striketrough
+ public function doStrikethrough($text) {
+ $parts = preg_split("/(?3) {
+ $text = "";
+ $open = false;
+ foreach ($parts as $part) {
+ if ($part=="~~") {
+ $text .= $open ? "" : "";
+ $open = !$open;
+ } else {
+ $text .= $part;
+ }
+ }
+ if ($open) $text .= "";
+ }
+ return $text;
+ }
+
+ // Handle links
+ public function doAutoLinks($text) {
+ $text = preg_replace_callback("/<(\w+:[^\'\">\s]+)>/", array($this, "_doAutoLinks_url_callback"), $text);
+ $text = preg_replace_callback("/<([\w\+\-\.]+@[\w\-\.]+)>/", array($this, "_doAutoLinks_email_callback"), $text);
+ $text = preg_replace_callback("/^\s*\[(\w+)(.*?)\]\s*$/", array($this, "_doAutoLinks_shortcutBlock_callback"), $text);
+ $text = preg_replace_callback("/\[(\w+)(.*?)\]/", array($this, "_doAutoLinks_shortcutInline_callback"), $text);
+ $text = preg_replace_callback("/\[\-\-(.*?)\-\-\]/", array($this, "_doAutoLinks_shortcutComment_callback"), $text);
+ $text = preg_replace_callback("/\:([\w\+\-\_]+)\:/", array($this, "_doAutoLinks_shortcutSymbol_callback"), $text);
+ $text = preg_replace_callback("/((http|https|ftp):\/\/\S+[^\'\"\,\.\;\:\*\~\s]+)/", array($this, "_doAutoLinks_url_callback"), $text);
+ $text = preg_replace_callback("/([\w\+\-\.]+@[\w\-\.]+\.[\w]{2,4})/", array($this, "_doAutoLinks_email_callback"), $text);
+ return $text;
+ }
+
+ // Handle shortcuts, block style
+ public function _doAutoLinks_shortcutBlock_callback($matches) {
+ $output = $this->page->parseContentShortcut($matches[1], trim($matches[2]), "block");
+ return is_null($output) ? $matches[0] : $this->hashBlock($output);
+ }
+
+ // Handle shortcuts, inline style
+ public function _doAutoLinks_shortcutInline_callback($matches) {
+ $output = $this->page->parseContentShortcut($matches[1], trim($matches[2]), "inline");
+ return is_null($output) ? $matches[0] : $this->hashPart($output);
+ }
+
+ // Handle shortcuts, comment style
+ public function _doAutoLinks_shortcutComment_callback($matches) {
+ $output = "";
+ return $this->hashBlock($output);
+ }
+
+ // Handle shortcuts, symbol style
+ public function _doAutoLinks_shortcutSymbol_callback($matches) {
+ $output = $this->page->parseContentShortcut("", $matches[1], "symbol");
+ return is_null($output) ? $matches[0] : $this->hashPart($output);
+ }
+
+ // Handle fenced code blocks
+ public function _doFencedCodeBlocks_callback($matches) {
+ $text = $matches[4];
+ $name = empty($matches[2]) ? "" : trim("$matches[2] $matches[3]");
+ $output = $this->page->parseContentShortcut($name, $text, "code");
+ if (is_null($output)) {
+ $attr = $this->doExtraAttributes("pre", ".$matches[2] $matches[3]");
+ $output = "".htmlspecialchars($text, ENT_NOQUOTES)."
";
+ }
+ return "\n\n".$this->hashBlock($output)."\n\n";
+ }
+
+ // Handle headers, text style
+ public function _doHeaders_callback_setext($matches) {
+ if ($matches[3]=="-" && preg_match('{^- }', $matches[1])) return $matches[0];
+ $text = $matches[1];
+ $level = $matches[3][0]=="=" ? 1 : 2;
+ $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2]);
+ if (empty($attr) && $level>=2 && $level<=3) $attr = $this->getIdAttribute($text);
+ $output = "".$this->runSpanGamut($text)." ";
+ return "\n".$this->hashBlock($output)."\n\n";
+ }
+
+ // Handle headers, atx style
+ public function _doHeaders_callback_atx($matches) {
+ $text = $matches[2];
+ $level = strlen($matches[1]);
+ $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3]);
+ if (empty($attr) && $level>=2 && $level<=3) $attr = $this->getIdAttribute($text);
+ $output = "".$this->runSpanGamut($text)." ";
+ return "\n".$this->hashBlock($output)."\n\n";
+ }
+
+ // Handle inline links
+ public function _doAnchors_inline_callback($matches) {
+ $url = $matches[3]=="" ? $matches[4] : $matches[3];
+ $text = $matches[2];
+ $title = isset($matches[7]) ? $matches[7] : "";
+ $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
+ $output = "encodeURLAttribute($url)."\"";
+ if (!empty($title)) $output .= " title=\"".$this->encodeAttribute($title)."\"";
+ $output .= $attr;
+ $output .= ">".$this->runSpanGamut($text)." ";
+ return $this->hashPart($output);
+ }
+
+ // Handle inline images
+ public function _doImages_inline_callback($matches) {
+ $src = $matches[3]=="" ? $matches[4] : $matches[3];
+ if (!preg_match("/^\w+:/", $src)) {
+ $src = $this->yellow->system->get("coreServerBase").$this->yellow->system->get("coreImageLocation").$src;
+ }
+ $alt = $matches[2];
+ $title = isset($matches[7]) ? $matches[7] : $matches[2];
+ $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
+ $output = " encodeURLAttribute($src)."\"";
+ if (!empty($alt)) $output .= " alt=\"".$this->encodeAttribute($alt)."\"";
+ if (!empty($title)) $output .= " title=\"".$this->encodeAttribute($title)."\"";
+ $output .= $attr;
+ $output .= $this->empty_element_suffix;
+ return $this->hashPart($output);
+ }
+
+ // Handle lists, task list
+ public function _processListItems_callback($matches) {
+ $attr = "";
+ $item = $matches[4];
+ $leadingLine = $matches[1];
+ $tailingLine = $matches[5];
+ if ($leadingLine || $tailingLine || preg_match('/\n{2,}/', $item))
+ {
+ $item = $matches[2].str_repeat(' ', strlen($matches[3])).$item;
+ $item = $this->runBlockGamut($this->outdent($item)."\n");
+ } else {
+ $item = $this->doLists($this->outdent($item));
+ $item = $this->formParagraphs($item, false);
+ $token = substr($item, 0, 4);
+ if ($token=="[ ] " || $token=="[x] ") {
+ $attr = " class=\"task-list-item\"";
+ $item = ($token=='[ ] ' ? " " :
+ " ").substr($item, 4);
+ }
+ }
+ return "".$item." \n";
+ }
+
+ // Handle notice blocks
+ public function doNoticeBlocks($text) {
+ return preg_replace_callback("/((?>^[ ]*!(?!\[)[ ]?.+\n(.+\n)*)+)/m", array($this, "_doNoticeBlocks_callback"), $text);
+ }
+
+ // Handle notice blocks over multiple lines
+ public function _doNoticeBlocks_callback($matches) {
+ $lines = $matches[1];
+ $attr = "";
+ $text = preg_replace("/^[ ]*![ ]?/m", "", $lines);
+ if (preg_match("/^[ ]*".$this->id_class_attr_catch_re."[ ]*\n([\S\s]*)$/m", $text, $matches)) {
+ $attr = $this->doExtraAttributes("div", $dummy =& $matches[1]);
+ $text = $matches[2];
+ } elseif ($this->noticeLevel==0) {
+ $level = strspn(str_replace(array("![", " "), "", $lines), "!");
+ $attr = " class=\"notice$level\"";
+ }
+ if (!empty($text)) {
+ ++$this->noticeLevel;
+ $output = "\n".$this->runBlockGamut($text)."\n
";
+ --$this->noticeLevel;
+ } else {
+ $output = "
";
+ }
+ return "\n".$this->hashBlock($output)."\n\n";
+ }
+
+ // Return unique id attribute
+ public function getIdAttribute($text) {
+ $attr = "";
+ $text = $this->yellow->lookup->normaliseName($text, true, false, true);
+ $text = trim(preg_replace("/-+/", "-", $text), "-");
+ if (!isset($this->idAttributes[$text])) {
+ $this->idAttributes[$text] = $text;
+ $attr = " id=\"$text\"";
+ }
+ return $attr;
+ }
+}
diff --git a/system/extensions/meta.php b/system/extensions/meta.php
new file mode 100644
index 0000000..11cd730
--- /dev/null
+++ b/system/extensions/meta.php
@@ -0,0 +1,65 @@
+yellow = $yellow;
+ $this->yellow->system->setDefault("metaDefaultImage", "favicon");
+ }
+
+ // Handle page extra data
+ public function onParsePageExtra($page, $name) {
+ $output = null;
+ if ($name=="header" && !$page->isError()) {
+ list($imageUrl, $imageAlt) = $this->getImageInformation($page);
+ $locale = $this->yellow->language->getText("languageLocale", $page->get("language"));
+ $output .= " getUrl().$this->yellow->toolbox->getLocationArguments())."\" />\n";
+ $output .= " \n";
+ $output .= " \n";
+ $output .= " getHtml("title")."\" />\n";
+ $output .= " getHtml("sitename")."\" />\n";
+ $output .= " getHtml("description")."\" />\n";
+ $output .= " \n";
+ $output .= " \n";
+ }
+ return $output;
+ }
+
+ // Handle page output data
+ public function onParsePageOutput($page, $text) {
+ $output = null;
+ if ($text && preg_match("/^(.*?)(.*)$/s", $text, $matches)) {
+ $output = $matches[1]."".$matches[3];
+ }
+ return $output;
+ }
+
+ // Return image information for page
+ public function getImageInformation($page) {
+ if ($page->isExisting("image")) {
+ $name = $page->get("image");
+ $alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title");
+ } elseif (preg_match("/\[image(\s.*?)\]/", $page->getContent(true), $matches)) {
+ list($name, $alt) = $this->yellow->toolbox->getTextArguments(trim($matches[1]));
+ if (empty($alt)) $alt = $page->get("title");
+ } else {
+ $name = $this->yellow->system->get("metaDefaultImage");
+ $alt = $page->isExisting("imageAlt") ? $page->get("imageAlt") : $page->get("title");
+ }
+ if (!preg_match("/^\w+:/", $name)) {
+ $location = $name!="favicon" ? $this->yellow->system->get("coreImageLocation").$name :
+ $this->yellow->system->get("coreThemeLocation").$this->yellow->lookup->normaliseName($page->get("theme")).".png";
+ $url = $this->yellow->lookup->normaliseUrl(
+ $this->yellow->system->get("coreServerScheme"),
+ $this->yellow->system->get("coreServerAddress"),
+ $this->yellow->system->get("coreServerBase"), $location);
+ } else {
+ $url = $this->yellow->lookup->normaliseUrl("", "", "", $name);
+ }
+ return array($url, $alt);
+ }
+}
diff --git a/system/extensions/stockholm.php b/system/extensions/stockholm.php
new file mode 100644
index 0000000..528898c
--- /dev/null
+++ b/system/extensions/stockholm.php
@@ -0,0 +1,23 @@
+yellow = $yellow;
+ }
+
+ // Handle update
+ public function onUpdate($action) {
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
+ if ($action=="install") {
+ $this->yellow->system->save($fileName, array("theme" => "stockholm"));
+ } elseif ($action=="uninstall" && $this->yellow->system->get("theme")=="stockholm") {
+ $theme = reset(array_diff($this->yellow->system->getValues("theme"), array("stockholm")));
+ $this->yellow->system->save($fileName, array("theme" => $theme));
+ }
+ }
+}
diff --git a/system/extensions/update-current.ini b/system/extensions/update-current.ini
new file mode 100644
index 0000000..e4dffa8
--- /dev/null
+++ b/system/extensions/update-current.ini
@@ -0,0 +1,133 @@
+# Datenstrom Yellow update settings
+
+Extension: Bundle
+Version: 0.8.15
+Description: Bundle website files.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/bundle
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/bundle.zip
+Published: 2020-07-29 10:13:34
+Developer: Datenstrom
+Tag: feature
+system/extensions/bundle.php: bundle.php,create,update
+
+Extension: Command
+Version: 0.8.22
+Description: Command line of the website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/command
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/command.zip
+Published: 2020-08-08 16:53:28
+Developer: Datenstrom
+Tag: feature
+system/extensions/command.php: command.php,create,update
+
+Extension: Core
+Version: 0.8.19
+Description: Core functionality of the website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip
+Published: 2020-08-08 17:14:56
+Developer: Datenstrom
+Tag: feature
+system/extensions/core.php: core.php,create,update
+
+Extension: Edit
+Version: 0.8.35
+Description: Edit your website in a web browser.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/edit
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/edit.zip
+Published: 2020-08-06 23:26:40
+Developer: Datenstrom
+Tag: feature
+system/extensions/edit.php: edit.php,create,update
+system/extensions/edit.css: edit.css,create,update
+system/extensions/edit.js: edit.js,create,update
+system/extensions/edit.woff: edit.woff,create,update
+
+Extension: Image
+Version: 0.8.9
+Description: Images and thumbnails.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/image
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/image.zip
+Published: 2020-07-26 16:01:58
+Developer: Datenstrom
+Tag: feature
+system/extensions/image.php: image.php,create,update
+
+Extension: Markdown
+Version: 0.8.15
+Description: Text formatting for humans.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/markdown
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/markdown.zip
+Published: 2020-07-26 16:03:56
+Developer: Datenstrom
+Tag: feature
+system/extensions/markdown.php: markdown.php,create,update
+system/extensions/markdownx.php: markdownx.php,update
+
+Extension: Meta
+Version: 0.8.14
+Description: Meta data for social media sites.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/meta
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/meta.zip
+Published: 2020-07-26 16:03:37
+Developer: Datenstrom, Steffen Schultz
+Tag: feature
+system/extensions/meta.php: meta.php,create,update
+
+Extension: Stockholm
+Version: 0.8.9
+Description: Stockholm is a clean theme.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/stockholm
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/stockholm.zip
+Published: 2020-07-26 15:14:23
+Designer: Datenstrom
+Tag: theme
+system/extensions/stockholm.php: stockholm.php,create,update
+system/themes/stockholm.css: stockholm.css,create,update,careful
+system/themes/stockholm.png: stockholm.png,create
+system/themes/stockholm-opensans-bold.woff: stockholm-opensans-bold.woff,create,update,careful
+system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff,create,update,careful
+system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff,create,update,careful
+
+Extension: Update
+Version: 0.8.31
+Description: Keep your website up to date.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
+Published: 2020-08-08 16:53:43
+Developer: Datenstrom
+Tag: feature
+system/extensions/update.php: update.php,create,update
+
+Extension: English
+Version: 0.8.24
+Description: English/English with language 'en'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/english
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/english.zip
+Published: 2020-08-12 10:00:22
+Translator: Mark Seuffert
+Tag: language
+system/extensions/english.php: english.php,create,update
+system/extensions/english.txt: english.txt,create,update
+
+Extension: French
+Version: 0.8.24
+Description: French/Français with language 'fr'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/french
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/french.zip
+Published: 2020-08-12 10:00:23
+Translator: Juh Nibreh
+Tag: language
+system/extensions/french.php: french.php,create,update
+system/extensions/french.txt: french.txt,create,update
+
+Extension: German
+Version: 0.8.24
+Description: German/Deutsch with language 'de'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/german
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/german.zip
+Published: 2020-08-12 10:00:24
+Translator: David Fehrmann
+Tag: language
+system/extensions/german.php: german.php,create,update
+system/extensions/german.txt: german.txt,create,update
diff --git a/system/extensions/update-latest.ini b/system/extensions/update-latest.ini
new file mode 100644
index 0000000..c159f66
--- /dev/null
+++ b/system/extensions/update-latest.ini
@@ -0,0 +1,787 @@
+# Datenstrom Yellow update settings
+
+Extension: About
+Version: 0.8.7
+Description: Author profile for blog pages.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/about
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/about.zip
+Published: 2020-08-12 14:53:26
+Developer: Steffen Schultz
+Tag: feature
+system/extensions/about.php: about.php,create,update
+content/about/page.md: page.md,create,optional
+
+Extension: Antispam
+Version: 0.8.6
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/antispam
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/antispam.zip
+Tag: feature, email, antispam
+Description: Alternative email address obfuscator.
+Published: 2020-07-29 11:52:15
+Developer: Steffen Schultz
+system/extensions/antispam.php: antispam.php,create,update
+system/extensions/antispam.js: antispam.js,create,update
+
+Extension: Audio
+Version: 0.8.7
+Tag: feature, audio, streaming
+Description: HTML5 audio player.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/audio
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/audio.zip
+Published: 2020-07-29 12:04:07
+Developer: Steffen Schultz
+system/extensions/audio.php: audio.php,create,update
+system/layouts/audio.html: audio.html,create,update,careful
+content/audio/page.md: page.md,create,optional
+
+Extension: Berlin
+Version: 0.8.9
+Description: Berlin is a theme inspired by Dieter Rams.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/berlin
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/berlin.zip
+Published: 2020-07-26 15:14:48
+Designer: Datenstrom
+Tag: theme
+system/extensions/berlin.php: berlin.php,create,update
+system/layouts/berlin-default.html: berlin-default.html,create,update,careful
+system/themes/berlin.css: berlin.css,create,update,careful
+system/themes/berlin.png: berlin.png,create
+system/themes/berlin-opensans-bold.woff: berlin-opensans-bold.woff,create,update,careful
+system/themes/berlin-opensans-light.woff: berlin-opensans-light.woff,create,update,careful
+system/themes/berlin-opensans-regular.woff: berlin-opensans-regular.woff,create,update,careful
+
+Extension: Blog
+Version: 0.8.10
+Description: Blog for your website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/blog
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/blog.zip
+Published: 2020-08-16 10:03:12
+Developer: Datenstrom
+Tag: feature
+system/extensions/blog.php: blog.php,create,update
+system/layouts/blog.html: blog.html,create,update,careful
+system/layouts/blogpages.html: blogpages.html,create,update,careful
+content/shared/page-new-blog.md: page-new-blog.md,create,optional
+content/2-blog/page.md: page.md,create,optional
+content/2-blog/2013-04-07-blog-example.md: 2013-04-07-blog-example.md,create,optional
+content/2-blog/2018-04-22-made-for-people.md: 2018-04-22-made-for-people.md,create,optional
+
+Extension: Breadcrumb
+Version: 0.8.6
+Description: Breadcrumb navigation.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/breadcrumb
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/breadcrumb.zip
+Published: 2020-08-01 14:56:24
+Developer: Datenstrom
+Tag: feature
+system/extensions/breadcrumb.php: breadcrumb.php,create,update
+
+Extension: Bundle
+Version: 0.8.15
+Description: Bundle website files.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/bundle
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/bundle.zip
+Published: 2020-07-29 10:13:34
+Developer: Datenstrom
+Tag: feature
+system/extensions/bundle.php: bundle.php,create,update
+
+Extension: Chinese
+Version: 0.8.24
+Description: Chinese/简体中文 with language 'zh-CN'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/chinese
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/chinese.zip
+Published: 2020-08-12 10:43:35
+Translator: Hyson Lee
+Tag: language
+system/extensions/chinese.php: chinese.php,create,update
+system/extensions/chinese.txt: chinese.txt,create,update
+
+Extension: Command
+Version: 0.8.22
+Description: Command line of the website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/command
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/command.zip
+Published: 2020-08-11 09:43:50
+Developer: Datenstrom
+Tag: feature
+system/extensions/command.php: command.php,create,update
+
+Extension: Contact
+Version: 0.8.13
+Description: Email contact page.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/contact
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/contact.zip
+Published: 2020-07-26 20:45:31
+Developer: Datenstrom
+Tag: feature
+system/extensions/contact.php: contact.php,create,update
+system/layouts/contact.html: contact.html,create,update,careful
+content/contact/page.md: page.md,create,optional
+
+Extension: Core
+Version: 0.8.20
+Description: Core functionality of the website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip
+Published: 2020-08-16 09:48:00
+Developer: Datenstrom
+Tag: feature
+system/extensions/core.php: core.php,create,update
+
+Extension: Csv
+Version: 0.8.13
+Tag: feature, csv, data, tables
+Description: CSV file parser.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/csv
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/csv.zip
+Published: 2020-08-01 19:23:00
+Developer: Steffen Schultz
+system/extensions/csv.php: csv.php,create,update
+system/extensions/csv.js: csv.js,create,update
+
+Extension: Czech
+Version: 0.8.24
+Description: Czech/Čeština with language 'cs'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/czech
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/czech.zip
+Published: 2020-08-12 10:43:36
+Translator: Ufo Vyhuleny
+Tag: language
+system/extensions/czech.php: czech.php,create,update
+system/extensions/czech.txt: czech.txt,create,update
+
+Extension: Danish
+Version: 0.8.24
+Description: Danish/Dansk with language 'da'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/danish
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/danish.zip
+Published: 2020-08-12 10:43:34
+Translator: David Garcia
+Tag: language
+system/extensions/danish.php: danish.php,create,update
+system/extensions/danish.txt: danish.txt,create,update
+
+Extension: Disqus
+Version: 0.8.4
+Description: Show Disqus comments on blog.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/disqus
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/disqus.zip
+Published: 2020-07-26 17:58:11
+Developer: Datenstrom
+Tag: feature
+system/extensions/disqus.php: disqus.php,create,update
+system/extensions/disqus.js: disqus.js,create,update
+
+Extension: Draft
+Version: 0.8.10
+Description: Support for draft pages.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/draft
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/draft.zip
+Published: 2020-08-16 10:03:06
+Developer: Datenstrom
+Tag: feature
+system/extensions/draft.php: draft.php,create,update
+system/layouts/draftpages.html: draftpages.html,create,update,careful
+content/drafts/page.md: page.md,create,optional
+
+Extension: Dutch
+Version: 0.8.24
+Description: Dutch/Nederlands (België) with language 'nl'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/dutch
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/dutch.zip
+Published: 2020-08-12 10:43:37
+Translator: Robin Vannieuwenhuijse
+Tag: language
+system/extensions/dutch.php: dutch.php,create,update
+system/extensions/dutch.txt: dutch.txt,create,update
+
+Extension: Edit
+Version: 0.8.35
+Description: Edit your website in a web browser.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/edit
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/edit.zip
+Published: 2020-08-10 13:12:52
+Developer: Datenstrom
+Tag: feature
+system/extensions/edit.php: edit.php,create,update
+system/extensions/edit.css: edit.css,create,update
+system/extensions/edit.js: edit.js,create,update
+system/extensions/edit.woff: edit.woff,create,update
+
+Extension: Emojiawesome
+Version: 0.8.6
+Description: Lots and lots of emoji.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/emojiawesome
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/emojiawesome.zip
+Published: 2020-07-26 17:59:52
+Developer: Datenstrom
+Tag: feature
+system/extensions/emojiawesome.php: emojiawesome.php,create,update
+system/extensions/emojiawesome.css: emojiawesome.css,create,update
+
+Extension: English
+Version: 0.8.24
+Description: English/English with language 'en'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/english
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/english.zip
+Published: 2020-08-12 10:00:22
+Translator: Mark Seuffert
+Tag: language
+system/extensions/english.php: english.php,create,update
+system/extensions/english.txt: english.txt,create,update
+
+Extension: Feed
+Version: 0.8.10
+Description: Feed with recent changes.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/feed
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/feed.zip
+Published: 2020-08-16 10:03:48
+Developer: Datenstrom
+Tag: feature
+system/extensions/feed.php: feed.php,create,update
+system/layouts/feed.html: feed.html,create,update,careful
+content/feed/page.md: page.md,create,optional
+
+Extension: Fontawesome
+Version: 0.8.6
+Description: Icons and symbols.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/fontawesome
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/fontawesome.zip
+Published: 2020-07-26 17:59:58
+Developer: Datenstrom
+Tag: feature
+system/extensions/fontawesome.php: fontawesome.php,create,update
+system/extensions/fontawesome.css: fontawesome.css,create,update
+system/extensions/fontawesome.woff: fontawesome.woff,create,update
+
+Extension: French
+Version: 0.8.24
+Description: French/Français with language 'fr'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/french
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/french.zip
+Published: 2020-08-12 10:00:23
+Translator: Juh Nibreh
+Tag: language
+system/extensions/french.php: french.php,create,update
+system/extensions/french.txt: french.txt,create,update
+
+Extension: Gallery
+Version: 0.8.8
+Description: Image gallery with popup.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/gallery
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/gallery.zip
+Published: 2020-08-05 08:48:35
+Developer: Datenstrom
+Tag: feature
+system/extensions/gallery.php: gallery.php,create,update
+system/extensions/gallery.js: gallery.js,create,update
+system/extensions/gallery.css: gallery.css,create,update
+system/extensions/gallery-photoswipe.min.js: gallery-photoswipe.min.js,create,update
+system/extensions/gallery-default-skin.png: gallery-default-skin.png,create,update
+system/extensions/gallery-default-skin.svg: gallery-default-skin.svg,create,update
+
+Extension: German
+Version: 0.8.24
+Description: German/Deutsch with language 'de'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/german
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/german.zip
+Published: 2020-08-12 10:00:24
+Translator: David Fehrmann
+Tag: language
+system/extensions/german.php: german.php,create,update
+system/extensions/german.txt: german.txt,create,update
+
+Extension: Googlecalendar
+Version: 0.8.7
+Description: Embed Google calendar.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/googlecalendar
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/googlecalendar.zip
+Published: 2020-07-26 18:01:25
+Developer: Datenstrom
+Tag: feature
+system/extensions/googlecalendar.php: googlecalendar.php,create,update
+system/extensions/googlecalendar.js: googlecalendar.js,create,update
+system/extensions/googlecalendar.css: googlecalendar.css,create,update
+
+Extension: Googlemap
+Version: 0.8.7
+Description: Embed Google map.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/googlemap
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/googlemap.zip
+Published: 2020-07-26 18:01:29
+Developer: Datenstrom
+Tag: feature
+system/extensions/googlemap.php: googlemap.php,create,update
+
+Extension: Help
+Version: 0.8.14
+Description: Help for your website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/help
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/help.zip
+Published: 2020-07-26 20:53:08
+Developer: Datenstrom
+Tag: feature
+system/extensions/help.php: help.php,create,update
+content/9-help/adjusting-content.md: adjusting-content.md,create,optional,multi-language
+content/9-help/adjusting-media.md: adjusting-media.md,create,optional,multi-language
+content/9-help/adjusting-system.md: adjusting-system.md,create,optional,multi-language
+content/9-help/api-for-developers.md: api-for-developers.md,create,optional,multi-language
+content/9-help/contributing-guidelines.md: contributing-guidelines.md,create,optional,multi-language
+content/9-help/css-files.md: css-files.md,create,optional,multi-language
+content/9-help/how-to-make-a-small-blog.md: how-to-make-a-small-blog.md,create,optional,multi-language
+content/9-help/how-to-make-a-small-website.md: how-to-make-a-small-website.md,create,optional,multi-language
+content/9-help/how-to-make-a-small-wiki.md: how-to-make-a-small-wiki.md,create,optional,multi-language
+content/9-help/html-files.md: html-files.md,create,optional,multi-language
+content/9-help/javascript-files.md: javascript-files.md,create,optional,multi-language
+content/9-help/markdown-cheat-sheet.md: markdown-cheat-sheet.md,create,optional,multi-language
+content/9-help/page.md: page.md,create,optional,multi-language
+content/9-help/troubleshooting.md: troubleshooting.md,create,optional,multi-language
+media/images/help-photo.jpg: help-photo.jpg,create,optional
+media/images/language-en.png: language-en.png,create,optional
+media/images/language-de.png: language-de.png,create,optional
+media/images/language-fr.png: language-fr.png,create,optional
+media/images/language-it.png: language-it.png,create,optional
+media/images/language-sv.png: language-sv.png,create,optional
+
+Extension: Highlight
+Version: 0.8.8
+Description: Highlight source code.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/highlight
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/highlight.zip
+Published: 2020-07-26 18:02:41
+Developer: Datenstrom
+Tag: feature
+system/extensions/highlight.php: highlight.php,create,update
+system/extensions/highlight.css: highlight.css,create,update
+system/extensions/highlight-cpp.json: highlight-cpp.json,create,update
+system/extensions/highlight-css.json: highlight-css.json,create,update
+system/extensions/highlight-javascript.json: highlight-javascript.json,create,update
+system/extensions/highlight-json.json: highlight-json.json,create,update
+system/extensions/highlight-php.json: highlight-php.json,create,update
+system/extensions/highlight-python.json: highlight-python.json,create,update
+system/extensions/highlight-xml.json: highlight-xml.json,create,update
+system/extensions/highlight-yaml.json: highlight-yaml.json,create,update
+
+Extension: Hungarian
+Version: 0.8.24
+Description: Hungarian/Magyar with language 'hu'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/hungarian
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/hungarian.zip
+Published: 2020-08-12 10:56:47
+Translator: Ádám Tuba
+Tag: language
+system/extensions/hungarian.php: hungarian.php,create,update
+system/extensions/hungarian.txt: hungarian.txt,create,update
+
+Extension: Image
+Version: 0.8.9
+Description: Images and thumbnails.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/image
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/image.zip
+Published: 2020-07-26 16:01:58
+Developer: Datenstrom
+Tag: feature
+system/extensions/image.php: image.php,create,update
+
+Extension: Include
+Version: 0.8.5
+Tag: feature, content, page
+Description: Includes page content from other pages.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/include
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/include.zip
+Published: 2020-07-29 12:14:17
+Developer: Steffen Schultz
+system/extensions/include.php: include.php,create,update
+
+Extension: Instagram
+Version: 0.8.5
+Description: Embed Instagram photos.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/instagram
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/instagram.zip
+Published: 2020-07-26 18:03:04
+Developer: Datenstrom
+Tag: feature
+system/extensions/instagram.php: instagram.php,create,update
+system/extensions/instagram.js: instagram.js,create,update
+
+Extension: Italian
+Version: 0.8.24
+Description: Italian/Italiano with language 'it'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/italian
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/italian.zip
+Published: 2020-08-12 10:56:47
+Translator: Giovanni Salmeri
+Tag: language
+system/extensions/italian.php: italian.php,create,update
+system/extensions/italian.txt: italian.txt,create,update
+
+Extension: Japanese
+Version: 0.8.24
+Description: Japanese/日本語 with language 'ja'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/japanese
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/japanese.zip
+Published: 2020-08-12 10:56:48
+Translator: Yuhko Senuma
+Tag: language
+system/extensions/japanese.php: japanese.php,create,update
+system/extensions/japanese.txt: japanese.txt,create,update
+
+Extension: Markdown
+Version: 0.8.15
+Description: Text formatting for humans.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/markdown
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/markdown.zip
+Published: 2020-07-26 16:03:56
+Developer: Datenstrom
+Tag: feature
+system/extensions/markdown.php: markdown.php,create,update
+system/extensions/markdownx.php: markdownx.php,update
+
+Extension: Meta
+Version: 0.8.14
+Description: Meta data for social media sites.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/meta
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/meta.zip
+Published: 2020-07-26 16:03:37
+Developer: Datenstrom, Steffen Schultz
+Tag: feature
+system/extensions/meta.php: meta.php,create,update
+
+Extension: Motd
+Version: 0.8.4
+Tag: feature, message
+Description: Message of the day.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/motd
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/motd.zip
+Published: 2020-07-29 12:15:03
+Developer: Steffen Schultz
+system/extensions/motd.php: motd.php,create,update
+
+Extension: Norwegian
+Version: 0.8.24
+Description: Norwegian/Norsk Bokmål with language 'nb'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/norwegian
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/norwegian.zip
+Published: 2020-08-12 10:56:46
+Translator: Per Arne Solvik
+Tag: language
+system/extensions/norwegian.php: norwegian.php,create,update
+system/extensions/norwegian.txt: norwegian.txt,create,update
+
+Extension: Pagesource
+Version: 0.8.6
+Tag: feature, markdown, page, source
+Description: View the markdown source of a page.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/pagesource
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/pagesource.zip
+Published: 2020-07-29 12:16:24
+Developer: Steffen Schultz
+system/extensions/pagesource.php: pagesource.php,create,update
+
+Extension: Paris
+Version: 0.8.9
+Description: Paris is an elegant theme.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/paris
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/paris.zip
+Published: 2020-07-26 15:14:55
+Designer: Datenstrom
+Tag: theme
+system/extensions/paris.php: paris.php,create,update
+system/layouts/paris-navigation.html: paris-navigation.html,create,update,careful
+system/themes/paris.css: paris.css,create,update,careful
+system/themes/paris.png: paris.png,create
+system/themes/paris-logo.png: paris-logo.png,create
+system/themes/paris-quote.png: paris-quote.png,create
+system/themes/paris-opensans-bold.woff: paris-opensans-bold.woff,create,update,careful
+system/themes/paris-opensans-light.woff: paris-opensans-light.woff,create,update,careful
+system/themes/paris-opensans-regular.woff: paris-opensans-regular.woff,create,update,careful
+
+Extension: Podcast
+Version: 0.8.9
+Tag: feature, feed, podcast
+Description: Web feed optimized for podcast publishing.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/podcast
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/podcast.zip
+Published: 2020-08-16 14:07:43
+Developer: Steffen Schultz
+system/extensions/podcast.php: podcast.php,create,update
+system/layouts/podcast.html: podcast.html,create,update,careful
+content/podcast/page.md: page.md,create,optional
+
+Extension: Polish
+Version: 0.8.24
+Description: Polish/Polski with language 'pl'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/polish
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/polish.zip
+Published: 2020-08-12 11:20:53
+Translator: Paweł Klockiewicz
+Tag: language
+system/extensions/polish.php: polish.php,create,update
+system/extensions/polish.txt: polish.txt,create,update
+
+Extension: Portuguese
+Version: 0.8.24
+Description: Portuguese/Português with language 'pt'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/portuguese
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/portuguese.zip
+Published: 2020-08-12 11:07:16
+Translator: Al Garcia
+Tag: language
+system/extensions/portuguese.php: portuguese.php,create,update
+system/extensions/portuguese.txt: portuguese.txt,create,update
+
+Extension: Previousnext
+Version: 0.8.7
+Description: Show links to previous/next page.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/previousnext
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/previousnext.zip
+Published: 2020-07-26 18:03:32
+Developer: Datenstrom
+Tag: feature
+system/extensions/previousnext.php: previousnext.php,create,update
+
+Extension: Private
+Version: 0.8.7
+Tag: feature, page, private, security
+Description: Support for password-protected pages.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/private
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/private.zip
+Published: 2020-07-29 12:20:44
+Developer: Steffen Schultz
+system/extensions/private.php: private.php,create,update
+system/extensions/private.txt: private.txt,create,update
+
+Extension: Publish
+Version: 0.8.27
+Description: Package and publish extensions.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/publish
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/publish.zip
+Published: 2020-08-16 11:08:28
+Developer: Datenstrom
+Tag: feature
+system/extensions/publish.php: publish.php,create,update
+
+Extension: Radioboss
+Version: 0.8.9
+Tag: feature, radio, widgets
+Description: Widgets for RadioBoss Cloud.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/radioboss
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/radioboss.zip
+Published: 2020-07-29 12:21:38
+Developer: Steffen Schultz
+system/extensions/radioboss.php: radioboss.php,create,update
+
+Extension: Random
+Version: 0.8.6
+Tag: feature, pages, random
+Description: Display random pages from specified location.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/random
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/random.zip
+Published: 2020-08-17 21:15:55
+Developer: Steffen Schultz
+system/extensions/random.php: random.php,create,update
+
+Extension: Redirect
+Version: 0.8.3
+Tag: feature, page, redirect
+Description: Alternative page redirection.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/redirect
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/redirect.zip
+Published: 2020-07-29 12:25:06
+Developer: Steffen Schultz
+system/extensions/redirect.php: redirect.php,create,update
+
+Extension: Russian
+Version: 0.8.24
+Description: Russian/Русский with language 'ru'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/russian
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/russian.zip
+Published: 2020-08-12 11:07:15
+Translator: Сергей Ворон
+Tag: language
+system/extensions/russian.php: russian.php,create,update
+system/extensions/russian.txt: russian.txt,create,update
+
+Extension: Search
+Version: 0.8.10
+Description: Full-text search.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/search
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/search.zip
+Published: 2020-08-16 10:03:54
+Developer: Datenstrom
+Tag: feature
+system/extensions/search.php: search.php,create,update
+system/layouts/search.html: search.html,create,update,careful
+content/search/page.md: page.md,create,optional
+
+Extension: Sitemap
+Version: 0.8.10
+Description: Sitemap with all pages.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/sitemap
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/sitemap.zip
+Published: 2020-08-16 10:04:05
+Developer: Datenstrom
+Tag: feature
+system/extensions/sitemap.php: sitemap.php,create,update
+system/layouts/sitemap.html: sitemap.html,create,update,careful
+content/sitemap/page.md: page.md,create,optional
+
+Extension: Slider
+Version: 0.8.5
+Description: Image gallery with slider.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/slider
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/slider.zip
+Published: 2020-07-26 18:06:59
+Developer: Datenstrom
+Tag: feature
+system/extensions/slider.php: slider.php,create,update
+system/extensions/slider.js: slider.js,create,update
+system/extensions/slider.css: slider.css,create,update
+system/extensions/slider-flickity.min.js: slider-flickity.min.js,create,update
+
+Extension: Slovak
+Version: 0.8.24
+Description: Slovak/Slovenčina with language 'sk'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/slovak
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/slovak.zip
+Published: 2020-08-12 11:07:14
+Translator: Ádám Tuba
+Tag: language
+system/extensions/slovak.php: slovak.php,create,update
+system/extensions/slovak.txt: slovak.txt,create,update
+
+Extension: Soundcloud
+Version: 0.8.4
+Description: Embed Soundcloud audio tracks.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/soundcloud
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/soundcloud.zip
+Published: 2020-07-26 18:07:35
+Developer: Datenstrom
+Tag: feature
+system/extensions/soundcloud.php: soundcloud.php,create,update
+
+Extension: Spanish
+Version: 0.8.24
+Description: Spanish/Español with language 'es'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/spanish
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/spanish.zip
+Published: 2020-08-12 11:07:13
+Translator: Al Garcia, David Garcia
+Tag: language
+system/extensions/spanish.php: spanish.php,create,update
+system/extensions/spanish.txt: spanish.txt,create,update
+
+Extension: Spoiler
+Version: 0.8.7
+Tag: feature, page, spoiler
+Description: Hide certain page elements.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/spoiler
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/spoiler.zip
+Published: 2020-07-29 12:27:02
+Developer: Steffen Schultz
+system/extensions/spoiler.php: spoiler.php,create,update
+system/extensions/spoiler.js: spoiler.js,create,update
+
+Extension: Stockholm
+Version: 0.8.9
+Description: Stockholm is a clean theme.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/stockholm
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/stockholm.zip
+Published: 2020-07-26 15:14:23
+Designer: Datenstrom
+Tag: theme
+system/extensions/stockholm.php: stockholm.php,create,update
+system/themes/stockholm.css: stockholm.css,create,update,careful
+system/themes/stockholm.png: stockholm.png,create
+system/themes/stockholm-opensans-bold.woff: stockholm-opensans-bold.woff,create,update,careful
+system/themes/stockholm-opensans-light.woff: stockholm-opensans-light.woff,create,update,careful
+system/themes/stockholm-opensans-regular.woff: stockholm-opensans-regular.woff,create,update,careful
+
+Extension: Swedish
+Version: 0.8.24
+Description: Swedish/Svenska with language 'sv'.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/swedish
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/swedish.zip
+Published: 2020-08-12 10:23:59
+Translator: Adam Engel
+Tag: language
+system/extensions/swedish.php: swedish.php,create,update
+system/extensions/swedish.txt: swedish.txt,create,update
+
+Extension: Ticker
+Version: 0.8.7
+Tag: feature, feed, rss, simplepie
+Description: RSS feed parser.
+HelpUrl: https://github.com/schulle4u/yellow-extensions-schulle4u/tree/master/ticker
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/ticker.zip
+Published: 2020-07-29 12:29:17
+Developer: Steffen Schultz
+system/extensions/ticker.php: ticker.php,create,update
+system/extensions/ticker-simplepie.compiled.php: ticker-simplepie.compiled.php,create,update
+
+Extension: Toc
+Version: 0.8.5
+Description: Table of contents.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/toc
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/toc.zip
+Published: 2020-08-16 09:52:54
+Developer: Datenstrom
+Tag: feature
+system/extensions/toc.php: toc.php,create,update
+
+Extension: Traffic
+Version: 0.8.7
+Description: Create traffic analytics from web server log files.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/traffic
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/traffic.zip
+Published: 2020-07-26 18:08:29
+Developer: Datenstrom
+Tag: feature
+system/extensions/traffic.php: traffic.php,create,update
+
+Extension: Twitter
+Version: 0.8.5
+Description: Embed Twitter messages.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/twitter
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/twitter.zip
+Published: 2020-07-26 18:08:33
+Developer: Datenstrom, Steffen Schultz
+Tag: feature
+system/extensions/twitter.php: twitter.php,create,update
+system/extensions/twitter.js: twitter.js,create,update
+
+Extension: Update
+Version: 0.8.34
+Description: Keep your website up to date.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/update
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/update.zip
+Published: 2020-08-17 11:16:25
+Developer: Datenstrom
+Tag: feature
+system/extensions/update.php: update.php,create,update
+
+Extension: Wiki
+Version: 0.8.11
+Description: Wiki for your website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/wiki
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/wiki.zip
+Published: 2020-08-16 13:29:15
+Developer: Datenstrom
+Tag: feature
+system/extensions/wiki.php: wiki.php,create,update
+system/layouts/wiki.html: wiki.html,create,update,careful
+system/layouts/wikipages.html: wikipages.html,create,update,careful
+content/shared/page-new-wiki.md: page-new-wiki.md,create,optional
+content/2-wiki/page.md: page.md,create,optional
+content/2-wiki/wiki-example.md: wiki-example.md,create,optional
+
+Extension: Youtube
+Version: 0.8.4
+Description: Embed Youtube videos.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/youtube
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/youtube.zip
+Published: 2020-07-26 18:08:39
+Developer: Datenstrom
+Tag: feature
+system/extensions/youtube.php: youtube.php,create,update
diff --git a/system/extensions/update.php b/system/extensions/update.php
new file mode 100644
index 0000000..693b05e
--- /dev/null
+++ b/system/extensions/update.php
@@ -0,0 +1,760 @@
+yellow = $yellow;
+ $this->yellow->system->setDefault("updateExtensionUrl", "https://github.com/datenstrom/yellow-extensions");
+ $this->yellow->system->setDefault("updateExtensionFile", "extension.ini");
+ $this->yellow->system->setDefault("updateCurrentFile", "update-current.ini");
+ $this->yellow->system->setDefault("updateLatestFile", "update-latest.ini");
+ $this->yellow->system->setDefault("updateNotification", "none");
+ }
+
+ // Handle request
+ public function onRequest($scheme, $address, $base, $location, $fileName) {
+ $statusCode = 0;
+ if ($this->yellow->lookup->isContentFile($fileName) && $this->isExtensionPending()) {
+ $statusCode = $this->processRequestPending($scheme, $address, $base, $location, $fileName);
+ }
+ return $statusCode;
+ }
+
+ // Handle command
+ public function onCommand($command, $text) {
+ $statusCode = 0;
+ if ($this->isExtensionPending()) $statusCode = $this->processCommandPending();
+ if ($statusCode==0) {
+ switch ($command) {
+ case "about": $statusCode = $this->processCommandAbout($command, $text); break;
+ case "clean": $statusCode = $this->processCommandClean($command, $text); break;
+ case "install": $statusCode = $this->processCommandInstall($command, $text); break;
+ case "uninstall": $statusCode = $this->processCommandUninstall($command, $text); break;
+ case "update": $statusCode = $this->processCommandUpdate($command, $text); break;
+ default: $statusCode = 0; break;
+ }
+ }
+ return $statusCode;
+ }
+
+ // Handle command help
+ public function onCommandHelp() {
+ $help = "about\n";
+ $help .= "install [extension]\n";
+ $help .= "uninstall [extension]\n";
+ $help .= "update [extension]\n";
+ return $help;
+ }
+
+ // Handle update
+ public function onUpdate($action) {
+ if ($action=="update") { // TODO: remove later, converts old layout files
+ $path = $this->yellow->system->get("coreLayoutDirectory");
+ foreach ($this->yellow->toolbox->getDirectoryEntriesRecursive($path, "/^.*\.html$/", true, false) as $entry) {
+ $key = str_replace("pages", "", $this->yellow->lookup->normaliseName(basename($entry), true, true));
+ $fileData = $fileDataNew = $this->yellow->toolbox->readFile($entry);
+ $fileDataNew = str_replace("yellow->page->getPages()", "yellow->page->getPages(\"$key\")", $fileDataNew);
+ $fileDataNew = str_replace("\$this->yellow->content->shared(\"header\")", "null", $fileDataNew);
+ $fileDataNew = str_replace("\$this->yellow->content->shared(\"footer\")", "null", $fileDataNew);
+ $fileDataNew = str_replace("php if (\$page = null)", "php /* Remove this line */ if (\$page = null)", $fileDataNew);
+ if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($entry, $fileDataNew)) {
+ $this->yellow->log("error", "Can't write file '$entry'!");
+ }
+ }
+ }
+ if ($action=="startup") {
+ if ($this->yellow->system->get("updateNotification")!="none") {
+ foreach (explode(",", $this->yellow->system->get("updateNotification")) as $token) {
+ list($extension, $action) = $this->yellow->toolbox->getTextList($token, "/", 2);
+ if ($this->yellow->extension->isExisting($extension) && ($action!="startup" && $action!="uninstall")) {
+ $value = $this->yellow->extension->data[$extension];
+ if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
+ }
+ }
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
+ if (!$this->yellow->system->save($fileName, array("updateNotification" => "none"))) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
+ }
+ $this->updateSystemSettings();
+ $this->updateLanguageSettings();
+ }
+ }
+ }
+
+ // Update system settings after update notification
+ public function updateSystemSettings() {
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
+ $fileData = $this->yellow->toolbox->readFile($fileName);
+ $fileDataStart = $fileDataSettings = $fileDataComments = "";
+ $settings = new YellowArray();
+ $settings->exchangeArray($this->yellow->system->settingsDefaults->getArrayCopy());
+ foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
+ preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
+ if (empty($fileDataStart) && preg_match("/^\#/", $line)) {
+ $fileDataStart = $line;
+ } elseif (!empty($matches[1]) && isset($settings[$matches[1]])) {
+ $settings[$matches[1]] = $matches[2];
+ } elseif (!empty($matches[1]) && substru($matches[1], 0, 1)!="#") {
+ $fileDataComments .= "# $line";
+ } elseif (!empty($matches[1])) {
+ $fileDataComments .= $line;
+ }
+ }
+ unset($settings["coreSystemFile"]);
+ foreach ($settings as $key=>$value) {
+ $fileDataSettings .= ucfirst($key).(strempty($value) ? ":\n" : ": $value\n");
+ }
+ if (!empty($fileDataStart)) $fileDataStart .= "\n";
+ if (!empty($fileDataComments)) $fileDataSettings .= "\n";
+ $fileDataNew = $fileDataStart.$fileDataSettings.$fileDataComments;
+ if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
+ }
+ }
+
+ // Update language settings after update notification
+ public function updateLanguageSettings() {
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreLanguageFile");
+ $fileData = $this->yellow->toolbox->readFile($fileName);
+ $fileDataStart = $fileDataSettings = $language = "";
+ $settings = new YellowArray();
+ foreach ($this->yellow->toolbox->getTextLines($fileData) as $line) {
+ preg_match("/^\s*(.*?)\s*:\s*(.*?)\s*$/", $line, $matches);
+ if (empty($fileDataStart) && preg_match("/^\#/", $line)) {
+ $fileDataStart = $line;
+ } elseif (!empty($matches[1]) && !empty($matches[2])) {
+ if (lcfirst($matches[1])=="language" && !strempty($matches[2])) {
+ if (!empty($settings)) {
+ if (!empty($fileDataSettings)) $fileDataSettings .= "\n";
+ foreach ($settings as $key=>$value) {
+ $fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
+ }
+ }
+ $language = $matches[2];
+ $settings = new YellowArray();
+ $settings["language"] = $language;
+ foreach ($this->yellow->language->settingsDefaults as $key=>$value) {
+ if ($this->yellow->language->isText($key, $language)) {
+ $settings[$key] = $this->yellow->language->getText($key, $language);
+ }
+ }
+ }
+ if (!empty($language)) {
+ $settings[$matches[1]] = $matches[2];
+ }
+ }
+ }
+ if (!empty($fileDataStart)) $fileDataStart .= "\n";
+ if (!empty($fileDataSettings)) $fileDataSettings .= "\n";
+ foreach ($settings as $key=>$value) {
+ $fileDataSettings .= (strposu($key, "/") ? $key : ucfirst($key)).": $value\n";
+ }
+ $fileDataNew = $fileDataStart.$fileDataSettings;
+ if ($fileData!=$fileDataNew && !$this->yellow->toolbox->createFile($fileName, $fileDataNew)) {
+ $this->yellow->log("error", "Can't write file '$fileName'!");
+ }
+ }
+
+ // Create extension settings from scratch
+ public function createExtensionSettings() {
+ $fileNameCurrent = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateCurrentFile");
+ $fileNameLatest = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateLatestFile");
+ $url = $this->yellow->system->get("updateExtensionUrl")."/raw/master/".$this->yellow->system->get("updateLatestFile");
+ list($statusCode, $fileData) = $this->getExtensionFile($url);
+ if ($statusCode==200) {
+ $fileDataCurrent = $fileDataLatest = $fileData;
+ $settings = $this->yellow->toolbox->getTextSettings($fileDataCurrent, "extension");
+ foreach ($settings as $key=>$value) {
+ if ($this->yellow->extension->isExisting($key)) {
+ $settingsNew = new YellowArray();
+ $settingsNew["extension"] = ucfirst($key);
+ $settingsNew["version"] = $this->yellow->extension->data[$key]["version"];
+ $fileDataCurrent = $this->yellow->toolbox->setTextSettings($fileDataCurrent, "extension", $key, $settingsNew);
+ } else {
+ $fileDataCurrent = $this->yellow->toolbox->unsetTextSettings($fileDataCurrent, "extension", $key);
+ }
+ }
+ if(!$this->yellow->toolbox->createFile($fileNameCurrent, $fileDataCurrent)) {
+ $this->yellow->log("error", "Can't write file '$fileNameCurrent'!");
+ }
+ if(!$this->yellow->toolbox->createFile($fileNameLatest, $fileDataLatest)) {
+ $this->yellow->log("error", "Can't write file '$fileNameLatest'!");
+ }
+ }
+ return $statusCode;
+ }
+
+ // Update extension settings
+ public function updateExtensionSettings($extension, $settings, $action) {
+ $statusCode = 200;
+ $fileNameCurrent = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateCurrentFile");
+ $fileData = $this->yellow->toolbox->readFile($fileNameCurrent);
+ if ($action=="install" || $action=="update") {
+ $settingsNew = new YellowArray();
+ foreach($settings as $key=>$value) $settingsNew[$key] = $value;
+ $fileData = $this->yellow->toolbox->setTextSettings($fileData, "extension", $extension, $settingsNew);
+ } else {
+ $fileData = $this->yellow->toolbox->unsetTextSettings($fileData, "extension", $extension);
+ }
+ if (!$this->yellow->toolbox->createFile($fileNameCurrent, $fileData)) {
+ $statusCode = 500;
+ $this->yellow->page->error(500, "Can't write file '$fileNameCurrent'!");
+ }
+ return $statusCode;
+ }
+
+ // Process command to show website version and updates
+ public function processCommandAbout($command, $text) {
+ echo "Datenstrom Yellow ".YellowCore::RELEASE."\n";
+ list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
+ list($statusCode, $settingsLatest) = $this->getExtensionSettings(true);
+ foreach ($settingsCurrent as $key=>$value) {
+ $versionCurrent = $versionLatest = $settingsCurrent[$key]->get("version");
+ if ($settingsLatest->isExisting($key)) $versionLatest = $settingsLatest[$key]->get("version");
+ if (strnatcasecmp($versionCurrent, $versionLatest)<0) {
+ echo ucfirst($key)." $versionCurrent - Update available\n";
+ } else {
+ echo ucfirst($key)." $versionCurrent\n";
+ }
+ }
+ if ($statusCode!=200) echo "ERROR checking updates: ".$this->yellow->page->get("pageError")."\n";
+ return $statusCode;
+ }
+
+ // Process command to clean downloads
+ public function processCommandClean($command, $text) {
+ $statusCode = 0;
+ if ($command=="clean" && $text=="all") {
+ $path = $this->yellow->system->get("coreExtensionDirectory");
+ $regex = "/^.*\\".$this->yellow->system->get("coreDownloadExtension")."$/";
+ foreach ($this->yellow->toolbox->getDirectoryEntries($path, $regex, false, false) as $entry) {
+ if (!$this->yellow->toolbox->deleteFile($entry)) $statusCode = 500;
+ }
+ if ($statusCode==500) echo "ERROR cleaning downloads: Can't delete files in directory '$path'!\n";
+ }
+ return $statusCode;
+ }
+
+ // Process command to install extensions
+ public function processCommandInstall($command, $text) {
+ $extensions = $this->getExtensionsFromText($text);
+ if (!empty($extensions)) {
+ $this->updates = 0;
+ list($statusCode, $settings) = $this->getExtensionInstallInformation($extensions);
+ if ($statusCode==200) $statusCode = $this->downloadExtensions($settings);
+ if ($statusCode==200) $statusCode = $this->updateExtensions("install");
+ if ($statusCode>=400) echo "ERROR installing files: ".$this->yellow->page->get("pageError")."\n";
+ echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
+ echo ", $this->updates extension".($this->updates!=1 ? "s" : "")." installed\n";
+ } else {
+ $statusCode = $this->showExtensions();
+ }
+ return $statusCode;
+ }
+
+ // Process command to uninstall extensions
+ public function processCommandUninstall($command, $text) {
+ $extensions = $this->getExtensionsFromText($text);
+ if (!empty($extensions)) {
+ $this->updates = 0;
+ list($statusCode, $settings) = $this->getExtensionUninstallInformation($extensions, "core, update");
+ if ($statusCode==200) $statusCode = $this->removeExtensions($settings);
+ if ($statusCode>=400) echo "ERROR uninstalling files: ".$this->yellow->page->get("pageError")."\n";
+ echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
+ echo ", $this->updates extension".($this->updates!=1 ? "s" : "")." uninstalled\n";
+ } else {
+ $statusCode = $this->showExtensions();
+ }
+ return $statusCode;
+ }
+
+ // Process command to update website
+ public function processCommandUpdate($command, $text) {
+ $extensions = $this->getExtensionsFromText($text);
+ list($statusCode, $settings) = $this->getExtensionUpdateInformation($extensions);
+ if ($statusCode!=200 || !empty($settings)) {
+ $this->updates = 0;
+ if ($statusCode==200) $statusCode = $this->downloadExtensions($settings);
+ if ($statusCode==200) $statusCode = $this->updateExtensions("update");
+ if ($statusCode>=400) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
+ echo "Yellow $command: Website ".($statusCode!=200 ? "not " : "")."updated";
+ echo ", $this->updates update".($this->updates!=1 ? "s" : "")." installed\n";
+ } else {
+ echo "Your website is up to date\n";
+ }
+ return $statusCode;
+ }
+
+ // Process command to install pending extension
+ public function processCommandPending() {
+ $statusCode = $this->updateExtensions("install");
+ if ($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n";
+ echo "Your website has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n";
+ return $statusCode;
+ }
+
+ // Process request to install pending extension
+ public function processRequestPending($scheme, $address, $base, $location, $fileName) {
+ $statusCode = $this->updateExtensions("install");
+ if ($statusCode==200) {
+ $location = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
+ $statusCode = $this->yellow->sendStatus(303, $location);
+ }
+ return $statusCode;
+ }
+
+ // Process update notification
+ public function processUpdateNotification($extension, $action) {
+ $statusCode = 200;
+ if ($this->yellow->extension->isExisting($extension) && $action=="uninstall") {
+ $value = $this->yellow->extension->data[$extension];
+ if (method_exists($value["object"], "onUpdate")) $value["object"]->onUpdate($action);
+ }
+ $updateNotification = $this->yellow->system->get("updateNotification");
+ if ($updateNotification=="none") $updateNotification = "";
+ if (!empty($updateNotification)) $updateNotification .= ",";
+ $updateNotification .= "$extension/$action";
+ $fileName = $this->yellow->system->get("coreSettingDirectory").$this->yellow->system->get("coreSystemFile");
+ if (!$this->yellow->system->save($fileName, array("updateNotification" => $updateNotification))) {
+ $statusCode = 500;
+ $this->yellow->page->error(500, "Can't write file '$fileName'!");
+ }
+ return $statusCode;
+ }
+
+ // Show extensions
+ public function showExtensions() {
+ list($statusCode, $settingsLatest) = $this->getExtensionSettings(true);
+ foreach ($settingsLatest as $key=>$value) {
+ $text = $description = $value->get("description");
+ if ($value->isExisting("developer")) $text = "$description Developed by ".$value["developer"].".";
+ if ($value->isExisting("translator")) $text = "$description Translated by ".$value["translator"].".";
+ if ($value->isExisting("designer")) $text = "$description Designed by ".$value["designer"].".";
+ echo ucfirst($key).": $text\n";
+ }
+ if ($statusCode!=200) echo "ERROR checking extensions: ".$this->yellow->page->get("pageError")."\n";
+ return $statusCode;
+ }
+
+ // Download extensions
+ public function downloadExtensions($settings) {
+ $statusCode = 200;
+ $path = $this->yellow->system->get("coreExtensionDirectory");
+ $fileExtension = $this->yellow->system->get("coreDownloadExtension");
+ foreach ($settings as $key=>$value) {
+ $fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
+ list($statusCode, $fileData) = $this->getExtensionFile($value->get("downloadUrl"));
+ if (empty($fileData) || !$this->yellow->toolbox->createFile($fileName.$fileExtension, $fileData)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
+ break;
+ }
+ }
+ if ($statusCode==200) {
+ foreach ($settings as $key=>$value) {
+ $fileName = $path.$this->yellow->lookup->normaliseName($key, true, false, true).".zip";
+ if (!$this->yellow->toolbox->renameFile($fileName.$fileExtension, $fileName)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
+ }
+ }
+ }
+ return $statusCode;
+ }
+
+ // Update extensions
+ public function updateExtensions($action) {
+ $statusCode = 200;
+ if (function_exists("opcache_reset")) opcache_reset();
+ $path = $this->yellow->system->get("coreExtensionDirectory");
+ foreach ($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false) as $entry) {
+ $statusCode = max($statusCode, $this->updateExtensionArchive($entry, $action));
+ if (!$this->yellow->toolbox->deleteFile($entry)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't delete file '$entry'!");
+ }
+ }
+ return $statusCode;
+ }
+
+ // Update extension from archive
+ public function updateExtensionArchive($path, $action) {
+ $statusCode = 200;
+ $zip = new ZipArchive();
+ if ($zip->open($path)===true) {
+ if (defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::updateExtensionArchive file:$path \n";
+ $pathBase = "";
+ if (preg_match("#^(.*\/).*?$#", $zip->getNameIndex(0), $matches)) $pathBase = $matches[1];
+ $languages = $this->getExtensionArchiveLanguages($zip, $pathBase);
+ $fileData = $zip->getFromName($pathBase.$this->yellow->system->get("updateExtensionFile"));
+ $settings = $this->yellow->toolbox->getTextSettings($fileData, "");
+ list($extension, $version, $newModified, $oldModified) = $this->getExtensionInformation($settings);
+ if (!empty($extension) && !empty($version)) {
+ $statusCode = $this->updateExtensionSettings($extension, $settings, $action);
+ if ($statusCode==200) {
+ foreach ($this->getExtensionFileNames($settings) as $fileName) {
+ list($entry, $flags) = $this->yellow->toolbox->getTextList($settings[$fileName], ",", 2);
+ if (strposu($entry, ".")===false) { // TODO: remove later, converts old extension settings
+ list($dummy, $entry, $flags) = $this->yellow->toolbox->getTextList($settings[$fileName], ",", 3);
+ }
+ if (!$this->yellow->lookup->isContentFile($fileName)) {
+ $fileData = $zip->getFromName($pathBase.$entry);
+ $lastModified = $this->yellow->toolbox->getFileModified($fileName);
+ $statusCode = $this->updateExtensionFile($fileName, $fileData,
+ $newModified, $oldModified, $lastModified, $flags, $extension);
+ } else {
+ foreach ($this->getExtensionContentRootPages() as $page) {
+ list($fileNameSource, $fileNameDestination) = $this->getExtensionContentFileNames(
+ $fileName, $pathBase, $entry, $flags, $languages, $page);
+ $fileData = $zip->getFromName($fileNameSource);
+ $lastModified = $this->yellow->toolbox->getFileModified($fileNameDestination);
+ $statusCode = $this->updateExtensionFile($fileNameDestination, $fileData,
+ $newModified, $oldModified, $lastModified, $flags, $extension);
+ }
+ }
+ if ($statusCode!=200) break;
+ }
+ $statusCode = max($statusCode, $this->processUpdateNotification($extension, $action));
+ }
+ $this->yellow->log($statusCode==200 ? "info" : "error", ucfirst($action)." extension '".ucfirst($extension)." $version'");
+ ++$this->updates;
+ }
+ $zip->close();
+ } else {
+ $statusCode = 500;
+ $this->yellow->page->error(500, "Can't open file '$path'!");
+ }
+ return $statusCode;
+ }
+
+ // Update extension from file
+ public function updateExtensionFile($fileName, $fileData, $newModified, $oldModified, $lastModified, $flags, $extension) {
+ $statusCode = 200;
+ $fileName = $this->yellow->toolbox->normaliseTokens($fileName);
+ if ($this->yellow->lookup->isValidFile($fileName)) {
+ $create = $update = $delete = false;
+ if (preg_match("/create/i", $flags) && !is_file($fileName) && !empty($fileData)) $create = true;
+ if (preg_match("/update/i", $flags) && is_file($fileName) && !empty($fileData)) $update = true;
+ if (preg_match("/delete/i", $flags) && is_file($fileName)) $delete = true;
+ if (preg_match("/optional/i", $flags) && $this->yellow->extension->isExisting($extension)) $create = $update = $delete = false;
+ if (preg_match("/careful/i", $flags) && is_file($fileName) && $lastModified!=$oldModified) $update = false;
+ if ($create) {
+ if (!$this->yellow->toolbox->createFile($fileName, $fileData, true) ||
+ !$this->yellow->toolbox->modifyFile($fileName, $newModified)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
+ }
+ }
+ if ($update) {
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory")) ||
+ !$this->yellow->toolbox->createFile($fileName, $fileData) ||
+ !$this->yellow->toolbox->modifyFile($fileName, $newModified)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
+ }
+ }
+ if ($delete) {
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"))) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
+ }
+ }
+ if (defined("DEBUG") && DEBUG>=2) {
+ $debug = "action:".($create ? "create" : "").($update ? "update" : "").($delete ? "delete" : "");
+ if (!$create && !$update && !$delete) $debug = "action:none";
+ echo "YellowUpdate::updateExtensionFile file:$fileName $debug \n";
+ }
+ }
+ return $statusCode;
+ }
+
+ // Remove extensions
+ public function removeExtensions($settings) {
+ $statusCode = 200;
+ if (function_exists("opcache_reset")) opcache_reset();
+ foreach ($settings as $extension=>$block) {
+ $statusCode = max($statusCode, $this->removeExtensionArchive($extension, $block, "uninstall"));
+ }
+ return $statusCode;
+ }
+
+ // Remove extension archive
+ public function removeExtensionArchive($extension, $settings, $action) {
+ $statusCode = 200;
+ $fileNames = $this->getExtensionFileNames($settings, true);
+ if (count($fileNames)) {
+ $statusCode = max($statusCode, $this->processUpdateNotification($extension, $action));
+ foreach ($fileNames as $fileName) {
+ $statusCode = max($statusCode, $this->removeExtensionFile($fileName));
+ }
+ if ($statusCode==200) $statusCode = $this->updateExtensionSettings($extension, $settings, $action);
+ $version = $settings->get("version");
+ $this->yellow->log($statusCode==200 ? "info" : "error", ucfirst($action)." extension '".ucfirst($extension)." $version'");
+ ++$this->updates;
+ } else {
+ $statusCode = 500;
+ $this->yellow->page->error(500, "Please delete extension '$extension' manually!");
+ }
+ return $statusCode;
+ }
+
+ // Remove extension file
+ public function removeExtensionFile($fileName) {
+ $statusCode = 200;
+ $fileName = $this->yellow->toolbox->normaliseTokens($fileName);
+ if ($this->yellow->lookup->isValidFile($fileName) && is_file($fileName)) {
+ if (!$this->yellow->toolbox->deleteFile($fileName, $this->yellow->system->get("coreTrashDirectory"))) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't delete file '$fileName'!");
+ }
+ if (defined("DEBUG") && DEBUG>=2) {
+ echo "YellowUpdate::removeExtensionFile file:$fileName action:delete \n";
+ }
+ }
+ return $statusCode;
+ }
+
+ // Return extensions from text, space separated
+ public function getExtensionsFromText($text) {
+ return array_unique(array_filter($this->yellow->toolbox->getTextArguments($text), "strlen"));
+ }
+
+ // Return extension install information
+ public function getExtensionInstallInformation($extensions) {
+ $settings = array();
+ list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
+ list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
+ $statusCode = max($statusCodeCurrent, $statusCodeLatest);
+ foreach ($extensions as $extension) {
+ $found = false;
+ foreach ($settingsLatest as $key=>$value) {
+ if (strtoloweru($key)==strtoloweru($extension)) {
+ if (!$settingsCurrent->isExisting($key)) $settings[$key] = $settingsLatest[$key];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't find extension '$extension'!");
+ }
+ }
+ return array($statusCode, $settings);
+ }
+
+ // Return extension uninstall information
+ public function getExtensionUninstallInformation($extensions, $extensionsProtected) {
+ $settings = array();
+ list($statusCode, $settingsCurrent) = $this->getExtensionSettings(false);
+ foreach ($extensions as $extension) {
+ $found = false;
+ foreach ($settingsCurrent as $key=>$value) {
+ if (strtoloweru($key)==strtoloweru($extension)) {
+ $settings[$key] = $settingsCurrent[$key];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't find extension '$extension'!");
+ }
+ }
+ $protected = preg_split("/\s*,\s*/", $extensionsProtected);
+ foreach ($settings as $key=>$value) {
+ if (in_array($key, $protected)) unset($settings[$key]);
+ }
+ return array($statusCode, $settings);
+ }
+
+ // Return extension update information
+ public function getExtensionUpdateInformation($extensions) {
+ $settings = array();
+ list($statusCodeCurrent, $settingsCurrent) = $this->getExtensionSettings(false);
+ list($statusCodeLatest, $settingsLatest) = $this->getExtensionSettings(true);
+ $statusCode = max($statusCodeCurrent, $statusCodeLatest);
+ if (empty($extensions)) {
+ foreach ($settingsCurrent as $key=>$value) {
+ if ($settingsLatest->isExisting($key)) {
+ $versionCurrent = $settingsCurrent[$key]->get("version");
+ $versionLatest = $settingsLatest[$key]->get("version");
+ if (strnatcasecmp($versionCurrent, $versionLatest)<0) {
+ $settings[$key] = $settingsLatest[$key];
+ }
+ }
+ }
+ } else {
+ $force = false;
+ foreach ($extensions as $extension) {
+ $found = false;
+ if ($extension=="force") { $force = true; continue; }
+ foreach ($settingsCurrent as $key=>$value) {
+ if (strtoloweru($key)==strtoloweru($extension) && $settingsLatest->isExisting($key)) {
+ $settings[$key] = $settingsLatest[$key];
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't find extension '$extension'!");
+ }
+ }
+ if (!$force) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Please use 'force' to update an extension!");
+ }
+ }
+ if ($statusCode==200) {
+ foreach ($settings as $key=>$value) {
+ echo ucfirst($key)." ".$value->get("version")."\n";
+ }
+ }
+ return array($statusCode, $settings);
+ }
+
+ // Return extension settings
+ public function getExtensionSettings($latest) {
+ $statusCode = 200;
+ $settings = array();
+ if (!$latest) {
+ $fileNameCurrent = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateCurrentFile");
+ if (!is_file($fileNameCurrent)) $statusCode = $this->createExtensionSettings();
+ $fileData = $this->yellow->toolbox->readFile($fileNameCurrent);
+ $settings = $this->yellow->toolbox->getTextSettings($fileData, "extension");
+ foreach ($settings as $key=>$value) {
+ if (!$this->yellow->extension->isExisting($key)) unset($settings[$key]);
+ }
+ foreach ($this->yellow->extension->data as $key=>$value) {
+ if (!$settings->isExisting($key)) $settings[$key] = new YellowArray();
+ $settings[$key]["extension"] = ucfirst($key);
+ $settings[$key]["version"] = $value["version"];
+ }
+ } else {
+ $fileNameLatest = $this->yellow->system->get("coreExtensionDirectory").$this->yellow->system->get("updateLatestFile");
+ $expire = $this->yellow->toolbox->getFileModified($fileNameLatest) + 60*10;
+ if ($expire<=time()) {
+ $url = $this->yellow->system->get("updateExtensionUrl")."/raw/master/".$this->yellow->system->get("updateLatestFile");
+ list($statusCode, $fileData) = $this->getExtensionFile($url);
+ if ($statusCode==200 && !$this->yellow->toolbox->createFile($fileNameLatest, $fileData)) {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't write file '$fileNameLatest'!");
+ }
+ }
+ $fileData = $this->yellow->toolbox->readFile($fileNameLatest);
+ $settings = $this->yellow->toolbox->getTextSettings($fileData, "extension");
+ }
+ $settings->uksort("strnatcasecmp");
+ return array($statusCode, $settings);
+ }
+
+ // Return extension archive languages
+ public function getExtensionArchiveLanguages($zip, $pathBase) {
+ $languages = array();
+ for ($index=0; $index<$zip->numFiles; ++$index) {
+ $entry = substru($zip->getNameIndex($index), strlenu($pathBase));
+ if (preg_match("#^(.*)\/.*?$#", $entry, $matches)) {
+ array_push($languages, $matches[1]);
+ }
+ }
+ return array_unique($languages);
+ }
+
+ // Return extension information
+ public function getExtensionInformation($settings) {
+ $extension = lcfirst($settings->get("extension"));
+ $version = $settings->get("version");
+ $newModified = strtotime($settings->get("published"));
+ $oldModified = 0;
+ foreach ($settings as $key=>$value) {
+ if (strposu($key, "/") && is_file($key)) {
+ $oldModified = filemtime($key);
+ break;
+ }
+ }
+ return array($extension, $version, $newModified, $oldModified);
+ }
+
+ // Return extension file names
+ public function getExtensionFileNames($settings, $reverse = false) {
+ $fileNames = array();
+ foreach ($settings as $key=>$value) {
+ if (strposu($key, "/")) array_push($fileNames, $key);
+ }
+ if ($reverse) $fileNames = array_reverse($fileNames);
+ return $fileNames;
+ }
+
+ // Return extension root pages for content files
+ public function getExtensionContentRootPages() {
+ $rootPages = array();
+ foreach ($this->yellow->content->scanLocation("") as $page) {
+ if ($page->isAvailable() && $page->isVisible()) array_push($rootPages, $page);
+ }
+ return $rootPages;
+ }
+
+ // Return extension files names for content files
+ public function getExtensionContentFileNames($fileName, $pathBase, $entry, $flags, $languages, $page) {
+ if (preg_match("/multi-language/i", $flags)) {
+ $languageFound = "";
+ $languagesWanted = array($page->get("language"), "en");
+ foreach ($languagesWanted as $language) {
+ if (in_array($language, $languages)) {
+ $languageFound = $language;
+ break;
+ }
+ }
+ $pathLanguage = $languageFound ? "$languageFound/" : "";
+ $fileNameSource = $pathBase.$pathLanguage.$entry;
+ } else {
+ $fileNameSource = $pathBase.$entry;
+ }
+ if ($this->yellow->system->get("coreMultiLanguageMode")) {
+ $contentDirectoryLength = strlenu($this->yellow->system->get("coreContentDirectory"));
+ $fileNameDestination = $page->fileName.substru($fileName, $contentDirectoryLength);
+ } else {
+ $fileNameDestination = $fileName;
+ }
+ return array($fileNameSource, $fileNameDestination);
+ }
+
+ // Return extension file
+ public function getExtensionFile($url) {
+ $urlRequest = $url;
+ if (preg_match("#^https://github.com/(.+)/raw/(.+)$#", $url, $matches)) $urlRequest = "https://raw.githubusercontent.com/".$matches[1]."/".$matches[2];
+ $curlHandle = curl_init();
+ curl_setopt($curlHandle, CURLOPT_URL, $urlRequest);
+ curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowUpdate/".YellowUpdate::VERSION."; SoftwareUpdater)");
+ curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
+ $rawData = curl_exec($curlHandle);
+ $statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
+ $fileData = "";
+ curl_close($curlHandle);
+ if ($statusCode==200) {
+ $fileData = $rawData;
+ } elseif ($statusCode==0) {
+ $statusCode = 500;
+ list($scheme, $address) = $this->yellow->lookup->getUrlInformation($url);
+ $this->yellow->page->error($statusCode, "Can't connect to server '$scheme://$address'!");
+ } else {
+ $statusCode = 500;
+ $this->yellow->page->error($statusCode, "Can't download file '$url'!");
+ }
+ if (defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::getExtensionFile status:$statusCode url:$url \n";
+ return array($statusCode, $fileData);
+ }
+
+ // Check if extension pending
+ public function isExtensionPending() {
+ $path = $this->yellow->system->get("coreExtensionDirectory");
+ return count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", false, false))>0;
+ }
+}
diff --git a/system/extensions/wiki/extension.ini b/system/extensions/wiki/extension.ini
new file mode 100644
index 0000000..f981621
--- /dev/null
+++ b/system/extensions/wiki/extension.ini
@@ -0,0 +1,16 @@
+# Datenstrom Yellow extension settings
+
+Extension: Wiki
+Version: 0.8.11
+Description: Wiki for your website.
+HelpUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/wiki
+DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/wiki.zip
+Published: 2020-08-16 13:29:15
+Developer: Datenstrom
+Tag: feature
+system/extensions/wiki.php: wiki.php,create,update
+system/layouts/wiki.html: wiki.html,create,update,careful
+system/layouts/wikipages.html: wikipages.html,create,update,careful
+content/shared/page-new-wiki.md: page-new-wiki.md,create,optional
+content/2-wiki/page.md: page.md,create,optional
+content/2-wiki/wiki-example.md: wiki-example.md,create,optional
diff --git a/system/extensions/wiki/page-new-wiki.md b/system/extensions/wiki/page-new-wiki.md
new file mode 100644
index 0000000..b26ac69
--- /dev/null
+++ b/system/extensions/wiki/page-new-wiki.md
@@ -0,0 +1,6 @@
+---
+Title: Wiki page
+Layout: wiki
+Tag: Example
+---
+This is a new wiki page.
\ No newline at end of file
diff --git a/system/extensions/wiki/page.md b/system/extensions/wiki/page.md
new file mode 100644
index 0000000..d2250ca
--- /dev/null
+++ b/system/extensions/wiki/page.md
@@ -0,0 +1,9 @@
+---
+Title: Wiki
+Layout: wikipages
+LayoutNew: wiki
+Tag: Example
+---
+Datenstrom Yellow is for people who make small websites. Create small web pages, blogs and wikis. The focus is on people and that it's useful for you. No database, no admin panel, nothing that gets in your way. You make your website, we take care of the rest.
+
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
diff --git a/system/extensions/wiki/wiki-example.md b/system/extensions/wiki/wiki-example.md
new file mode 100644
index 0000000..6f11757
--- /dev/null
+++ b/system/extensions/wiki/wiki-example.md
@@ -0,0 +1,8 @@
+---
+Title: Wiki example
+Layout: wiki
+Tag: Example
+---
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna pizza. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\ No newline at end of file
diff --git a/system/extensions/wiki/wiki.html b/system/extensions/wiki/wiki.html
new file mode 100644
index 0000000..0f64c47
--- /dev/null
+++ b/system/extensions/wiki/wiki.html
@@ -0,0 +1,20 @@
+yellow->layout("header") ?>
+
+
+yellow->page->set("entryClass", "entry") ?>
+yellow->page->isExisting("tag")): ?>
+yellow->page->get("tag")) as $tag) { $this->yellow->page->set("entryClass", $this->yellow->page->get("entryClass")." tag-".$this->yellow->toolbox->normaliseArguments($tag, false)); } ?>
+
+
">
+
yellow->page->getHtml("titleContent") ?>
+
yellow->language->getTextHtml("wikiModified") ?> yellow->page->getDateHtml("modified") ?>
+
yellow->page->getContent() ?>
+yellow->page->isExisting("tag")): ?>
+
+
+
+
+
+yellow->layout("footer") ?>
diff --git a/system/extensions/wiki/wiki.php b/system/extensions/wiki/wiki.php
new file mode 100644
index 0000000..bf1c4e7
--- /dev/null
+++ b/system/extensions/wiki/wiki.php
@@ -0,0 +1,275 @@
+yellow = $yellow;
+ $this->yellow->system->setDefault("wikiLocation", "");
+ $this->yellow->system->setDefault("wikiNewLocation", "@title");
+ $this->yellow->system->setDefault("wikiPagesMax", "5");
+ $this->yellow->system->setDefault("wikiPaginationLimit", "30");
+ }
+
+ // Handle page meta data
+ public function onParseMeta($page) {
+ if ($page===$this->yellow->page) {
+ if ($page->get("layout")=="wikipages" && !$this->yellow->toolbox->isLocationArguments()) {
+ $page->set("layout", $page->isExisting("layoutShow") ? $page->get("layoutShow") : "wiki");
+ }
+ }
+ }
+
+ // Handle page content of shortcut
+ public function onParseContentShortcut($page, $name, $text, $type) {
+ $output = null;
+ if (substru($name, 0, 4)=="wiki" && ($type=="block" || $type=="inline")) {
+ switch($name) {
+ case "wikiauthors": $output = $this->getShorcutWikiauthors($page, $name, $text); break;
+ case "wikipages": $output = $this->getShorcutWikipages($page, $name, $text); break;
+ case "wikichanges": $output = $this->getShorcutWikichanges($page, $name, $text); break;
+ case "wikirelated": $output = $this->getShorcutWikirelated($page, $name, $text); break;
+ case "wikitags": $output = $this->getShorcutWikitags($page, $name, $text); break;
+ }
+ }
+ return $output;
+ }
+
+ // Return wikiauthors shortcut
+ public function getShorcutWikiauthors($page, $name, $text) {
+ $output = null;
+ list($location, $pagesMax) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location)) $location = $this->yellow->system->get("wikiLocation");
+ if (strempty($pagesMax)) $pagesMax = $this->yellow->system->get("wikiPagesMax");
+ $wiki = $this->yellow->content->find($location);
+ $pages = $this->getWikiPages($location);
+ $page->setLastModified($pages->getModified());
+ $authors = $this->getMeta($pages, "author");
+ if (count($authors)) {
+ $authors = $this->yellow->lookup->normaliseUpperLower($authors);
+ if ($pagesMax!=0 && count($authors)>$pagesMax) {
+ uasort($authors, "strnatcasecmp");
+ $authors = array_slice($authors, -$pagesMax);
+ }
+ uksort($authors, "strnatcasecmp");
+ $output = "\n";
+ $output .= "
\n";
+ $output .= "
\n";
+ } else {
+ $page->error(500, "Wikiauthors '$location' does not exist!");
+ }
+ return $output;
+ }
+
+ // Return wikiauthors shortcut
+ public function getShorcutWikipages($page, $name, $text) {
+ $output = null;
+ list($location, $pagesMax, $author, $tag) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location)) $location = $this->yellow->system->get("wikiLocation");
+ if (strempty($pagesMax)) $pagesMax = $this->yellow->system->get("wikiPagesMax");
+ $wiki = $this->yellow->content->find($location);
+ $pages = $this->getWikiPages($location);
+ if (!empty($author)) $pages->filter("author", $author);
+ if (!empty($tag)) $pages->filter("tag", $tag);
+ $pages->sort("title");
+ $page->setLastModified($pages->getModified());
+ if (count($pages)) {
+ if ($pagesMax!=0) $pages->limit($pagesMax);
+ $output = "\n";
+ $output .= "
\n";
+ $output .= "
\n";
+ } else {
+ $page->error(500, "Wikipages '$location' does not exist!");
+ }
+ return $output;
+ }
+
+ // Return wikiauthors shortcut
+ public function getShorcutWikichanges($page, $name, $text) {
+ $output = null;
+ list($location, $pagesMax, $author, $tag) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location)) $location = $this->yellow->system->get("wikiLocation");
+ if (strempty($pagesMax)) $pagesMax = $this->yellow->system->get("wikiPagesMax");
+ $wiki = $this->yellow->content->find($location);
+ $pages = $this->getWikiPages($location);
+ if (!empty($author)) $pages->filter("author", $author);
+ if (!empty($tag)) $pages->filter("tag", $tag);
+ $pages->sort("modified", false);
+ $page->setLastModified($pages->getModified());
+ if (count($pages)) {
+ if ($pagesMax!=0) $pages->limit($pagesMax);
+ $output = "\n";
+ $output .= "
\n";
+ $output .= "
\n";
+ } else {
+ $page->error(500, "Wikichanges '$location' does not exist!");
+ }
+ return $output;
+ }
+
+ // Return wikiauthors shortcut
+ public function getShorcutWikirelated($page, $name, $text) {
+ $output = null;
+ list($location, $pagesMax) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location)) $location = $this->yellow->system->get("wikiLocation");
+ if (strempty($pagesMax)) $pagesMax = $this->yellow->system->get("wikiPagesMax");
+ $wiki = $this->yellow->content->find($location);
+ $pages = $this->getWikiPages($location);
+ $pages->similar($page->getPage("main"));
+ $page->setLastModified($pages->getModified());
+ if (count($pages)) {
+ if ($pagesMax!=0) $pages->limit($pagesMax);
+ $output = "\n";
+ $output .= "
\n";
+ $output .= "
\n";
+ } else {
+ $page->error(500, "Wikirelated '$location' does not exist!");
+ }
+ return $output;
+ }
+
+ // Return wikiauthors shortcut
+ public function getShorcutWikitags($page, $name, $text) {
+ $output = null;
+ list($location, $pagesMax) = $this->yellow->toolbox->getTextArguments($text);
+ if (empty($location)) $location = $this->yellow->system->get("wikiLocation");
+ if (strempty($pagesMax)) $pagesMax = $this->yellow->system->get("wikiPagesMax");
+ $wiki = $this->yellow->content->find($location);
+ $pages = $this->getWikiPages($location);
+ $page->setLastModified($pages->getModified());
+ $tags = $this->getMeta($pages, "tag");
+ if (count($tags)) {
+ $tags = $this->yellow->lookup->normaliseUpperLower($tags);
+ if ($pagesMax!=0 && count($tags)>$pagesMax) {
+ uasort($tags, "strnatcasecmp");
+ $tags = array_slice($tags, -$pagesMax);
+ }
+ uksort($tags, "strnatcasecmp");
+ $output = "\n";
+ $output .= "
\n";
+ $output .= "
\n";
+ } else {
+ $page->error(500, "Wikitags '$location' does not exist!");
+ }
+ return $output;
+ }
+
+ // Handle page layout
+ public function onParsePageLayout($page, $name) {
+ if ($name=="wikipages") {
+ $chronologicalOrder = false;
+ $pages = $this->getWikiPages($this->yellow->page->location);
+ $pagesFilter = array();
+ if ($page->getRequest("special")=="pages") {
+ array_push($pagesFilter, $this->yellow->language->getText("wikiSpecialPages"));
+ }
+ if ($page->getRequest("special")=="changes") {
+ $chronologicalOrder = true;
+ array_push($pagesFilter, $this->yellow->language->getText("wikiSpecialChanges"));
+ }
+ if ($page->isRequest("tag")) {
+ $pages->filter("tag", $page->getRequest("tag"));
+ array_push($pagesFilter, $pages->getFilter());
+ }
+ if ($page->isRequest("author")) {
+ $pages->filter("author", $page->getRequest("author"), false);
+ array_push($pagesFilter, $pages->getFilter());
+ }
+ if ($page->isRequest("modified")) {
+ $pages->filter("modified", $page->getRequest("modified"), false);
+ array_push($pagesFilter, $this->yellow->language->normaliseDate($pages->getFilter()));
+ }
+ $pages->sort($chronologicalOrder ? "modified" : "title", $chronologicalOrder);
+ $pages->pagination($this->yellow->system->get("wikiPaginationLimit"));
+ if (!$pages->getPaginationNumber()) $this->yellow->page->error(404);
+ if (!empty($pagesFilter)) {
+ $text = implode(" ", $pagesFilter);
+ $this->yellow->page->set("titleHeader", $text." - ".$this->yellow->page->get("sitename"));
+ $this->yellow->page->set("titleContent", $this->yellow->page->get("title").": ".$text);
+ $this->yellow->page->set("title", $this->yellow->page->get("title").": ".$text);
+ $this->yellow->page->set("wikipagesChronologicalOrder", $chronologicalOrder);
+ }
+ $this->yellow->page->setPages("wiki", $pages);
+ $this->yellow->page->setLastModified($pages->getModified());
+ $this->yellow->page->setHeader("Cache-Control", "max-age=60");
+ }
+ if ($name=="wiki") {
+ $location = $this->yellow->system->get("wikiLocation");
+ if (empty($location)) $location = $this->yellow->lookup->getDirectoryLocation($this->yellow->page->location);
+ $wiki = $this->yellow->content->find($location);
+ $this->yellow->page->setPage("wiki", $wiki);
+ }
+ }
+
+ // Handle content file editing
+ public function onEditContentFile($page, $action, $email) {
+ if ($page->get("layout")=="wiki") $page->set("pageNewLocation", $this->yellow->system->get("wikiNewLocation"));
+ }
+
+ // Return wiki pages
+ public function getWikiPages($location) {
+ $pages = $this->yellow->content->clean();
+ $wiki = $this->yellow->content->find($location);
+ if ($wiki) {
+ if ($location==$this->yellow->system->get("wikiLocation")) {
+ $pages = $this->yellow->content->index(!$wiki->isVisible());
+ } else {
+ $pages = $wiki->getChildren(!$wiki->isVisible());
+ }
+ $wiki->set("layout", $wiki->isExisting("layoutShow") ? $wiki->get("layoutShow") : "wiki");
+ $pages->append($wiki)->filter("layout", "wiki");
+ }
+ return $pages;
+ }
+
+ // Return class for page
+ public function getClass($page) {
+ if ($page->isExisting("tag")) {
+ foreach (preg_split("/\s*,\s*/", $page->get("tag")) as $tag) {
+ $class .= " tag-".$this->yellow->toolbox->normaliseArguments($tag, false);
+ }
+ }
+ return trim($class);
+ }
+
+ // Return meta data from page collection
+ public function getMeta($pages, $key) {
+ $data = array();
+ foreach ($pages as $page) {
+ if ($page->isExisting($key)) {
+ foreach (preg_split("/\s*,\s*/", $page->get($key)) as $entry) {
+ ++$data[$entry];
+ }
+ }
+ }
+ return $data;
+ }
+}
diff --git a/system/extensions/wiki/wikipages.html b/system/extensions/wiki/wikipages.html
new file mode 100644
index 0000000..c769b04
--- /dev/null
+++ b/system/extensions/wiki/wikipages.html
@@ -0,0 +1,20 @@
+yellow->layout("header") ?>
+
+
+
yellow->page->getHtml("titleContent") ?>
+
+
+yellow->page->getPages("wiki") as $page): ?>
+yellow->page->get("wikipagesChronologicalOrder")): ?>
+getDate("modified")) ?>
+
+get("title"), 0, 1))) ?>
+
+$section
+yellow->layout("pagination", $this->yellow->page->getPages("wiki")) ?>
+
+
+yellow->layout("footer") ?>
diff --git a/system/extensions/yellow.log b/system/extensions/yellow.log
new file mode 100644
index 0000000..dcf43e8
--- /dev/null
+++ b/system/extensions/yellow.log
@@ -0,0 +1,5 @@
+2020-08-21 08:49:53 info Datenstrom Yellow 0.8.15, PHP 7.3.8, Apache 2.4.34, Mac
+2020-08-21 08:49:53 info Install extension 'English 0.8.24'
+2020-08-21 08:49:53 info Install extension 'French 0.8.24'
+2020-08-21 08:49:53 info Install extension 'German 0.8.24'
+2020-08-21 08:50:35 info Add user 'Alphonse'
diff --git a/system/layouts/default.html b/system/layouts/default.html
new file mode 100644
index 0000000..9c1fb60
--- /dev/null
+++ b/system/layouts/default.html
@@ -0,0 +1,8 @@
+yellow->layout("header") ?>
+
+
+
yellow->page->getHtml("titleContent") ?>
+yellow->page->getContent() ?>
+
+
+yellow->layout("footer") ?>
diff --git a/system/layouts/error.html b/system/layouts/error.html
new file mode 100644
index 0000000..9c1fb60
--- /dev/null
+++ b/system/layouts/error.html
@@ -0,0 +1,8 @@
+yellow->layout("header") ?>
+
+
+
yellow->page->getHtml("titleContent") ?>
+yellow->page->getContent() ?>
+
+
+yellow->layout("footer") ?>
diff --git a/system/layouts/footer.html b/system/layouts/footer.html
new file mode 100644
index 0000000..bd6fdbb
--- /dev/null
+++ b/system/layouts/footer.html
@@ -0,0 +1,10 @@
+
+
+yellow->page->getExtra("footer") ?>
+
+
diff --git a/system/layouts/header.html b/system/layouts/header.html
new file mode 100644
index 0000000..d078bff
--- /dev/null
+++ b/system/layouts/header.html
@@ -0,0 +1,21 @@
+
+">
+
+
yellow->page->getHtml("titleHeader") ?>
+
+
" />
+
" />
+
+
+yellow->page->getExtra("header") ?>
+
+
+
yellow->page->getHtml("layout") ?>">
+
diff --git a/system/layouts/navigation.html b/system/layouts/navigation.html
new file mode 100644
index 0000000..96c70b5
--- /dev/null
+++ b/system/layouts/navigation.html
@@ -0,0 +1,10 @@
+yellow->content->top() ?>
+yellow->page->setLastModified($pages->getModified()) ?>
+
+
diff --git a/system/layouts/pagination.html b/system/layouts/pagination.html
new file mode 100644
index 0000000..2bb8d67
--- /dev/null
+++ b/system/layouts/pagination.html
@@ -0,0 +1,11 @@
+yellow->getLayoutArguments() ?>
+isPagination()): ?>
+
+
diff --git a/system/settings/language.ini b/system/settings/language.ini
new file mode 100644
index 0000000..177002a
--- /dev/null
+++ b/system/settings/language.ini
@@ -0,0 +1,9 @@
+# Datenstrom Yellow language settings
+
+Language: en
+CoreDateFormatShort: F Y
+CoreDateFormatMedium: Y-m-d
+CoreDateFormatLong: Y-m-d H:i
+EditMailFooter: @sitename
+ImageDefaultAlt: Image without description
+media/images/photo.jpg: This is an example image
diff --git a/system/settings/system.ini b/system/settings/system.ini
new file mode 100644
index 0000000..c2dff4d
--- /dev/null
+++ b/system/settings/system.ini
@@ -0,0 +1,70 @@
+# Datenstrom Yellow system settings
+
+Sitename: Datenstrom Yellow
+Author: Alphonse
+Email: alphonse@brown.com
+Language: en
+Layout: default
+Theme: stockholm
+Parser: markdown
+Status: public
+CoreStaticUrl: http://localhost/sandbox/www/yellow/
+CoreServerUrl: auto
+CoreServerTimezone: Europe/Zurich
+CoreMultiLanguageMode: 0
+CoreMediaLocation: /media/
+CoreDownloadLocation: /media/downloads/
+CoreImageLocation: /media/images/
+CoreExtensionLocation: /media/extensions/
+CoreThemeLocation: /media/themes/
+CoreMediaDirectory: media/
+CoreDownloadDirectory: media/downloads/
+CoreImageDirectory: media/images/
+CoreSystemDirectory: system/
+CoreExtensionDirectory: system/extensions/
+CoreSettingDirectory: system/settings/
+CoreLayoutDirectory: system/layouts/
+CoreThemeDirectory: system/themes/
+CoreTrashDirectory: system/trash/
+CoreCacheDirectory: cache/
+CoreContentDirectory: content/
+CoreContentRootDirectory: default/
+CoreContentHomeDirectory: home/
+CoreContentSharedDirectory: shared/
+CoreContentDefaultFile: page.md
+CoreContentErrorFile: page-error-(.*).md
+CoreContentExtension: .md
+CoreDownloadExtension: .download
+CoreUserFile: user.ini
+CoreLanguageFile: language.ini
+CoreLogFile: yellow.log
+UpdateExtensionUrl: https://github.com/datenstrom/yellow-extensions
+UpdateExtensionFile: extension.ini
+UpdateCurrentFile: update-current.ini
+UpdateLatestFile: update-latest.ini
+UpdateNotification: none
+CommandStaticBuildDirectory: public/
+CommandStaticDefaultFile: index.html
+CommandStaticErrorFile: 404.html
+EditLocation: /edit/
+EditUploadNewLocation: /media/@group/@filename
+EditUploadExtensions: .gif, .jpg, .pdf, .png, .svg, .zip
+EditKeyboardShortcuts: ctrl+b bold, ctrl+i italic, ctrl+k strikethrough, ctrl+e code, ctrl+s save, ctrl+alt+p preview
+EditToolbarButtons: auto
+EditEndOfLine: auto
+EditNewFile: page-new-(.*).md
+EditUserPasswordMinLength: 8
+EditUserHashAlgorithm: bcrypt
+EditUserHashCost: 10
+EditUserHome: /
+EditUserAccess: create, edit, delete, upload
+EditLoginRestriction: 0
+EditLoginSessionTimeout: 2592000
+EditBruteForceProtection: 25
+ImageUploadWidthMax: 1280
+ImageUploadHeightMax: 1280
+ImageUploadJpgQuality: 80
+ImageThumbnailLocation: /media/thumbnails/
+ImageThumbnailDirectory: media/thumbnails/
+ImageThumbnailJpgQuality: 80
+MetaDefaultImage: favicon
diff --git a/system/settings/user.ini b/system/settings/user.ini
new file mode 100644
index 0000000..d95b616
--- /dev/null
+++ b/system/settings/user.ini
@@ -0,0 +1,13 @@
+# Datenstrom Yellow user settings
+
+Email: alphonse@brown.com
+Name: Alphonse
+Language: en
+Home: /
+Access: create, edit, delete, upload, system, update
+Hash: $2y$10$23/5JKZ8aWZQiImOfk9huuxR.VqVPfyWY8qHu1A9Ps3uelEGb5Ss.
+Stamp: ed6881f247fd2846df04
+Pending: none
+Failed: 0
+Modified: 2020-08-21 10:51:08
+Status: active
diff --git a/system/themes/stockholm-opensans-bold.woff b/system/themes/stockholm-opensans-bold.woff
new file mode 100644
index 0000000..ca2f1c2
Binary files /dev/null and b/system/themes/stockholm-opensans-bold.woff differ
diff --git a/system/themes/stockholm-opensans-license.txt b/system/themes/stockholm-opensans-license.txt
new file mode 100644
index 0000000..989e2c5
--- /dev/null
+++ b/system/themes/stockholm-opensans-license.txt
@@ -0,0 +1,201 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/system/themes/stockholm-opensans-light.woff b/system/themes/stockholm-opensans-light.woff
new file mode 100644
index 0000000..32da261
Binary files /dev/null and b/system/themes/stockholm-opensans-light.woff differ
diff --git a/system/themes/stockholm-opensans-regular.woff b/system/themes/stockholm-opensans-regular.woff
new file mode 100644
index 0000000..ac2b2c6
Binary files /dev/null and b/system/themes/stockholm-opensans-regular.woff differ
diff --git a/system/themes/stockholm.css b/system/themes/stockholm.css
new file mode 100644
index 0000000..14a4885
--- /dev/null
+++ b/system/themes/stockholm.css
@@ -0,0 +1,362 @@
+/* Stockholm extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/stockholm */
+
+html, body, div, form, pre, span, tr, th, td, img {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ vertical-align: baseline;
+}
+@font-face {
+ font-family: "Open Sans";
+ font-style: normal;
+ font-weight: 300;
+ src: url(stockholm-opensans-light.woff) format("woff");
+}
+@font-face {
+ font-family: "Open Sans";
+ font-style: normal;
+ font-weight: 400;
+ src: url(stockholm-opensans-regular.woff) format("woff");
+}
+@font-face {
+ font-family: "Open Sans";
+ font-style: normal;
+ font-weight: 700;
+ src: url(stockholm-opensans-bold.woff) format("woff");
+}
+body {
+ margin: 1em;
+ background-color: #fff;
+ color: #666;
+ font-family: "Open Sans", Helvetica, sans-serif;
+ font-size: 1em;
+ font-weight: 300;
+ line-height: 1.5;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ color: #111;
+ font-weight: 400;
+}
+h1 {
+ font-size: 2em;
+}
+hr {
+ height: 1px;
+ background: #ddd;
+ border: 0;
+}
+strong {
+ font-weight: bold;
+}
+code {
+ font-size: 1.1em;
+}
+a {
+ color: #07d;
+ text-decoration: none;
+}
+a:hover {
+ color: #07d;
+ text-decoration: underline;
+}
+
+/* Content */
+
+.content h1 {
+ margin: 1em 0;
+}
+.content h1 a {
+ color: #111;
+}
+.content h1 a:hover {
+ color: #111;
+ text-decoration: none;
+}
+.content img {
+ max-width: 100%;
+ height: auto;
+}
+.content form {
+ margin: 1em 0;
+}
+.content table {
+ border-spacing: 0;
+ border-collapse: collapse;
+}
+.content th {
+ text-align: left;
+ padding: 0.3em;
+}
+.content td {
+ text-align: left;
+ padding: 0.3em;
+ border-top: 1px solid #ddd;
+ border-bottom: 1px solid #ddd;
+}
+.content code,
+.content pre {
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
+ font-size: 90%;
+}
+.content code {
+ padding: 0.15em 0.4em;
+ margin: 0;
+ background-color: #f7f7f7;
+ border-radius: 3px;
+}
+.content pre > code {
+ padding: 0;
+ margin: 0;
+ white-space: pre;
+ background: transparent;
+ border: 0;
+ font-size: inherit;
+}
+.content pre {
+ padding: 1em;
+ overflow: auto;
+ line-height: 1.45;
+ background-color: #f7f7f7;
+ border-radius: 3px;
+}
+.content blockquote {
+ margin-left: 0;
+ padding-left: 1em;
+ border-left: 1px solid #ddd;
+}
+.content .notice1 {
+ margin: 1em 0;
+ padding: 10px 1em;
+ background-color: #fffbf0;
+ border-left: 10px solid #fb0;
+}
+.content .notice2 {
+ margin: 1em 0;
+ padding: 10px 1em;
+ background-color: #fdf0f0;
+ border-left: 10px solid #d00;
+}
+.content .notice3,
+.content .notice4,
+.content .notice5,
+.content .notice6 {
+ margin: 1em 0;
+ padding: 10px 1em;
+ background-color: #f0f8fe;
+ border-left: 10px solid #08e;
+}
+.content .flexible {
+ position: relative;
+ padding-top: 0;
+ padding-bottom: 56.25%;
+}
+.content .flexible iframe {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+}
+.content .task-list-item {
+ list-style-type: none;
+}
+.content .task-list-item input {
+ margin: 0 0.2em 0.25em -1.75em;
+ vertical-align: middle;
+}
+.content .toc {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+.content .wikipages ul,
+.content .wikitags ul,
+.content .wikilinks ul {
+ padding: 0;
+ list-style: none;
+ column-width: 19em;
+}
+.content .entry-links .previous {
+ margin-right: 1em;
+}
+.content .pagination .previous {
+ margin-right: 1em;
+}
+.content .pagination {
+ margin: 1em 0;
+}
+.content .left {
+ float: left;
+ margin: 0 1em 0 0;
+}
+.content .center {
+ display: block;
+ margin: 0 auto;
+}
+.content .right {
+ float: right;
+ margin: 0 0 0 1em;
+}
+.content .rounded {
+ border-radius: 4px;
+}
+
+/* Header */
+
+.header {
+ margin: 2em 0;
+}
+.header .sitename {
+ display: block;
+ float: left;
+}
+.header .sitename h1 {
+ margin: 0;
+ font-size: 1em;
+ font-weight: 300;
+}
+.header .sitename h1 a {
+ color: #666;
+ border-bottom: solid 3px #fff;
+ text-decoration: none;
+ padding: 0.5em 0;
+}
+.header .sitename h1 a:hover {
+ color: #07d;
+ border-bottom: solid 3px #29f;
+}
+.header .sitename p {
+ margin-top: 0;
+ color: #666;
+}
+
+/* Navigation */
+
+.navigation {
+ display: block;
+ float: right;
+}
+.navigation a {
+ color: #666;
+ border-bottom: solid 3px #fff;
+ text-decoration: none;
+ padding: 0.5em 0;
+ margin: 0 0.5em;
+}
+.navigation a:hover {
+ color: #07d;
+ border-bottom: solid 3px #29f;
+}
+.navigation ul {
+ margin: 0 -0.5em;
+ padding: 0;
+ list-style: none;
+}
+.navigation li {
+ display: inline;
+}
+.navigation li a.active {
+ border-bottom: solid 3px #29f;
+}
+.navigation-banner {
+ clear: both;
+}
+
+/* Footer */
+
+.footer {
+ margin: 2em 0;
+}
+.footer .siteinfo a {
+ color: #07d;
+}
+.footer .siteinfo a:hover {
+ color: #07d;
+ text-decoration: underline;
+}
+
+/* Forms and buttons */
+
+.form-control {
+ margin: 0;
+ padding: 2px 4px;
+ display: inline-block;
+ min-width: 7em;
+ background-color: #fff;
+ color: #666;
+ background-image: linear-gradient(to bottom, #fff, #fff);
+ border: 1px solid #bbb;
+ border-radius: 4px;
+ font-size: 0.9em;
+ font-family: inherit;
+ font-weight: normal;
+ line-height: normal;
+}
+.btn {
+ margin: 0;
+ padding: 4px 22px;
+ display: inline-block;
+ min-width: 7em;
+ background-color: #eaeaea;
+ color: #333333;
+ background-image: linear-gradient(to bottom, #f8f8f8, #e1e1e1);
+ border: 1px solid #bbb;
+ border-color: #c1c1c1 #c1c1c1 #aaaaaa;
+ border-radius: 4px;
+ outline-offset: -2px;
+ font-size: 0.9em;
+ font-family: inherit;
+ font-weight: normal;
+ line-height: 1;
+ text-align: center;
+ text-decoration: none;
+ box-sizing: border-box;
+}
+.btn:hover,
+.btn:focus,
+.btn:active {
+ color: #333333;
+ background-image: none;
+ text-decoration: none;
+}
+.btn:active {
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
+}
+
+/* Responsive and print */
+
+.page {
+ margin: 0 auto;
+ max-width: 1000px;
+}
+
+@media screen and (min-width: 62em) {
+ body {
+ width: 60em;
+ margin: 1em auto;
+ }
+ .page {
+ margin: 0;
+ max-width: none;
+ }
+}
+@media screen and (max-width: 32em) {
+ body {
+ margin: 0.5em;
+ font-size: 0.9em;
+ }
+ .content h1,
+ .content h2 {
+ font-size: 1.5em;
+ }
+}
+@media print {
+ .page {
+ border: none !important;
+ }
+}
diff --git a/system/themes/stockholm.png b/system/themes/stockholm.png
new file mode 100644
index 0000000..7d0ecef
Binary files /dev/null and b/system/themes/stockholm.png differ
diff --git a/yellow.php b/yellow.php
new file mode 100644
index 0000000..be7b8e5
--- /dev/null
+++ b/yellow.php
@@ -0,0 +1,14 @@
+load();
+ $yellow->request();
+} else {
+ $yellow = new YellowCore();
+ $yellow->load();
+ exit($yellow->command());
+}