DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:codeprettify

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:codeprettify [2015-09-07 14:19] s.saharaplugin:codeprettify [2023-12-04 19:42] (current) – [Installation] 2607:f8d8:2:1:dda3:ffb:6ae1:ebca
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: syntax highlighting of source code snippets in wiki page using google-code-prettify (javascript module with CSS files)+description: Syntax highlighting of source code snippets in wiki page using google-code-prettify (javascript module with CSS files)
 author     : s.sahara  author     : s.sahara 
 email      : sahara.satoshi@gmail.com  email      : sahara.satoshi@gmail.com 
 type       : syntax type       : syntax
-lastupdate : 2015-01-24 +lastupdate : 2019-09-29 
-compatible : Hrun+compatible : 2015-08-10, 2016-06-26, 2017-02-19, 2018-04-22a
 depends    :  depends    : 
 conflicts  conflicts 
Line 23: Line 23:
 ===== Installation ===== ===== Installation =====
  
-Install the plugin through the [[plugin:extension|Extension Manager]] or [[plugin:plugin|Plugin Manager]] using the download URL above, which points to latest version of the plugin. Refer to [[:plugin_installation_instructions|plugin installation instructions]].+Require PHP 7.0.x or later! 
 + 
 +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:plugin_installation_instructions|plugin installation instructions]]. 
 + 
 +Note: After updated to 2015-09-12 release, you can remove older "google-code-prettify" subfolder in this plugin directory.  
 + 
 +<Code:txt> 
 +Test of text 
 +</Code> 
 + 
 +<Code:css> 
 +<style> hello </style> 
 +</Code>
  
 ===== Feature ===== ===== Feature =====
Line 31: Line 43:
   * You can configure Code Prettifier plugin to override DokuWiki built-in syntax ''%%<code>%%'' for code blocks.   * You can configure Code Prettifier plugin to override DokuWiki built-in syntax ''%%<code>%%'' for code blocks.
   * you may use skin (css file) for code block.   * you may use skin (css file) for code block.
- 
- 
 ===== Examples/Usage ===== ===== Examples/Usage =====
  
   * Enclose code snippets using ''%%<Code>%%'' and ''%%</Code>%%'' tag to show it //pretty-printed// in wiki page.   * Enclose code snippets using ''%%<Code>%%'' and ''%%</Code>%%'' tag to show it //pretty-printed// in wiki page.
   * Prettify module makes a best effort to guess the language but works best with C-like and HTML-like languages.   * Prettify module makes a best effort to guess the language but works best with C-like and HTML-like languages.
-  * To specify language hint for Prettify, you can use \\ 1) ''%%<Code:ext>%%'' (file extension, you must put it just after "Code:" keyword) or \\ 2) ''%%<Code lang-ext>%%'' option.+  * To specify language hint for Prettify, you can use 
 +    - ''%%<Code:ext>%%'' (file extension, you must put it just after "Code:" keyword) 
 +    - ''%%<Code lang-ext>%%'' option
   * For example, use ''%%<Code:css>%%'' or ''%%<Code lang-css>%%'' to specify that the code is Cascading Style Sheets (CSS).   * For example, use ''%%<Code:css>%%'' or ''%%<Code lang-css>%%'' to specify that the code is Cascading Style Sheets (CSS).
