Added internal documentation links
This commit is contained in:
parent
60b50919b4
commit
5791fccea8
@ -367,3 +367,5 @@ If you have a global mime map entry for `.less` files set for the server, you wi
|
|||||||
## Support
|
## Support
|
||||||
|
|
||||||
If you need help using Daux.io, or have found a bug, please create an issue on the <a href="https://github.com/justinwalsh/daux.io/issues" target="_blank">GitHub repo</a>.
|
If you need help using Daux.io, or have found a bug, please create an issue on the <a href="https://github.com/justinwalsh/daux.io/issues" target="_blank">GitHub repo</a>.
|
||||||
|
|
||||||
|
[Code Highlighting examples](!Examples/Code_Highlighting)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
Highlight.js highlights syntax in code examples on blogs, forums and in fact on any web pages. It's very easy to use because it works automatically: finds blocks of code, detects a language, highlights it. [Learn more.](http://softwaremaniacs.org/soft/highlight/en/)
|
Highlight.js highlights syntax in code examples on blogs, forums and in fact on any web pages. It's very easy to use because it works automatically: finds blocks of code, detects a language, highlights it. [Learn more.](http://softwaremaniacs.org/soft/highlight/en/)
|
||||||
|
|
||||||
|
You can even use [Github Flavored Markdown](!Examples/GitHub_Flavored_Markdown)
|
||||||
|
|
||||||
|
|
||||||
**Python**
|
**Python**
|
||||||
|
|
||||||
@requires_authorization
|
@requires_authorization
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Confluence;
|
<?php namespace Todaymade\Daux\Format\Base\CommonMark;
|
||||||
|
|
||||||
use League\CommonMark\DocParser;
|
use League\CommonMark\DocParser;
|
||||||
use League\CommonMark\Environment;
|
use League\CommonMark\Environment;
|
||||||
@ -16,11 +16,19 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
|||||||
$environment = Environment::createCommonMarkEnvironment();
|
$environment = Environment::createCommonMarkEnvironment();
|
||||||
$environment->mergeConfig($config);
|
$environment->mergeConfig($config);
|
||||||
|
|
||||||
//Add code renderer
|
$this->extendEnvironment($environment);
|
||||||
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
|
|
||||||
$environment->addBlockRenderer('IndentedCode', new IndentedCodeRenderer());
|
|
||||||
|
|
||||||
$this->docParser = new DocParser($environment);
|
$this->docParser = new DocParser($environment);
|
||||||
$this->htmlRenderer = new HtmlRenderer($environment);
|
$this->htmlRenderer = new HtmlRenderer($environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getLinkRenderer(Environment $environment)
|
||||||
|
{
|
||||||
|
return new LinkRenderer($environment->getConfig('daux'));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function extendEnvironment(Environment $environment)
|
||||||
|
{
|
||||||
|
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
|
||||||
|
}
|
||||||
}
|
}
|
63
libs/Format/Base/CommonMark/LinkRenderer.php
Normal file
63
libs/Format/Base/CommonMark/LinkRenderer.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php namespace Todaymade\Daux\Format\Base\CommonMark;
|
||||||
|
|
||||||
|
use League\CommonMark\HtmlElement;
|
||||||
|
use League\CommonMark\HtmlRendererInterface;
|
||||||
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
|
use League\CommonMark\Inline\Element\Link;
|
||||||
|
use Todaymade\Daux\Config;
|
||||||
|
use Todaymade\Daux\DauxHelper;
|
||||||
|
use Todaymade\Daux\Exception;
|
||||||
|
use Todaymade\Daux\Tree\Entry;
|
||||||
|
|
||||||
|
class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
protected $daux;
|
||||||
|
|
||||||
|
public function __construct($daux)
|
||||||
|
{
|
||||||
|
$this->daux = $daux;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $url
|
||||||
|
* @return Entry
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected function resolveInternalFile($url) {
|
||||||
|
|
||||||
|
$file = DauxHelper::getFile($this->daux['tree'], $url);
|
||||||
|
if ($file) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = DauxHelper::getFile($this->daux['tree'], $url . '.html');
|
||||||
|
if ($file) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("Could not locate file '$url'");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Link $inline
|
||||||
|
* @param HtmlRendererInterface $htmlRenderer
|
||||||
|
*
|
||||||
|
* @return HtmlElement
|
||||||
|
*/
|
||||||
|
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
|
||||||
|
{
|
||||||
|
$element = parent::render($inline, $htmlRenderer);
|
||||||
|
|
||||||
|
$url = $inline->getUrl();
|
||||||
|
if (!empty($url) && $url[0] == '!') {
|
||||||
|
$file = $this->resolveInternalFile(ltrim($url, "!"));
|
||||||
|
|
||||||
|
$element->setAttribute('href', $this->daux['base_url'] . $file->getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Base;
|
<?php namespace Todaymade\Daux\Format\Base;
|
||||||
|
|
||||||
use League\CommonMark\CommonMarkConverter;
|
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
|
use Todaymade\Daux\Format\Base\CommonMark\CommonMarkConverter;
|
||||||
use Todaymade\Daux\Tree\Content;
|
use Todaymade\Daux\Tree\Content;
|
||||||
|
|
||||||
abstract class MarkdownPage extends SimplePage
|
abstract class MarkdownPage extends SimplePage
|
||||||
@ -26,6 +26,11 @@ abstract class MarkdownPage extends SimplePage
|
|||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFile()
|
||||||
|
{
|
||||||
|
return $this->file;
|
||||||
|
}
|
||||||
|
|
||||||
public function setParams(Config $params)
|
public function setParams(Config $params)
|
||||||
{
|
{
|
||||||
$this->params = $params;
|
$this->params = $params;
|
||||||
@ -33,7 +38,7 @@ abstract class MarkdownPage extends SimplePage
|
|||||||
|
|
||||||
protected function getMarkdownConverter()
|
protected function getMarkdownConverter()
|
||||||
{
|
{
|
||||||
return new CommonMarkConverter();
|
return new CommonMarkConverter(['daux' => $this->params]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function convertPage($content)
|
protected function convertPage($content)
|
||||||
|
20
libs/Format/Confluence/CommonMark/CommonMarkConverter.php
Normal file
20
libs/Format/Confluence/CommonMark/CommonMarkConverter.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php namespace Todaymade\Daux\Format\Confluence\CommonMark;
|
||||||
|
|
||||||
|
use League\CommonMark\Environment;
|
||||||
|
|
||||||
|
class CommonMarkConverter extends \Todaymade\Daux\Format\Base\CommonMark\CommonMarkConverter
|
||||||
|
{
|
||||||
|
protected function getLinkRenderer(Environment $environment)
|
||||||
|
{
|
||||||
|
return new LinkRenderer($environment->getConfig('daux'));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function extendEnvironment(Environment $environment)
|
||||||
|
{
|
||||||
|
parent::extendEnvironment($environment);
|
||||||
|
|
||||||
|
//Add code renderer
|
||||||
|
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
|
||||||
|
$environment->addBlockRenderer('IndentedCode', new IndentedCodeRenderer());
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Confluence;
|
<?php namespace Todaymade\Daux\Format\Confluence\CommonMark;
|
||||||
|
|
||||||
use League\CommonMark\Block\Element\AbstractBlock;
|
use League\CommonMark\Block\Element\AbstractBlock;
|
||||||
use League\CommonMark\Block\Element\FencedCode;
|
use League\CommonMark\Block\Element\FencedCode;
|
@ -1,4 +1,4 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Confluence;
|
<?php namespace Todaymade\Daux\Format\Confluence\CommonMark;
|
||||||
|
|
||||||
use League\CommonMark\Block\Element\AbstractBlock;
|
use League\CommonMark\Block\Element\AbstractBlock;
|
||||||
use League\CommonMark\Block\Element\IndentedCode;
|
use League\CommonMark\Block\Element\IndentedCode;
|
43
libs/Format/Confluence/CommonMark/LinkRenderer.php
Normal file
43
libs/Format/Confluence/CommonMark/LinkRenderer.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php namespace Todaymade\Daux\Format\Confluence\CommonMark;
|
||||||
|
|
||||||
|
use League\CommonMark\HtmlElement;
|
||||||
|
use League\CommonMark\HtmlRendererInterface;
|
||||||
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
|
use League\CommonMark\Inline\Element\Link;
|
||||||
|
|
||||||
|
class LinkRenderer extends \Todaymade\Daux\Format\Base\CommonMark\LinkRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Link $inline
|
||||||
|
* @param HtmlRendererInterface $htmlRenderer
|
||||||
|
*
|
||||||
|
* @return HtmlElement
|
||||||
|
*/
|
||||||
|
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
|
||||||
|
{
|
||||||
|
// Default handling
|
||||||
|
$element = parent::render($inline, $htmlRenderer);
|
||||||
|
$url = $inline->getUrl();
|
||||||
|
if (empty($url) || $url[0] != '!') {
|
||||||
|
return $element;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Internal links
|
||||||
|
$file = $this->resolveInternalFile(ltrim($url, "!"));
|
||||||
|
|
||||||
|
$link_props = [
|
||||||
|
'ri:content-title' => trim($this->daux['confluence']['prefix']) . " " . $file->getTitle(),
|
||||||
|
'ri:space-key' => $this->daux['confluence']['space_id']
|
||||||
|
];
|
||||||
|
|
||||||
|
$page = strval(new HtmlElement('ri:page', $link_props, '', true));
|
||||||
|
$children = $htmlRenderer->renderInlines($inline->getChildren());
|
||||||
|
if (strpos($children, "<") !== false) {
|
||||||
|
$children = '<ac:link-body>' . $children . '</ac:link-body>';
|
||||||
|
} else {
|
||||||
|
$children = '<ac:plain-text-link-body><![CDATA[' . $children . ']]></ac:plain-text-link-body>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HtmlElement('ac:link', [], $page . $children);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use Todaymade\Daux\DauxHelper;
|
use Todaymade\Daux\DauxHelper;
|
||||||
|
use Todaymade\Daux\Format\Confluence\CommonMark\CommonMarkConverter;
|
||||||
|
|
||||||
class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
||||||
{
|
{
|
||||||
@ -9,7 +10,7 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
|||||||
|
|
||||||
protected function getMarkdownConverter()
|
protected function getMarkdownConverter()
|
||||||
{
|
{
|
||||||
return new CommonMarkConverter();
|
return new CommonMarkConverter(['daux' => $this->params]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generatePage()
|
protected function generatePage()
|
||||||
@ -80,7 +81,6 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
|
|||||||
|
|
||||||
private function createImageTag($filename, $attributes)
|
private function createImageTag($filename, $attributes)
|
||||||
{
|
{
|
||||||
|
|
||||||
$img = "<ac:image";
|
$img = "<ac:image";
|
||||||
|
|
||||||
foreach ($attributes as $name => $value) {
|
foreach ($attributes as $name => $value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user