Wrap Plugin

http://www.dokuwiki.org/plugin:wrap

—- plugin


description: Universal plugin which combines the functionality of many other plugins. Wrap wiki text inside containers (divs or spans) and give them a class (choose from a variety of preset classes), a width and/or a language with its associated text direction. author : Anika Henke email : anika@selfthinker.org type : syntax, action lastupdate : 2010-03-14 compatible : 2009-12-25 depends : conflicts : openlayersmap similar : class, div_span_shorthand, box, note, tip, float, columns, side_note, divalign, divalign2, emphasis, important_paragraf, important_text, styler, layout, typography, highlight, hilited, color, fontcolor, fontfamily, fontsize, fontsize2, clearfloat, comment, commentsrc, htmlcomment, spoiler, hide, tab, outdent, tablewidth, pagebreak, lang, ltr, noprint, pagebreak, wpre tags : style, boxes, highlight, hide, language, icons, annotations, typography, printing, formatting

downloadurl: http://www.dokuwiki.org/_media/plugin:dokuwiki_plugin_wrap_latest.zip bugtracker : http://github.com/selfthinker/dokuwiki_plugin_wrap/issues sourcerepo : http://github.com/selfthinker/dokuwiki_plugin_wrap/ donationurl: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=11071728


This plugin gives you the ability to wrap wiki text inside containers (divs or spans) and give them

  1. a certain class (with loads of useful preset classes)
  2. a width
  3. a language with its associated text direction

It potentially replaces a lot of other plugins and is IMHO the better alternative for many. There is one exception: It currently lacks ODT support. If you need ODT support, you might want to take a look at similar plugins.

It fully replaces: class, divalign, div_span_shorthand, side_note, tip, clearfloat, emphasis, hide, hilited, important_paragraph, inportant_text, noprint, pagebreak, wpre, http://www.dokuwiki.org/plugin:lang, ltr
It partly replaces: box, layout, note, styler, typeography, color, columns, fontcolor, fontfamily, fontsize, http://www.dokuwiki.org/plugin:fontsize2, highlight, tab, tablewidth

Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.

Version 2010-03-14 is only compatible to the latest DokuWiki release 2009-12-25 (“Lemming”). If you like to use the plugin in an older version (but younger than 2006-11-06), you only need to remove the file action.php inside the plugin's main folder. With removing that file you will not have the toolbar picker, but can use the plugin in older DokuWiki versions.

The plugin comes with an example page, which should explain a lot and looks like this in the default template:

Basic Syntax:

<WRAP classes width :language>

"big" content
</WRAP>

An uppercase <WRAP> creates a div and should be used for “big” containers, surrounding paragraphs, lists, tables, etc.

<wrap classes width :language>"small" content</wrap>

A lowercase <wrap> creates a span and should be used for “small” containers, inside paragraphs, lists, tables, etc.

:!: Please note, some things won't work with lowercase <wrap>s: alignments (including alignments generated by changing the text direction) and widths if the according wrap isn't floated as well.

The following classes are currently available:

class namedescription/notes
columns – similar to columns, side_note, styler, tip
column same as left in LTR languages and same as right in RTL languages
left same as column, will let you float your container on the left
right will let the container float right
center will position the container in the horizontal center of the page
alignments – similar to divalign, columns, styler:!: don't work with spans, i.e. lowercase <wrap>s!
leftalign aligns text on the left
rightalign aligns text on the right
centeralign centers the text
justify justifies the text
boxes and notes – similar to box, note, tip
box creates a box around the container (uses colours from style.ini)
info (was information in first version) creates a blue box with an info icon
important creates an orange box with an important icon
alert (:!: was warning in previous versions) creates a red box with a alert icon
tip creates a yellow box with a tip icon
help creates a violet box with a help icon
todo creates a cyan box with an todo icon
download creates a green box with a download icon
round adds rounded corners to any container with a background colour or a border (only works in modern browsers, i.e. no IE)
danger creates a red danger safety note
warning creates an orange warning safety note
caution creates a yellow caution safety note
notice creates a blue notice safety note
safety creates a green safety note
marks – similar to hilited, emphasis, important_paragraf, important_text
hi marks text as highlighted
lo marks text as less significant
em marks text as especially emphasised
typography (not recommended) – similar to typography, styler, color, fontcolor, hilight, fontsize, fontsize2, fontfamily
sansserif, serif, monospace changes the font family
bigger, muchbigger, smaller changes the font size
fgred, fggreen, fgblue, fgcyan, fgviolet, fgyellow, fggrey, fgwhite, fgblack changes the font colour
bgred, bggreen, bgblue, bgcyan, bgviolet, bgyellow, bggrey, bgwhite, bgblack changes the background colour
miscellaneous
clear similar to clearfloat, should preferably be used with divs, i.e. uppercase <WRAP>s
hide hides the text per CSS (the text will still appear in the source code, in non-modern browsers and is searchable)
noprint displays text on the screen, but not in print, similar to http://www.dokuwiki.org/plugin:noprint
onlyprint displays text only in print, but not on the screen
pagebreak forces a new page in printouts (not visible on the screen), similar to http://www.dokuwiki.org/plugin:pagebreak
nopagebreak tries to avoid a pagebreak in printouts (not visible on the screen)
spoiler shows white text on a white background, only to be revealed by highlighting it; similar to http://www.dokuwiki.org/plugin:hide
indent indents the text, could be used instead of http://www.dokuwiki.org/plugin:tab
outdent “outdents” the text, could partly be used instead of http://www.dokuwiki.org/plugin:outdent
prewrap wraps text inside pre-formatted code blocks, similar to http://www.dokuwiki.org/plugin:wpre