-  * use ''linenums'' option to turn on line numbering. To specify start line number, you can add a colon and the number to the end of the option, eg. ''linenums:12''+  * use ''linenums'' or ''nolinenums'' option to turn on/off line numbering. You can add a colon and the number to the end of the option, eg. ''linenums:12'' to specify start line number
-  * If you want to add title for code block, you can specify it after ''|'' that will be shown just above the code box.+  * If you want to add title for code block, you can specify it after ''%%|%%'' that will be shown just above the code box.
  
  
Line 62: Line 74:
 ^ Config key        ^ Description  ^ ^ Config key        ^ Description  ^
 |''override''       |override DokuWiki built-in syntax %%<code>%% for [[:wiki:syntax#Code Blocks]].| |''override''       |override DokuWiki built-in syntax %%<code>%% for [[:wiki:syntax#Code Blocks]].|
-|''url_loader''     |url of prettify loader (default blank)\\ :!: will be obsoleted in next release| +|''linenums''       |enable line numbering implicitly. | 
-|''url_prettify_handlers''  |Base URL for prettify.js and optional language handler scripts\\ ex: https://cdn.rawgit.com/google/code-prettify/master/src/ \\ (default blank)\\ :!: will be available in next release +|''url_loader''     |url of prettify loader (default blank)\\ :!: obsoleted since 2015-09-12 release| 
-|''url_prettify_skins''     |Base URL for color theme for code-prettify (css)\\ ex: https://cdn.rawgit.com/google/code-prettify/master/styles/ \\ (default blank)\\ :!: will be available in next release  |+|''url_prettify_handlers''  |Base URL for prettify.js and optional language handler scripts\\ ex: %%https://cdn.rawgit.com/google/code-prettify/master/src/%% \\ (default blank)\\ :!: available in 2015-09-12 release 
 +|''url_prettify_skins''     |Base URL for color theme for code-prettify (css)\\ ex: %%https://cdn.rawgit.com/google/code-prettify/master/styles/%% \\ (default blank)\\ :!: available in 2015-09-12 release  |
 |''lang_handlers''  |additional langage handler (comma separated)| |''lang_handlers''  |additional langage handler (comma separated)|
 |''skin''           |color theme/skin for code-prettify (CSS filename in code-prettify/styles/)| |''skin''           |color theme/skin for code-prettify (CSS filename in code-prettify/styles/)|
Line 78: Line 91:
   * sunburst.css   * sunburst.css
  
-Color themes for Prettify will be found at http://jmblog.github.io/color-themes-for-google-code-prettify/+Other color themes for Prettify will be found at http://jmblog.github.io/color-themes-for-google-code-prettify/
  
  
Line 84: Line 97:
  
 === Change Log from github repository === === Change Log from github repository ===
 +
 {{rss>https://github.com/ssahara/dw-plugin-codeprettify/commits/master.atom date 5}} {{rss>https://github.com/ssahara/dw-plugin-codeprettify/commits/master.atom date 5}}
  
 === ToDo/Wish List === === ToDo/Wish List ===
 +
   * Collapse/Expand Code Feature   * Collapse/Expand Code Feature
   * follow recent updates of [[https://github.com/google/code-prettify|Japascript code prettifier]] project   * follow recent updates of [[https://github.com/google/code-prettify|Japascript code prettifier]] project
  
 ===== FAQ ===== ===== FAQ =====
 +
 +==== Non-highlight code block ====
 +
 +use ''%%<Code:none>%%'' or ''%%<Code lang-none>%%'' to prevent highlight code. Maybe useful to show error log output or console output.
 +  <Code:none>
 +  This is not any kind of code.
 +  </Code>
 +
 +==== Geshi options in DowkuWiki ====
 +
 +DowkuWiki suppports some [[:syntax_highlighting|additional Geshi options]] for syntax highlighting 
 +since its 2018-04-22 release (Greebo). The extra Geshi options are to be specified inside ''['' and '']''.  
 +The code prettifier plugin should also recognize them, and following example will work fine for both DokuWiki original syntax and code prettifier plugin (except ''%%<code>%%'' and ''<**__C__**ode>'' markup tag respectively). 
 +
 +  <Code C [enable_line_numbers=1, start_line_numbers_at=42]>
 +  void main () {
 +      printf ("Hello World!");
 +      exit 0;
 +  }
 +  </Code>
 +
  
 ===== Known Bugs and Issues ===== ===== Known Bugs and Issues =====
-see also: https://github.com/ssahara/dw-plugin-codeprettify/issues+ 
 +See also: https://github.com/ssahara/dw-plugin-codeprettify/issues
  
 ===== Discussion ===== ===== Discussion =====
 +
 +Using current dokuwiki theme and prettifyer with <Code linenums> does print a linenumber only on every fifth.
 +line.
 +
 +To solve just add
 +''.prettyprint ol.linenums > li { list-style-type: decimal; }''
 +to lib/plugins/codeprettify/all.css
  
  
  
  
plugin/codeprettify.1441628343.txt.gz · Last modified: 2015-09-07 14:19 by s.sahara

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki