exclude page parts from indexing using a regex

This commit is contained in:
Andreas Gohr
2024-12-05 09:41:01 +01:00
parent 85b60323a9
commit 10ce0ca939
4 changed files with 9 additions and 0 deletions

View File

@ -53,4 +53,5 @@ $conf['logging'] = 0;
$conf['restrict'] = '';
$conf['skipRegex'] = ':(playground|sandbox)(:|$)';
$conf['matchRegex'] = '';
$conf['ignoreRegex'] = '';
$conf['preferUIlanguage'] = 0;

View File

@ -60,6 +60,7 @@ $meta['logging'] = array('onoff');
$meta['restrict'] = array('string');
$meta['skipRegex'] = array('string');
$meta['matchRegex'] = array('string');
$meta['ignoreRegex'] = array('string');
$meta['preferUIlanguage'] = array('multichoice', '_choices' => array(
\dokuwiki\plugin\aichat\AIChat::LANG_AUTO_ALL,
\dokuwiki\plugin\aichat\AIChat::LANG_UI_ALL,

View File

@ -45,6 +45,7 @@ $lang['logging'] = 'Log all questions and answers. Use the <a href="?do=admin&pa
$lang['restrict'] = 'Restrict access to these users and groups (comma separated). Leave empty to allow all users.';
$lang['skipRegex'] = 'Skip indexing pages matching this regular expression (no delimiters).';
$lang['matchRegex'] = 'Only index pages matching this regular expression (no delimiters).';
$lang['ignoreRegex'] = 'Ignore parts of the page content matching this regular expression (no delimiters).';
$lang['preferUIlanguage'] = 'How to work with multilingual wikis? (Requires the translation plugin)';
$lang['preferUIlanguage_o_0'] = 'Guess language, use all sources';

View File

@ -87,6 +87,12 @@ class renderer_plugin_aichat extends Doku_Renderer_xhtml
{
$this->doc = preg_replace("/(\r?\n){3,}/", "\n\n", $this->doc);
$this->doc = ltrim($this->doc); // remove leading space and empty lines
// remove ignored parts
$regex = $this->getConf('ignoreRegex');
if($regex) {
$this->doc = preg_replace('/' . $regex . '/i', '', $this->doc);
}
}
/** @inheritdoc */