Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Remove font tags from some namespaces on save #255

Merged
merged 4 commits into from
Sep 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
url = https://github.com/splitbrain/dokuwiki-plugin-swiftmail
[submodule "lib/plugins/tag"]
path = lib/plugins/tag
url = https://github.com/dokufreaks/plugin-tag
url = https://github.com/superdav42/plugin-tag
[submodule "lib/plugins/captcha"]
path = lib/plugins/captcha
url = https://github.com/splitbrain/dokuwiki-plugin-captcha
Expand Down
10 changes: 10 additions & 0 deletions lib/plugins/codecleanup/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
code cleanup Plugin for DokuWiki

Removes font tags from pages that shouldn't use them

If you install this plugin manually, make sure it is installed in
lib/plugins/codecleanup/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.
50 changes: 50 additions & 0 deletions lib/plugins/codecleanup/action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Clean up code
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author David Stone <david@nnucomputerwhiz.com>
*/

/**
* Class action_plugin_codecleanup
*/
class action_plugin_codecleanup extends DokuWiki_Action_Plugin {

/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @return void
*/
public function register(Doku_Event_Handler $controller) {

$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'cleanupCode');
}

/**
* [Custom event handler which performs action]
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function cleanupCode(Doku_Event &$event, $param) {

$event->data[0][1] = preg_replace('/<\/?font[^>]*>/', '', $event->data[0][1]);

}

/**
*
* @param string $haystack
* @param string $needle
* @return string
*/
private function startsWith($haystack, $needle) {
return (substr($haystack, 0, strlen($needle)) === $needle);
}


}
7 changes: 7 additions & 0 deletions lib/plugins/codecleanup/plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base codecleanup
author David Stone
email david@nnucomputerwhiz.com
date 2015-09-21
name Code Cleanup Plugin
desc Remove font tags and other junk that can occur on copy and paste
url http://www.distantshores.org
2 changes: 1 addition & 1 deletion lib/plugins/tag