turnermm / codedoc Goto Github PK
View Code? Open in Web Editor NEWDokuwiki plugin for documenting and displaying extended blocks of code
Home Page: https://www.dokuwiki.org/plugin:codedoc
Dokuwiki plugin for documenting and displaying extended blocks of code
Home Page: https://www.dokuwiki.org/plugin:codedoc
As of EOL of PHP 7.4 many hosters disable these older versions of PHP.
This plugin seems still not to be compatible to higher versions.
Error: Call to undefined function create_function()
/var/www/virtual/punk1t/punk-t.de/wiki/lib/plugins/codedoc/syntax/specials.php(67)
#0 /var/www/virtual/punk1t/punk-t.de/wiki/inc/parser/renderer.php(117): syntax_plugin_codedoc_specials->render('xhtml', Object(renderer_plugin_xbr), Array)
#1 /var/www/virtual/punk1t/punk-t.de/wiki/inc/parserutils.php(682): Doku_Renderer->plugin('codedoc_special...', Array, 5, '~~codedoc:Ein K...')
#2 /var/www/virtual/punk1t/punk-t.de/wiki/inc/parserutils.php(149): p_render('xhtml', Array, NULL)
#3 /var/www/virtual/punk1t/punk-t.de/wiki/inc/parserutils.php(89): p_cached_output('/var/www/virtua...', 'xhtml', 'playground:star...')
#4 /var/www/virtual/punk1t/punk-t.de/wiki/inc/Ui/PageView.php(68): p_wiki_xhtml('playground:star...', 0, true, '')
#5 /var/www/virtual/punk1t/punk-t.de/wiki/inc/Action/Show.php(37): dokuwiki\Ui\PageView->show()
#6 /var/www/virtual/punk1t/punk-t.de/wiki/inc/template.php(100): dokuwiki\Action\Show->tplContent()
#7 [internal function]: tpl_content_core('show')
#8 /var/www/virtual/punk1t/punk-t.de/wiki/inc/Extension/Event.php(133): call_user_func_array('tpl_content_cor...', Array)
#9 /var/www/virtual/punk1t/punk-t.de/wiki/inc/Extension/Event.php(199): dokuwiki\Extension\Event->trigger('tpl_content_cor...', true)
#10 /var/www/virtual/punk1t/punk-t.de/wiki/inc/template.php(85): dokuwiki\Extension\Event::createAndTrigger('TPL_ACT_RENDER', 'show', 'tpl_content_cor...')
#11 /var/www/virtual/punk1t/punk-t.de/wiki/lib/tpl/dokuwiki/main.php(59): tpl_content()
#12 /var/www/virtual/punk1t/punk-t.de/wiki/inc/actions.php(27): include('/var/www/virtua...')
#13 /var/www/virtual/punk1t/punk-t.de/wiki/doku.php(126): act_dispatch()
It looks like DokuWiki is missing any sort of copy-to-clipboard button functionality, the only plugin I could find that provides it is very outdated and relies on adobe flash.
Discourse has a nice plugin that leverages https://github.com/zenorocha/clipboard.js/
Is that something that could be added to codedoc as well?
The repository is here https://github.com/Daemonite/discourse-clipboard
<codeblock file>
does not actually offer a file to download as <file>
does. Not sure if this is a bug or just a missing implementation.
I'm often prefering the codedoc plugin over the builtin DW <code>
syntax because <codedoc code>
supports highlighting of specific parts of the sample text. This is very helpful e.g. if you want to highlight a specific part of a command, or a specific piece of text of the output from a command.
However, usage can be a bit tricky because parts of the text can be unexpectedly changed by DW's substitution, which is often not even obvious.
For example, a long command line parameter like --version
is displayed correctly in a <code>
block, but shows up as -version
(with a single dash) in a <codedoc code>
block. You can only avoid this if you explicitly use a codedoc-specific syntax (~~codedoc:clean: ... ~~
) to escape every single of such potential substitutions, and you can easily overlook places like --
being substituted by -
.
Also, if the output text from a command contains an email address enclosed in angle brackets, you individually have to escape each of the angle brackets <
and >
to see the real output of the command.
Even though I find codedoc very useful, I've often stumbled across things like this and it takes quite some time to review the generated web page to see if the DW substitution hasn't unexpectedly changed something.
I've also set up a sample page that tries to explain this in more detail:
https://wiki.burnicki.net/miscellaneous_tips:00_dokuwiki:a_codedoc_plugin_test_page
So unless I'm missing something that already does this, it would be a great feature (IMO) to be able to disable DW substitution in specific code blocks, using syntax like
<codedoc code:raw>
</codedoc>
or similar. I have to admit that I'm not very familiar with the way DW and the plugins work in detail, if it comes to syntax parsing. So I can't tell if it's easily possible to implement this, but it would be great if all substitutions except the codedoc-specific things like
~~codedoc:<em>~~ ... </em>~~
could be disabled.
For some reason highlighted code generated from codedoc
tags looks different than highlighted code generated from DokuWiki's core code
tags. E.g. the following example causes different results also the source code is the same:
<codedoc code:C>
void main () {
printf ("Hello World!");
exit 0;
}
</codedoc>
<code C>
void main () {
printf ("Hello World!");
exit 0;
}
</code>
This is strange as the codedoc plugin just calls p_xhtml_cached_geshi()
. I noticed that the "
around the Hello World!
strings are different. It seems to be an encoding problem but I could not find the source of the problem yet.
Pages using codedoc fail to load and an error is generated in the logs:
2022-08-09 17:15:34Error: Call to undefined function create_function() /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/lib/plugins/codedoc/syntax/specials.php(67)
#0 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/parser/renderer.php(117): syntax_plugin_codedoc_specials->render()
#1 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/parserutils.php(682): Doku_Renderer->plugin()
#2 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/parserutils.php(149): p_render()
#3 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/parserutils.php(89): p_cached_output()
#4 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/Ui/PageView.php(68): p_wiki_xhtml()
#5 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/Action/Show.php(37): dokuwiki\Ui\PageView->show()
#6 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/template.php(100): dokuwiki\Action\Show->tplContent()
#7 [internal function]: tpl_content_core()
#8 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/Extension/Event.php(133): call_user_func_array()
#9 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/Extension/Event.php(199): dokuwiki\Extension\Event->trigger()
#10 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/template.php(85): dokuwiki\Extension\Event::createAndTrigger()
#11 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/lib/tpl/dokuwiki/main.php(59): tpl_content()
#12 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/inc/actions.php(27): include('...')
#13 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/doku.php(126): act_dispatch()
#14 /home/username/local_html/dokuwiki-2022-7-31/dokuwiki/index.php(76): require('...')
#15 {main}
This is being run locally in Linux Mint using php8.0 -S localhost:8008 index.php
.
When I run php7.4 -S localhost:8008 index.php
there are no problems, so it seems maybe an issue related to PHP8.0?
<codedoc code:sql>
does not recognize sql comments (which are prefixed by two dashes, --
)
When I wrote below code with codedoc, then it seen in oneline.
# include "sched.h" # include "../smpboot.h"Upper text show like in codedoc block:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.