DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:text

This is an old revision of the document!


text (export / renderer plugin)

Compatible with DokuWiki

Devel only

plugin Exports or Renders a page as plain text

Last updated on
2008-02-28
Provides
Render

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

Similar to plaintext

Tagged with export, search

Needed for bookcreator, odtsupport, searchtext

This plugin allows you to export a page to a plain text format usable as a simplistic document or to be used in further processing.

:!: You will need a recent development version of DokuWiki to make this work!

Download

Usage

To export a single page add the following parameter to the page URL:

<pagename>?do=export_text

To get a copy of rendered text in PHP (i.e. from a button or some other plugin) use:

global $ID;
$ID = $id; //necessary for correct metadata handling 
$text = p_cached_output(wikiFN($id),'text');

Other plugins

The text renderer plugin was originally designed for use with the searchtext plugin, to provide both a basis for searching rendered text, and providing a rendered text snippet for displayed search result.

If you use other syntax plugins, their output may not appear correctly in the exported text unless:

  1. they specifically support the 'text' output format, or
  2. they support standard XHTML output and the text is suitable when stripped of its HTML markup

Discussion

To add a button to your template to access this plugin's output, try adding the following in your template at the point you would like the button to appear.

<?php echo html_button('text',$ID,'t',array('do' => 'export_text'),'get','export this page as text'); ?>

Note:

  • 'text' will appear in the button, change as appropriate.
  • 'export this page as text' will appear as a tooltip when you hover over the button. change as appropriate.

If you are not using a dev version or are on the latest stable use this code instead:

<?php echo html_btn('text',$ID,'t',array('do' => 'export_text'),'get','export this page as text'); ?>

Or if you like pretty icon links rather than buttons:

<a href="<?php echo exportlink($ID, 'text')?>"><img src="<?php echo DOKU_BASE?>lib/images/fileicons/txt.png" alt="Text Export"></a>

MBCS problem

In the textsearch result page, there is some line like :

Warning: cannot yet handle MBCS in html_entity_decode()!
in /www/cyrille/lib/plugins/text/renderer.php on line 315

Is there somethine about utf8 or something like ?

Cyrille Giquello 2009/01/29 16:21

Ok, I've updated php from version 4.4.9 to 5.2.6 and the problem is solved.

Cyrille Giquello 2009/01/29 17:23

Since I don't want to lose searcheable content (when used with the Searchtext Plugin), I'd prefer to put the URL in if it contains additional information:

    function _getLinkTitle($title, $default, & $isImage, $id=NULL) {
        global $conf;
 
        $isImage = false;
        if ( is_null($title) ) {
            if ($conf['useheading'] && $id) {
                $heading = p_get_first_heading($id,true);
                if ($heading) {
                    return $heading;
                }
            }
            return $default;
        } else if ( is_string($title) ) {
		if (!is_null($default) && ($default != $title))
			return $default." ".$title;
		else
			return $title;
        } else if ( is_array($title) ) {
		if (!is_null($default) && ($default != $title['title']))
			return $default." ".$title['title'];
		else
			return $title['title'];
        }
    }

Wilfried Goesgens 2010/02/23 15:45

Setting the right mimetype

in function document_start()

        $metaheader['Content-Type'] = 'text/html; charset=utf-8';

should be replaced by

        $metaheader['Content-Type'] = 'text/plain; charset=utf-8';

Else a browser will render it realy awfull. — Wilfried Goesgens 2010/02/23 15:45

plugin/text.1266937698.txt.gz · Last modified: 2010-02-23 16:08 by 62.153.93.226

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