diff --git a/CHANGELOG.md b/CHANGELOG.md index 064ae53..30668ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +3.2.0 / 2015-10-03 +================== + +* Added markdown support for docs +* Added markdown styling via [github-markdown.css](https://github.com/sindresorhus/github-markdown-css) +* Increased .sg-h2 and .sg-h3 font size to better align with github markdown heading sizes +* Converted sample documentation .html files to .md files +* Removed "Usage" heading that appeared above docs + 3.1.0 / 2015-07-27 ================== diff --git a/Parsedown.php b/Parsedown.php new file mode 100644 index 0000000..2be4056 --- /dev/null +++ b/Parsedown.php @@ -0,0 +1,1528 @@ +DefinitionData = array(); + + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + # remove surrounding line breaks + $text = trim($text, "\n"); + + # split text into lines + $lines = explode("\n", $text); + + # iterate through lines to identify blocks + $markup = $this->lines($lines); + + # trim line breaks + $markup = trim($markup, "\n"); + + return $markup; + } + + # + # Setters + # + + function setBreaksEnabled($breaksEnabled) + { + $this->breaksEnabled = $breaksEnabled; + + return $this; + } + + protected $breaksEnabled; + + function setMarkupEscaped($markupEscaped) + { + $this->markupEscaped = $markupEscaped; + + return $this; + } + + protected $markupEscaped; + + function setUrlsLinked($urlsLinked) + { + $this->urlsLinked = $urlsLinked; + + return $this; + } + + protected $urlsLinked = true; + + # + # Lines + # + + protected $BlockTypes = array( + '#' => array('Header'), + '*' => array('Rule', 'List'), + '+' => array('List'), + '-' => array('SetextHeader', 'Table', 'Rule', 'List'), + '0' => array('List'), + '1' => array('List'), + '2' => array('List'), + '3' => array('List'), + '4' => array('List'), + '5' => array('List'), + '6' => array('List'), + '7' => array('List'), + '8' => array('List'), + '9' => array('List'), + ':' => array('Table'), + '<' => array('Comment', 'Markup'), + '=' => array('SetextHeader'), + '>' => array('Quote'), + '[' => array('Reference'), + '_' => array('Rule'), + '`' => array('FencedCode'), + '|' => array('Table'), + '~' => array('FencedCode'), + ); + + # ~ + + protected $unmarkedBlockTypes = array( + 'Code', + ); + + # + # Blocks + # + + private function lines(array $lines) + { + $CurrentBlock = null; + + foreach ($lines as $line) + { + if (chop($line) === '') + { + if (isset($CurrentBlock)) + { + $CurrentBlock['interrupted'] = true; + } + + continue; + } + + if (strpos($line, "\t") !== false) + { + $parts = explode("\t", $line); + + $line = $parts[0]; + + unset($parts[0]); + + foreach ($parts as $part) + { + $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + + $line .= str_repeat(' ', $shortage); + $line .= $part; + } + } + + $indent = 0; + + while (isset($line[$indent]) and $line[$indent] === ' ') + { + $indent ++; + } + + $text = $indent > 0 ? substr($line, $indent) : $line; + + # ~ + + $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); + + # ~ + + if (isset($CurrentBlock['continuable'])) + { + $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock); + + if (isset($Block)) + { + $CurrentBlock = $Block; + + continue; + } + else + { + if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + } + } + + # ~ + + $marker = $text[0]; + + # ~ + + $blockTypes = $this->unmarkedBlockTypes; + + if (isset($this->BlockTypes[$marker])) + { + foreach ($this->BlockTypes[$marker] as $blockType) + { + $blockTypes []= $blockType; + } + } + + # + # ~ + + foreach ($blockTypes as $blockType) + { + $Block = $this->{'block'.$blockType}($Line, $CurrentBlock); + + if (isset($Block)) + { + $Block['type'] = $blockType; + + if ( ! isset($Block['identified'])) + { + $Blocks []= $CurrentBlock; + + $Block['identified'] = true; + } + + if (method_exists($this, 'block'.$blockType.'Continue')) + { + $Block['continuable'] = true; + } + + $CurrentBlock = $Block; + + continue 2; + } + } + + # ~ + + if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) + { + $CurrentBlock['element']['text'] .= "\n".$text; + } + else + { + $Blocks []= $CurrentBlock; + + $CurrentBlock = $this->paragraph($Line); + + $CurrentBlock['identified'] = true; + } + } + + # ~ + + if (isset($CurrentBlock['continuable']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete')) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + + # ~ + + $Blocks []= $CurrentBlock; + + unset($Blocks[0]); + + # ~ + + $markup = ''; + + foreach ($Blocks as $Block) + { + if (isset($Block['hidden'])) + { + continue; + } + + $markup .= "\n"; + $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']); + } + + $markup .= "\n"; + + # ~ + + return $markup; + } + + # + # Code + + protected function blockCode($Line, $Block = null) + { + if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] >= 4) + { + $text = substr($Line['body'], 4); + + $Block = array( + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => array( + 'name' => 'code', + 'text' => $text, + ), + ), + ); + + return $Block; + } + } + + protected function blockCodeContinue($Line, $Block) + { + if ($Line['indent'] >= 4) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['element']['text']['text'] .= "\n"; + + $text = substr($Line['body'], 4); + + $Block['element']['text']['text'] .= $text; + + return $Block; + } + } + + protected function blockCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Comment + + protected function blockComment($Line) + { + if ($this->markupEscaped) + { + return; + } + + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + { + $Block = array( + 'markup' => $Line['body'], + ); + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function blockCommentContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['markup'] .= "\n" . $Line['body']; + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + + # + # Fenced Code + + protected function blockFencedCode($Line) + { + if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches)) + { + $Element = array( + 'name' => 'code', + 'text' => '', + ); + + if (isset($matches[1])) + { + $class = 'language-'.$matches[1]; + + $Element['attributes'] = array( + 'class' => $class, + ); + } + + $Block = array( + 'char' => $Line['text'][0], + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => $Element, + ), + ); + + return $Block; + } + } + + protected function blockFencedCodeContinue($Line, $Block) + { + if (isset($Block['complete'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text'])) + { + $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1); + + $Block['complete'] = true; + + return $Block; + } + + $Block['element']['text']['text'] .= "\n".$Line['body'];; + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Header + + protected function blockHeader($Line) + { + if (isset($Line['text'][1])) + { + $level = 1; + + while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') + { + $level ++; + } + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '# '); + + $Block = array( + 'element' => array( + 'name' => 'h' . min(6, $level), + 'text' => $text, + 'handler' => 'line', + ), + ); + + return $Block; + } + } + + # + # List + + protected function blockList($Line) + { + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); + + if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'indent' => $Line['indent'], + 'pattern' => $pattern, + 'element' => array( + 'name' => $name, + 'handler' => 'elements', + ), + ); + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $matches[2], + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + } + + protected function blockListContinue($Line, array $Block) + { + if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['li']['text'] []= ''; + + unset($Block['interrupted']); + } + + unset($Block['li']); + + $text = isset($matches[1]) ? $matches[1] : ''; + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $text, + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + + if ($Line['text'][0] === '[' and $this->blockReference($Line)) + { + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + return $Block; + } + + if ($Line['indent'] > 0) + { + $Block['li']['text'] []= ''; + + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + unset($Block['interrupted']); + + return $Block; + } + } + + # + # Quote + + protected function blockQuote($Line) + { + if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'element' => array( + 'name' => 'blockquote', + 'handler' => 'lines', + 'text' => (array) $matches[1], + ), + ); + + return $Block; + } + } + + protected function blockQuoteContinue($Line, array $Block) + { + if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text'] []= ''; + + unset($Block['interrupted']); + } + + $Block['element']['text'] []= $matches[1]; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $Block['element']['text'] []= $Line['text']; + + return $Block; + } + } + + # + # Rule + + protected function blockRule($Line) + { + if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) + { + $Block = array( + 'element' => array( + 'name' => 'hr' + ), + ); + + return $Block; + } + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (chop($Line['text'], $Line['text'][0]) === '') + { + $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; + + return $Block; + } + } + + # + # Markup + + protected function blockMarkup($Line) + { + if ($this->markupEscaped) + { + return; + } + + if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) + { + $element = strtolower($matches[1]); + + if (in_array($element, $this->textLevelElements)) + { + return; + } + + $Block = array( + 'name' => $matches[1], + 'depth' => 0, + 'markup' => $Line['text'], + ); + + $length = strlen($matches[0]); + + $remainder = substr($Line['text'], $length); + + if (trim($remainder) === '') + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + $Block['closed'] = true; + + $Block['void'] = true; + } + } + else + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + return; + } + + if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder)) + { + $Block['closed'] = true; + } + } + + return $Block; + } + } + + protected function blockMarkupContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open + { + $Block['depth'] ++; + } + + if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close + { + if ($Block['depth'] > 0) + { + $Block['depth'] --; + } + else + { + $Block['closed'] = true; + } + } + + if (isset($Block['interrupted'])) + { + $Block['markup'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['markup'] .= "\n".$Line['body']; + + return $Block; + } + + # + # Reference + + protected function blockReference($Line) + { + if (preg_match('/^\[(.+?)\]:[ ]*?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) + { + $id = strtolower($matches[1]); + + $Data = array( + 'url' => $matches[2], + 'title' => null, + ); + + if (isset($matches[3])) + { + $Data['title'] = $matches[3]; + } + + $this->DefinitionData['Reference'][$id] = $Data; + + $Block = array( + 'hidden' => true, + ); + + return $Block; + } + } + + # + # Table + + protected function blockTable($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '') + { + $alignments = array(); + + $divider = $Line['text']; + + $divider = trim($divider); + $divider = trim($divider, '|'); + + $dividerCells = explode('|', $divider); + + foreach ($dividerCells as $dividerCell) + { + $dividerCell = trim($dividerCell); + + if ($dividerCell === '') + { + continue; + } + + $alignment = null; + + if ($dividerCell[0] === ':') + { + $alignment = 'left'; + } + + if (substr($dividerCell, - 1) === ':') + { + $alignment = $alignment === 'left' ? 'center' : 'right'; + } + + $alignments []= $alignment; + } + + # ~ + + $HeaderElements = array(); + + $header = $Block['element']['text']; + + $header = trim($header); + $header = trim($header, '|'); + + $headerCells = explode('|', $header); + + foreach ($headerCells as $index => $headerCell) + { + $headerCell = trim($headerCell); + + $HeaderElement = array( + 'name' => 'th', + 'text' => $headerCell, + 'handler' => 'line', + ); + + if (isset($alignments[$index])) + { + $alignment = $alignments[$index]; + + $HeaderElement['attributes'] = array( + 'style' => 'text-align: '.$alignment.';', + ); + } + + $HeaderElements []= $HeaderElement; + } + + # ~ + + $Block = array( + 'alignments' => $alignments, + 'identified' => true, + 'element' => array( + 'name' => 'table', + 'handler' => 'elements', + ), + ); + + $Block['element']['text'] []= array( + 'name' => 'thead', + 'handler' => 'elements', + ); + + $Block['element']['text'] []= array( + 'name' => 'tbody', + 'handler' => 'elements', + 'text' => array(), + ); + + $Block['element']['text'][0]['text'] []= array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $HeaderElements, + ); + + return $Block; + } + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); + + foreach ($matches[0] as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => 'line', + 'text' => $cell, + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: '.$Block['alignments'][$index].';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $Elements, + ); + + $Block['element']['text'][1]['text'] []= $Element; + + return $Block; + } + } + + # + # ~ + # + + protected function paragraph($Line) + { + $Block = array( + 'element' => array( + 'name' => 'p', + 'text' => $Line['text'], + 'handler' => 'line', + ), + ); + + return $Block; + } + + # + # Inline Elements + # + + protected $InlineTypes = array( + '"' => array('SpecialCharacter'), + '!' => array('Image'), + '&' => array('SpecialCharacter'), + '*' => array('Emphasis'), + ':' => array('Url'), + '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'), + '>' => array('SpecialCharacter'), + '[' => array('Link'), + '_' => array('Emphasis'), + '`' => array('Code'), + '~' => array('Strikethrough'), + '\\' => array('EscapeSequence'), + ); + + # ~ + + protected $inlineMarkerList = '!"*_&[:<>`~\\'; + + # + # ~ + # + + public function line($text) + { + $markup = ''; + + # $excerpt is based on the first occurrence of a marker + + while ($excerpt = strpbrk($text, $this->inlineMarkerList)) + { + $marker = $excerpt[0]; + + $markerPosition = strpos($text, $marker); + + $Excerpt = array('text' => $excerpt, 'context' => $text); + + foreach ($this->InlineTypes[$marker] as $inlineType) + { + $Inline = $this->{'inline'.$inlineType}($Excerpt); + + if ( ! isset($Inline)) + { + continue; + } + + # makes sure that the inline belongs to "our" marker + + if (isset($Inline['position']) and $Inline['position'] > $markerPosition) + { + continue; + } + + # sets a default inline position + + if ( ! isset($Inline['position'])) + { + $Inline['position'] = $markerPosition; + } + + # the text that comes before the inline + $unmarkedText = substr($text, 0, $Inline['position']); + + # compile the unmarked text + $markup .= $this->unmarkedText($unmarkedText); + + # compile the inline + $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); + + # remove the examined text + $text = substr($text, $Inline['position'] + $Inline['extent']); + + continue 2; + } + + # the marker does not belong to an inline + + $unmarkedText = substr($text, 0, $markerPosition + 1); + + $markup .= $this->unmarkedText($unmarkedText); + + $text = substr($text, $markerPosition + 1); + } + + $markup .= $this->unmarkedText($text); + + return $markup; + } + + # + # ~ + # + + protected function inlineCode($Excerpt) + { + $marker = $Excerpt['text'][0]; + + if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]), + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ); + } + } + + protected function inlineEmailTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + if ( ! isset($matches[2])) + { + $url = 'mailto:' . $url; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $matches[1], + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + protected function inlineEmphasis($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + $marker = $Excerpt['text'][0]; + + if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'strong'; + } + elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'em'; + } + else + { + return; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => $emphasis, + 'handler' => 'line', + 'text' => $matches[1], + ), + ); + } + + protected function inlineEscapeSequence($Excerpt) + { + if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) + { + return array( + 'markup' => $Excerpt['text'][1], + 'extent' => 2, + ); + } + } + + protected function inlineImage($Excerpt) + { + if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') + { + return; + } + + $Excerpt['text']= substr($Excerpt['text'], 1); + + $Link = $this->inlineLink($Excerpt); + + if ($Link === null) + { + return; + } + + $Inline = array( + 'extent' => $Link['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $Link['element']['attributes']['href'], + 'alt' => $Link['element']['text'], + ), + ), + ); + + $Inline['element']['attributes'] += $Link['element']['attributes']; + + unset($Inline['element']['attributes']['href']); + + return $Inline; + } + + protected function inlineLink($Excerpt) + { + $Element = array( + 'name' => 'a', + 'handler' => 'line', + 'text' => null, + 'attributes' => array( + 'href' => null, + 'title' => null, + ), + ); + + $extent = 0; + + $remainder = $Excerpt['text']; + + if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches)) + { + $Element['text'] = $matches[1]; + + $extent += strlen($matches[0]); + + $remainder = substr($remainder, $extent); + } + else + { + return; + } + + if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches)) + { + $Element['attributes']['href'] = $matches[1]; + + if (isset($matches[2])) + { + $Element['attributes']['title'] = substr($matches[2], 1, - 1); + } + + $extent += strlen($matches[0]); + } + else + { + if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) + { + $definition = strlen($matches[1]) ? $matches[1] : $Element['text']; + $definition = strtolower($definition); + + $extent += strlen($matches[0]); + } + else + { + $definition = strtolower($Element['text']); + } + + if ( ! isset($this->DefinitionData['Reference'][$definition])) + { + return; + } + + $Definition = $this->DefinitionData['Reference'][$definition]; + + $Element['attributes']['href'] = $Definition['url']; + $Element['attributes']['title'] = $Definition['title']; + } + + $Element['attributes']['href'] = str_replace(array('&', '<'), array('&', '<'), $Element['attributes']['href']); + + return array( + 'extent' => $extent, + 'element' => $Element, + ); + } + + protected function inlineMarkup($Excerpt) + { + if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false) + { + return; + } + + if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + } + + protected function inlineSpecialCharacter($Excerpt) + { + if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) + { + return array( + 'markup' => '&', + 'extent' => 1, + ); + } + + $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); + + if (isset($SpecialCharacter[$Excerpt['text'][0]])) + { + return array( + 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';', + 'extent' => 1, + ); + } + } + + protected function inlineStrikethrough($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) + { + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'del', + 'text' => $matches[1], + 'handler' => 'line', + ), + ); + } + } + + protected function inlineUrl($Excerpt) + { + if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') + { + return; + } + + if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) + { + $Inline = array( + 'extent' => strlen($matches[0][0]), + 'position' => $matches[0][1], + 'element' => array( + 'name' => 'a', + 'text' => $matches[0][0], + 'attributes' => array( + 'href' => $matches[0][0], + ), + ), + ); + + return $Inline; + } + } + + protected function inlineUrlTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) + { + $url = str_replace(array('&', '<'), array('&', '<'), $matches[1]); + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + # ~ + + protected function unmarkedText($text) + { + if ($this->breaksEnabled) + { + $text = preg_replace('/[ ]*\n/', "
\n", $text); + } + else + { + $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "
\n", $text); + $text = str_replace(" \n", "\n", $text); + } + + return $text; + } + + # + # Handlers + # + + protected function element(array $Element) + { + $markup = '<'.$Element['name']; + + if (isset($Element['attributes'])) + { + foreach ($Element['attributes'] as $name => $value) + { + if ($value === null) + { + continue; + } + + $markup .= ' '.$name.'="'.$value.'"'; + } + } + + if (isset($Element['text'])) + { + $markup .= '>'; + + if (isset($Element['handler'])) + { + $markup .= $this->{$Element['handler']}($Element['text']); + } + else + { + $markup .= $Element['text']; + } + + $markup .= ''; + } + else + { + $markup .= ' />'; + } + + return $markup; + } + + protected function elements(array $Elements) + { + $markup = ''; + + foreach ($Elements as $Element) + { + $markup .= "\n" . $this->element($Element); + } + + $markup .= "\n"; + + return $markup; + } + + # ~ + + protected function li($lines) + { + $markup = $this->lines($lines); + + $trimmedMarkup = trim($markup); + + if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

') + { + $markup = $trimmedMarkup; + $markup = substr($markup, 3); + + $position = strpos($markup, "

"); + + $markup = substr_replace($markup, '', $position, 4); + } + + return $markup; + } + + # + # Deprecated Methods + # + + function parse($text) + { + $markup = $this->text($text); + + return $markup; + } + + # + # Static Methods + # + + static function instance($name = 'default') + { + if (isset(self::$instances[$name])) + { + return self::$instances[$name]; + } + + $instance = new static(); + + self::$instances[$name] = $instance; + + return $instance; + } + + private static $instances = array(); + + # + # Fields + # + + protected $DefinitionData; + + # + # Read-Only + + protected $specialCharacters = array( + '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', + ); + + protected $StrongRegex = array( + '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', + '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', + ); + + protected $EmRegex = array( + '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', + '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', + ); + + protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; + + protected $voidElements = array( + 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', + ); + + protected $textLevelElements = array( + 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', + 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', + 'i', 'rp', 'del', 'code', 'strike', 'marquee', + 'q', 'rt', 'ins', 'font', 'strong', + 's', 'tt', 'sub', 'mark', + 'u', 'xm', 'sup', 'nobr', + 'var', 'ruby', + 'wbr', 'span', + 'time', + ); +} diff --git a/README.md b/README.md index 3419624..7c495a6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Style-Guide-Boilerplate v3.1.0 +Style-Guide-Boilerplate v3.2.0 ============================== [![Join the chat at https://gitter.im/bjankord/Style-Guide-Boilerplate](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bjankord/Style-Guide-Boilerplate?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -47,11 +47,11 @@ Save the file as `pattern-name.html` into the `markup/patterns` directory inside You should now be able to see the new patterns at `yoursite.com/style-guide/` ### Create personalized documentation -To create personalized documentation for your markup examples, create a new .html file and name it whatever your markup snippet is named. +You can use markdown or html to create personalized documentation for your examples. Create a new .md or .html file and name it whatever your markup snippet file is named. -Save the file as `markup-name.html` into the `doc/base` or `doc/patterns` directory inside of your `style-guide` directory. +Save the file as `markup-name.md` or `markup-name.html` into the `doc/base` or `doc/patterns` directory inside of your `style-guide` directory. -For example, if you want to create doc for `markup/patterns/breadcrumbs.html`, create a file called `breadcrumbs.html` and save it into `doc/patterns`. +For example, if you want to create doc for `markup/patterns/breadcrumbs.html`, create a file called `breadcrumbs.md` or `breadcrumbs.html` and save it into `doc/patterns`. You should now be able to see the new doc at `yoursite.com/style-guide/` diff --git a/css/github-markdown.css b/css/github-markdown.css new file mode 100644 index 0000000..199240b --- /dev/null +++ b/css/github-markdown.css @@ -0,0 +1 @@ +.markdown-body{-webkit-text-size-adjust:100%;text-size-adjust:100%;color:#333;overflow:hidden;font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;word-wrap:break-word;}.markdown-body a{background-color:transparent;}.markdown-body a:active,.markdown-body a:hover{outline:0;}.markdown-body strong{font-weight:bold;}.markdown-body h1{font-size:2em;margin:0.67em 0;}.markdown-body img{border:0;}.markdown-body hr{box-sizing:content-box;height:0;}.markdown-body pre{overflow:auto;}.markdown-body code,.markdown-body kbd,.markdown-body pre{font-family:monospace,monospace;font-size:1em;}.markdown-body input{color:inherit;font:inherit;margin:0;}.markdown-body html input[disabled]{cursor:default;}.markdown-body input{line-height:normal;}.markdown-body input[type="checkbox"]{box-sizing:border-box;padding:0;}.markdown-body table{border-collapse:collapse;border-spacing:0;}.markdown-body td,.markdown-body th{padding:0;}.markdown-body *{box-sizing:border-box;}.markdown-body input{font:13px/1.4 Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol";}.markdown-body a{color:#4078c0;text-decoration:none;}.markdown-body a:hover,.markdown-body a:active{text-decoration:underline;}.markdown-body hr{height:0;margin:15px 0;overflow:hidden;background:transparent;border:0;border-bottom:1px solid #ddd;}.markdown-body hr:before{display:table;content:"";}.markdown-body hr:after{display:table;clear:both;content:"";}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:15px;margin-bottom:15px;line-height:1.1;}.markdown-body h1{font-size:30px;}.markdown-body h2{font-size:21px;}.markdown-body h3{font-size:16px;}.markdown-body h4{font-size:14px;}.markdown-body h5{font-size:12px;}.markdown-body h6{font-size:11px;}.markdown-body blockquote{margin:0;}.markdown-body ul,.markdown-body ol{padding:0;margin-top:0;margin-bottom:0;}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman;}.markdown-body ul ul ol,.markdown-body ul ol ol,.markdown-body ol ul ol,.markdown-body ol ol ol{list-style-type:lower-alpha;}.markdown-body dd{margin-left:0;}.markdown-body code{font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;}.markdown-body pre{margin-top:0;margin-bottom:0;font:12px Consolas,"Liberation Mono",Menlo,Courier,monospace;}.markdown-body .select::-ms-expand{opacity:0;}.markdown-body .octicon-link:before{content:'\f05c';}.markdown-body>*:first-child{margin-top:0!important;}.markdown-body>*:last-child{margin-bottom:0!important;}.markdown-body a:not([href]){color:inherit;text-decoration:none;}.markdown-body .anchor{position:absolute;top:0;left:0;display:block;padding-right:6px;padding-left:30px;margin-left:-30px;}.markdown-body .anchor:focus{outline:none;}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{position:relative;margin-top:1em;margin-bottom:16px;font-family:"HelveticaNeue-Medium", "Helvetica Neue Medium", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:500;line-height:1.4;}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{display:none;color:#000;vertical-align:middle;}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{padding-left:8px;margin-left:-30px;text-decoration:none;}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{display:inline-block;}.markdown-body h1{padding-bottom:0.3em;font-size:1.75em;line-height:1.2;border-bottom:1px solid #eee;}.markdown-body h1 .anchor{line-height:1;}.markdown-body h2{padding-bottom:0.3em;font-size:1.5em;line-height:1.225;border-bottom:1px solid #eee;}.markdown-body h2 .anchor{line-height:1;}.markdown-body h3{font-size:1.25em;line-height:1.43;}.markdown-body h3 .anchor{line-height:1.2;}.markdown-body h4{font-size:1em;}.markdown-body h4 .anchor{line-height:1.2;}.markdown-body h5{font-size:.75em;}.markdown-body h5 .anchor{line-height:1.1;}.markdown-body h6{font-size:.75em;color:#777;}.markdown-body h6 .anchor{line-height:1.1;}.markdown-body p,.markdown-body blockquote,.markdown-body ul,.markdown-body ol,.markdown-body dl,.markdown-body table,.markdown-body pre{margin-top:0;margin-bottom:16px;}.markdown-body hr{height:4px;padding:0;margin:16px 0;background-color:#e7e7e7;border:0 none;}.markdown-body ul,.markdown-body ol{padding-left:2em;}.markdown-body ul ul,.markdown-body ul ol,.markdown-body ol ol,.markdown-body ol ul{margin-top:0;margin-bottom:0;}.markdown-body li>p{margin-top:16px;}.markdown-body dl{padding:0;}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold;}.markdown-body dl dd{padding:0 16px;margin-bottom:16px;}.markdown-body blockquote{padding:0 15px;color:#777;border-left:4px solid #ddd;}.markdown-body blockquote>:first-child{margin-top:0;}.markdown-body blockquote>:last-child{margin-bottom:0;}.markdown-body table{display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all;}.markdown-body table th{font-weight:bold;}.markdown-body table th,.markdown-body table td{padding:6px 13px;border:1px solid #ddd;}.markdown-body table tr{background-color:#fff;border-top:1px solid #ccc;}.markdown-body table tr:nth-child(2n){background-color:#f8f8f8;}.markdown-body img{max-width:100%;box-sizing:border-box;}.markdown-body code{padding:0;padding-top:0.2em;padding-bottom:0.2em;margin:0;font-size:85%;background-color:rgba(0,0,0,0.04);border-radius:3px;}.markdown-body code:before,.markdown-body code:after{letter-spacing:-0.2em;content:"\00a0";}.markdown-body pre>code{padding:0;margin:0;font-size:100%;word-break:normal;white-space:pre;background:transparent;border:0;}.markdown-body .highlight{margin-bottom:16px;}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#1B1B18;border-radius:3px;color:#fff;}.markdown-body .highlight pre{margin-bottom:0;word-break:normal;}.markdown-body pre{word-wrap:normal;}.markdown-body pre code{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0;}.markdown-body pre code:before,.markdown-body pre code:after{content:normal;}.markdown-body kbd{display:inline-block;padding:3px 5px;font-size:11px;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:solid 1px #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb;}.markdown-body .pl-c{color:#969896;}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:#0086b3;}.markdown-body .pl-e,.markdown-body .pl-en{color:#795da3;}.markdown-body .pl-s .pl-s1,.markdown-body .pl-smi{color:#333;}.markdown-body .pl-ent{color:#63a35c;}.markdown-body .pl-k{color:#a71d5d;}.markdown-body .pl-pds,.markdown-body .pl-s,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sra,.markdown-body .pl-sr .pl-sre{color:#183691;}.markdown-body .pl-v{color:#ed6a43;}.markdown-body .pl-id{color:#b52a1d;}.markdown-body .pl-ii{background-color:#b52a1d;color:#f8f8f8;}.markdown-body .pl-sr .pl-cce{color:#63a35c;font-weight:bold;}.markdown-body .pl-ml{color:#693a17;}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{color:#1d3e81;font-weight:bold;}.markdown-body .pl-mq{color:#008080;}.markdown-body .pl-mi{color:#333;font-style:italic;}.markdown-body .pl-mb{color:#333;font-weight:bold;}.markdown-body .pl-md{background-color:#ffecec;color:#bd2c00;}.markdown-body .pl-mi1{background-color:#eaffea;color:#55a532;}.markdown-body .pl-mdr{color:#795da3;font-weight:bold;}.markdown-body .pl-mo{color:#1d3e81;}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px Consolas,"Liberation Mono",Menlo,Courier,monospace;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:solid 1px #ccc;border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb;}.markdown-body .task-list-item{list-style-type:none;}.markdown-body .task-list-item+.task-list-item{margin-top:3px;}.markdown-body .task-list-item input{margin:0 0.35em 0.25em -1.6em;vertical-align:middle;}.markdown-body :checked+.radio-label{z-index:1;position:relative;border-color:#4078c0;} diff --git a/css/sg-style.css b/css/sg-style.css index 261bb2c..5a66459 100644 --- a/css/sg-style.css +++ b/css/sg-style.css @@ -288,14 +288,14 @@ body { .sg-h2 { border-bottom: 1px solid #ddd; - font-size: 1.5em; + font-size: 1.75em; margin-bottom: .75em; padding-bottom: .2em; text-transform: capitalize; } .sg-h3 { - font-size: 1.2em; + font-size: 1.5em; } .sg-about p { diff --git a/doc/base/address.html b/doc/base/address.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/address.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/address.md b/doc/base/address.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/address.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/blockquote.html b/doc/base/blockquote.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/blockquote.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/blockquote.md b/doc/base/blockquote.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/blockquote.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/details.html b/doc/base/details.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/details.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/details.md b/doc/base/details.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/details.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/figure.html b/doc/base/figure.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/figure.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/figure.md b/doc/base/figure.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/figure.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-buttons.html b/doc/base/form-buttons.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-buttons.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-buttons.md b/doc/base/form-buttons.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-buttons.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-fields-default.html b/doc/base/form-fields-default.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-fields-default.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-fields-default.md b/doc/base/form-fields-default.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-fields-default.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-fields-disabled.html b/doc/base/form-fields-disabled.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-fields-disabled.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-fields-disabled.md b/doc/base/form-fields-disabled.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-fields-disabled.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-fields-readonly.html b/doc/base/form-fields-readonly.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-fields-readonly.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-fields-readonly.md b/doc/base/form-fields-readonly.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-fields-readonly.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-fields-with-datalist.html b/doc/base/form-fields-with-datalist.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-fields-with-datalist.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-fields-with-datalist.md b/doc/base/form-fields-with-datalist.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-fields-with-datalist.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/form-fieldset.html b/doc/base/form-fieldset.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/form-fieldset.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/form-fieldset.md b/doc/base/form-fieldset.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/form-fieldset.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/headings-1.html b/doc/base/headings-1.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/headings-1.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/headings-1.md b/doc/base/headings-1.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/headings-1.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/headings-2.html b/doc/base/headings-2.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/headings-2.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/headings-2.md b/doc/base/headings-2.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/headings-2.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/headings-3.html b/doc/base/headings-3.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/headings-3.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/headings-3.md b/doc/base/headings-3.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/headings-3.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/hr.html b/doc/base/hr.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/hr.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/hr.md b/doc/base/hr.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/hr.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/list-definition.html b/doc/base/list-definition.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/list-definition.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/list-definition.md b/doc/base/list-definition.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/list-definition.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/list-ordered.html b/doc/base/list-ordered.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/list-ordered.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/list-ordered.md b/doc/base/list-ordered.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/list-ordered.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/list-unordered.html b/doc/base/list-unordered.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/list-unordered.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/list-unordered.md b/doc/base/list-unordered.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/list-unordered.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/media.html b/doc/base/media.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/media.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/media.md b/doc/base/media.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/media.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/meter-and-progress.html b/doc/base/meter-and-progress.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/meter-and-progress.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/meter-and-progress.md b/doc/base/meter-and-progress.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/meter-and-progress.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/preformated-text.html b/doc/base/preformated-text.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/preformated-text.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/preformated-text.md b/doc/base/preformated-text.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/preformated-text.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/sample-content-block.html b/doc/base/sample-content-block.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/sample-content-block.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/sample-content-block.md b/doc/base/sample-content-block.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/sample-content-block.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/tabular-data.html b/doc/base/tabular-data.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/tabular-data.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/tabular-data.md b/doc/base/tabular-data.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/tabular-data.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/text-elements.html b/doc/base/text-elements.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/text-elements.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/text-elements.md b/doc/base/text-elements.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/text-elements.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/base/time.html b/doc/base/time.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/base/time.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/base/time.md b/doc/base/time.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/base/time.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/patterns/alerts.html b/doc/patterns/alerts.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/patterns/alerts.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/patterns/alerts.md b/doc/patterns/alerts.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/patterns/alerts.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/doc/patterns/breadcrumbs.html b/doc/patterns/breadcrumbs.html deleted file mode 100644 index 0a4ccb9..0000000 --- a/doc/patterns/breadcrumbs.html +++ /dev/null @@ -1 +0,0 @@ -

Add your personalized documentation here.

\ No newline at end of file diff --git a/doc/patterns/breadcrumbs.md b/doc/patterns/breadcrumbs.md new file mode 100644 index 0000000..fc758d2 --- /dev/null +++ b/doc/patterns/breadcrumbs.md @@ -0,0 +1 @@ +Add your personalized documentation here. diff --git a/functions.php b/functions.php index 0e975d8..6e3b19e 100644 --- a/functions.php +++ b/functions.php @@ -68,12 +68,29 @@ function renderFile($path) { } function renderFileDoc($path) { - $documentation = 'doc'.strstr($path, "/"); - if (file_exists($documentation)) { + $doc = 'doc'.strstr($path, "/"); + $doc = str_replace(".html",".md",$doc); + + require_once 'Parsedown.php'; + $Parsedown = new Parsedown(); + + + // Check if markdown doc exists + if (is_readable($doc)) { echo '
'; - echo '

Usage

'; - include($documentation); + echo '
'; + echo $Parsedown->text(file_get_contents($doc)); + echo '
'; echo '
'; + } else { + $doc = 'doc'.strstr($path, "/"); + + // Check if html doc exists + if (file_exists($doc)) { + echo '
'; + include($doc); + echo '
'; + } } } diff --git a/index.php b/index.php index 6282252..e151b6d 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,9 @@ + + +