All tables inside a column or box will always be 100% wide. This makes positioning and sizing tables possible and partly replaces pagewidth.

Known restrictions

  • The PNG icons for the various notes have an alpha transparency which will look ugly in IE6.
  • Round corners only work in modern browsers (no IE).
  • After an opening <WRAP> there is one empty line needed before the content, or else there won't be any paragraph, which might lead to unexpected results. (Wraps without a visible content don't need any additional empty lines, e.g. clear or hide.)
  • Normal DokuWiki Headlines won't work inside any plugin syntax. As a work-around you can use the following two emulated headlines inside any of the columns or boxes/notes:
    • //**__Big Underlined Headline__**// (They will look a bit different in safety notes.)
    • //**Small Headline**//

You probably need to adjust a few of the classes to your template's needs, especially hi, lo and em if you have a dark or otherwise heavily coloured theme.

The classes are easily adjustable and extensible. Any wishes are welcome.

You can set any valid widths on any uppercase <WRAP> container: %, px, em, ex, pt, pc, cm, mm, in. Just set the width before or after or with the classes, e.g.

<WRAP someclass 50% anotherclass>...

You can change the language and the direction of a container by simply adding a colon followed by the language code, like this:

<wrap :en>This text is explicitly marked as English.</wrap>

The text direction (rtl, right to left or ltr, left to right) will get inserted automatically and is solely dependent on the language. The list of currently supported languages is taken from: http://meta.wikimedia.org/wiki/Template:List_of_language_names_ordered_by_code

If you like to mark a text with a different text direction than the default one, you should use divs, i.e. uppercase <WRAP>s. Otherwise the text alignment won't change as well.

This makes it a better replacement of http://www.dokuwiki.org/plugin:ltr (and http://www.dokuwiki.org/plugin:lang).

If you like to add your own classes and styles to the plugin, you can simply add the styles for your class preceded by “wrap_” to your user styles.

