mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
MINOR Enabled markdown code block parsing logic, README for syntax highlighting, loading syntaxhighlighter JS and CSS
This commit is contained in:
parent
77287d0c0d
commit
135415c2e3
46
README.md
46
README.md
@ -11,4 +11,48 @@ Read nested documentation files from the /docs/ folder in modules. To read docum
|
||||
|
||||
It is likely this will be integrated into the core in future versions once it is polished.
|
||||
|
||||
For more documentation on how to use the module please read /docs/Writing-Documentation.md (or via this in /dev/docs/sapphiredocs/Writing-Documentation)
|
||||
For more documentation on how to use the module please read /docs/Writing-Documentation.md (or via this in /dev/docs/sapphiredocs/Writing-Documentation)
|
||||
|
||||
## Syntax Highlighting ##
|
||||
|
||||
The custom Markdown parser can render custom prefixes for code blocks,
|
||||
and render it via a [javascript syntax highlighter](http://alexgorbatchev.com/SyntaxHighlighter).
|
||||
|
||||
In:
|
||||
|
||||
:::php
|
||||
my sourcecode
|
||||
|
||||
Out:
|
||||
|
||||
<pre class="brush: php">
|
||||
my sourcecode
|
||||
</pre>
|
||||
|
||||
To include the syntax highlighter source, add the following to your `DocumentationViewer->init()`:
|
||||
|
||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shCore.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushPHP.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushXML.js');
|
||||
// ... any additional syntaxes you want to support
|
||||
Requirements::combine_files(
|
||||
'syntaxhighlighter.js',
|
||||
array(
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shCore.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushPHP.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushXML.js'
|
||||
)
|
||||
);
|
||||
|
||||
Requirements::javascript('sapphiredocs/javascript/DocumentationViewer.js');
|
||||
|
||||
// css
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shCore.css');
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shCoreDefault.css');
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shThemeRDark.css');
|
||||
|
||||
You can overload the `DocumentationViewer` class and add a custom route through `Director::addRule()`
|
||||
if you prefer not to modify the module file.
|
@ -40,7 +40,7 @@ class DocumentationParser {
|
||||
$md = self::rewrite_relative_links($md, $page, $baselink);
|
||||
$md = self::rewrite_api_links($md, $page);
|
||||
$md = self::rewrite_heading_anchors($md, $page);
|
||||
// $md = self::rewrite_code_blocks($md, $page);
|
||||
$md = self::rewrite_code_blocks($md, $page);
|
||||
|
||||
require_once('../sapphiredocs/thirdparty/markdown/markdown.php');
|
||||
$html = Markdown($md);
|
||||
|
@ -59,8 +59,30 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
if(!$canAccess) return Security::permissionFailure($this);
|
||||
|
||||
// javascript
|
||||
Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shCore.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushPHP.js');
|
||||
Requirements::javascript('sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushXML.js');
|
||||
Requirements::combine_files(
|
||||
'syntaxhighlighter.js',
|
||||
array(
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shCore.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushPHP.js',
|
||||
'sapphiredocs/thirdparty/syntaxhighlighter/scripts/shBrushXML.js'
|
||||
)
|
||||
);
|
||||
|
||||
Requirements::javascript('sapphiredocs/javascript/DocumentationViewer.js');
|
||||
|
||||
// css
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shCore.css');
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shCoreDefault.css');
|
||||
Requirements::css('sapphiredocs/thirdparty/syntaxhighlighter/styles/shThemeRDark.css');
|
||||
|
||||
Requirements::customScript('jQuery(document).ready(function() {SyntaxHighlighter.all();});');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user