E.g. if you need a <WRAP myclass>, you edit (or create if it doesn't exist) your conf/userstyle.css and add your .wrap_myclass{} with its style definitions to it. (If necessary, edit conf/printstyle.css for the print view and conf/rtlstyle.css for RTL languages as well.)

Since version 2010-03-14 you have the possibility to exclude certain class names from being prefixed with “wrap_”. Just add a comma separated list of class names into the config option “noPrefix” in the configuration manager.

  • ODT support
  • print.css
  • rtl.css
  • toolbar picker
  • and more …

Before reporting any issues (bugs or requests), please first take a look at the FAQ on plugin problems.

You can report any issues either on the Issue Tracker or here in this section.

I've just made the CSS work properly with some custom themes using the git master branch, eg one of my own and typo. the trick is to remove all the .dokuwiki in the different classes with a

perl -pi -e 's/\.dokuwiki//g' *.css

Nicolas Thauvin 2009/09/09 23:22

Templates should use the .dokuwiki class and many already do (as does the typo template). See more on the dokuwiki class. — Anika Henke 2009/09/18 00:37

Wouldn't it be nice to add quotation box, too …
- chris

Yes, I thought about that, too. But as the http://www.dokuwiki.org/plugin:blockquote plugin would be semantically much more correct, I recommend using that instead. — Anika Henke 2009/09/18 00:37

Incredibly useful multipurpose plugin I must say. Thanks for that“ Looking forward to intended ODT compatibility.
Martin 2009/09/14 23:22

<WRAP centeralign>

<WRAP info 60%>

This is some text, text , text , text , text , text , text , text , text , text , text , text , text , text , text , text ,
text , text , text , text , text , text , text , text , text , text , text , text , text , text , text , text , text , text
</WRAP>

[[namespace:something|{{:picture.png|GO}}]]
</WRAP>

The result is the text of the info note is centered. If I use leftalign it aligns the whole box left. How do I get the box text to be left aligned and screen centered? peterennis [at] yahoo [dot] com

To position something you shouldn't use an alignment class, but one of the column classes. In this case it's “center” instead of “centeralign”. (And whenever you use “center” you should also give a width.) If you only want the info box to be centred, you can use <WRAP center info 60%>, and the image could be centred by using the normal DokuWiki syntax. — Anika Henke 2009/10/07 07:47

I sometimes need space above or below a paragraph. Fed up fiddling with HTML, PHP methods so I just use . (dot) Of course, it shows a dot! Is there an easy solution? peterennis [at] yahoo [dot] com

The best way would be to add your own classes. In this case you could use something like ”topspace“ and ”bottomspace“ and add
.dokuwiki .wrap_topspace { margin-top: 1.5em; }
.dokuwiki .wrap_bottomspace { margin-bottom: 1.5em; }

etc. But this depends highly on your template and in which combination you will use those classes. Just fiddle around with the values to change their effect. (And from the semantic point of view you should probably ask yourself why and if you need that space and find a better name if you find a common usage pattern.) — Anika Henke 2009/10/07 08:05

Love this plugin, but the CSS on my page seems to fail CSS3 validity check as a result.

1  	 .dokuwiki div.wrap_round  	 Property -moz-border-radius doesn't exist :  20px
1 	.dokuwiki div.wrap_round 	Property -webkit-border-radius doesn't exist : 20px
1 	.dokuwiki div.wrap_round 	Property -khtml-border-radius doesn't exist : 20px
1 	.dokuwiki span.wrap_round 	Property -moz-border-radius doesn't exist : 2px
1 	.dokuwiki span.wrap_round 	Property -webkit-border-radius doesn't exist : 2px
1 	.dokuwiki span.wrap_round 	Property -khtml-border-radius doesn't exist : 2px 

I'm no CSS expert. Anybody have any suggestions? — michaelrepucci 2009/11/06 22:08

Actually, did some web searches and discovered that since these properties are proprietary, they're not considered part of “valid” CSS, even though they do follow standards. Oh well. When CSS3 is adopted, “border-radius” will replace the proprietary properties and validate. Until then, guess I'll live with it. I'll leave this note here for others who are curious like me. Anyway, nice to have rounded corners :) — michaelrepucci 2009/11/06 22:32

is there any way to skip the generation of the wrap_ “namespace” I'd like to use this for providing a (hidden) geotag on the page like this:

<WRAP hide geo geo-post>  
    <wrap latitude>52.085819</wrap><wrap longitude>5.115348</wrap>
</WRAP>

right now that results in:

<div class="wrap_hide wrap_geo wrap_geo-post">  
    <span class="wrap_latitude">52.085819</span><span class="wrap_longitude">5.115348</span>
</div>

where I would want:

<div class="wrap_hide geo geo-post"> 
    <span class="latitude">52.085819</span><span class="longitude">5.115348</span>
</div>
I wouldn't want to skip the “wrap_” altogether. But it might be a good idea to add a config option for listing all class names which should not be adjusted but taken directly as specified. Then everybody is free to also add other microformat classes and more. I'll implement that as soon as I find the time. — Anika Henke 2010/01/07 01:52
I just implemented this (in the repo). A new release which includes it will follow soon. — Anika Henke 2010/01/31 15:36
                case DOKU_LEXER_ENTER:
                    $wrap = new syntax_plugin_wrap_base();
                    $attr = $wrap->buildAttributes($data);

                    $renderer->doc .= '<div'.$attr.'><p>';
                    break;

The div version of the plugin merges the first two paragraphs into one. The workaround is to leave a line break immediately after the opening

tag. The above code modification will fix this issue. This issue (and fix) is also present in the box plugin.

As described under known restrictions you can circumvent this by writing one more line after <WRAP> (see the very first syntax example). You solution will not fix this problem but will only cause more invalid code in other cases! This whole issue is due to a bug in the DokuWiki core: See 1797. And it annoys me as well. ;-)Anika Henke 2010/01/15 09:43

Is there a way to make the emulated headlines contain “a name=…” anchors, similar to how the regular headlines have such anchors?

No, this is currently not possible and is also not planned. As a work-around you can use the http://www.dokuwiki.org/plugin:bookmark plugin. — Anika Henke 2010/01/31 15:34

I've been using a few lines in conf/entities.conf and a template to easily make invisible tables with visible content. I use this to structure math proofs, so relevant parts of equations stay above each other. Is this something you could incorporate in your great plugin?

<bare> <html><div class="baretable"></html>
</bare> <html></div></html >
div.dokuwiki div.baretable th,
div.dokuwiki div.baretable td { border: 0px; }

Anika, sorry for spamming, just wanted to show my appreciation for the work you've done.

Alex.

I second that!

Tina

http://www.1wiki.de/doku.php/playground:playground

I just fixed that issue in the repo. (But it's not always working in IE6.) The same issue would occur whenever you float something inside a box with a background colour (or a border), e.g. a right-aligned image in a <WRAP box>. If you don't want to install the adjusted plugin, you can also just put a <WRAP clear></WRAP> before the containing closing ”</WRAP>“, like
...
</olmap>
<WRAP clear></WRAP>
</WRAP>

Anika Henke 2010/06/12 22:20

thats works

THANK YOU

I want to use several of the functions as the admin of my wiki (like columns), but I would like my users to only be able to insert the info/important boxes into the pages. Is it possible to hide the editor button, or to hide some of them? I wouldn't mind being able to hide all of the buttons and just telling my users what syntax to type in.

  • wiki/plugins/wrap.txt
  • Last modified: 2012/03/29 09:10
  • by 127.0.0.1