Difference: TWikiRenderDotPm (1 vs. 11)

Revision 112018-07-16 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

StaticMethod *chompUtf8Fragment ($str) -> $str

String truncation may happen in the middle of a UTF-8 byte sequence. This function gets rid of the truncated fragment.

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel,$theParams) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
  • $hasExplicitLinkLabel - boolean: true in case of explicit link label
  • $theParams - the URL parameters specified by ?name1=value1;name2=valu2;... excluding the leading ?. This is added as per Item7505. This parameter's natural position is before $theAnchor. But to minimize code changes, it's introduced as the laster one

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

Added:
>
>

ObjectMethod renderFORM (%params,$topic,$web) -> $tml

Returns TML of a TWiki Form, based on variable.

 

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

Added:
>
>

ObjectMethod renderEDITFORM (%params,$topic,$web) -> $tml

Returns TML of a TWiki Form, based on variable.

 

ObjectMethod *renderEDITFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a EDITFORMFIELD Error: Required form field name is missing tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data
  • entityencode - entity encode the resulting plain text (for title parameter)

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after: * newlines are replaced with value of $attrs->{newline} if defined * processing through breakName if $attrs->{break} is defined * escaping of $vars if $attrs->{protectdollar} is defined * | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 102014-10-05 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

StaticMethod *chompUtf8Fragment ($str) -> $str

String truncation may happen in the middle of a UTF-8 byte sequence. This function gets rid of the truncated fragment.

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

Changed:
<
<

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

>
>

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel,$theParams) -> $html

  Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
  • $hasExplicitLinkLabel - boolean: true in case of explicit link label
Added:
>
>
  • $theParams - the URL parameters specified by ?name1=value1;name2=valu2;... excluding the leading ?. This is added as per Item7505. This parameter's natural position is before $theAnchor. But to minimize code changes, it's introduced as the laster one
  Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *renderEDITFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a EDITFORMFIELD Error: Required form field name is missing tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data
  • entityencode - entity encode the resulting plain text (for title parameter)

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after:
Changed:
<
<
  • newlines are replaced with <br> or the value of $attrs->{newline}
>
>
  • newlines are replaced with value of $attrs->{newline} if defined
 
  • processing through breakName if $attrs->{break} is defined
  • escaping of $vars if $attrs->{protectdollar} is defined
  • | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 92013-10-14 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

Added:
>
>

StaticMethod *chompUtf8Fragment ($str) -> $str

String truncation may happen in the middle of a UTF-8 byte sequence. This function gets rid of the truncated fragment.

 

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
  • $hasExplicitLinkLabel - boolean: true in case of explicit link label

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

Added:
>
>

ObjectMethod *renderEDITFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a EDITFORMFIELD Error: Required form field name is missing tag.

 

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data
  • entityencode - entity encode the resulting plain text (for title parameter)

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after: * newlines are replaced with <br> or the value of $attrs->{newline} * processing through breakName if $attrs->{break} is defined * escaping of $vars if $attrs->{protectdollar} is defined * | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 82013-02-16 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
  • $hasExplicitLinkLabel - boolean: true in case of explicit link label

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data
Added:
>
>
  • entityencode - entity encode the resulting plain text (for title parameter)
 

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after: * newlines are replaced with <br> or the value of $attrs->{newline} * processing through breakName if $attrs->{break} is defined * escaping of $vars if $attrs->{protectdollar} is defined * | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 72010-05-29 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

Changed:
<
<
Generate a link.
>
>
Generate a link.
  Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".
  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
Changed:
<
<
>
>
  Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink
Changed:
<
<
Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form
>
>
Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form
  SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of

Changed:
<
<
topic and change summaries. Adds nop tags to prevent TWiki
>
>
topic and change summaries. Adds nop tags to prevent TWiki
 subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after: * newlines are replaced with <br> or the value of $attrs->{newline} * processing through breakName if $attrs->{break} is defined * escaping of $vars if $attrs->{protectdollar} is defined * | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 62008-12-06 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer

ObjectMethod finish ()

Break circular references.

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name

Added:
>
>

ObjectMethod *makeUniqueAnchorName ($web,$topic,$anchorName,$compatibility) -> $anchorName

  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown

Build a valid HTML anchor name (unique w.r.t. the list stored in %anchornames)

 

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be link
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
  • $hasExplicitLinkLabel - boolean: true in case of explicit link label

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =literal= => true, will call fn for each line in literal blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is =sub fn( $line, \%options ) -> $newLine=. The %options hash passed into this function is passed down to the sub, and the keys =in_literal=, =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *getReferenceRE* ($web,$topic,%options) -> $re * $web, $topic - specify the topic being referred to, or web if $topic is undef. * %options - the following options are available * =interweb= - if true, then fully web-qualified references are required. * =grep= - if true, generate a GNU-grep compatible RE instead of the default Perl RE. * =url= - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text. Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names. The RE returned is designed to be used with =s///= ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_ ---++ StaticMethod *protectFormFieldValue* ($value,$attrs) -> $html Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing. The protected value is determined from the value of the field after: * newlines are replaced with <br> or the value of $attrs->{newline} * processing through breakName if $attrs->{break} is defined * escaping of $vars if $attrs->{protectdollar} is defined * | is replaced with &#124; or the value of $attrs->{bar} if defined

Revision 52008-01-22 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Changed:
<
<
Creates a new renderer with initial state from preference values
>
>
Creates a new renderer
Deleted:
<
<
(NEWTOPICBGCOLOR, NEWTOPICFONTCOLOR NEWTOPICLINKSYMBOL LINKTOOLTIPINFO)
 
Added:
>
>

ObjectMethod finish ()

Break circular references.

 

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

Deleted:
<
<

ObjectMethod *renderFormField ($web,$topic,$meta,$params) -> $text

Render meta-data for a single formfield

 

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

Changed:
<
<
  • $anchorName -
  • $compatibilityMode -
>
>
  • $anchorName - the unprocessed anchor name
  • $compatibilityMode - SMELL: compatibility with what?? Who knows. frown
  Build a valid HTML anchor name

Changed:
<
<

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb) -> $html

>
>

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb,$hasExplicitLinkLabel) -> $html

  Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
Changed:
<
<
  • $theTopic - the topic to be lunk
>
>
  • $theTopic - the topic to be link
 
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)
Added:
>
>
  Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

Deleted:
<
<

ObjectMethod *takeOutProtected (\$text,$re,\%map) -> $text

  • $text - Text to process
  • $re - Regular expression that matches tag expressions to remove
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

used to extract from $text comment type tags like <!DOCTYPE blah>

WARNING: if you want to take out <!-- comments --> you will need to re-write all the takeOuts to use a different placeholder

ObjectMethod *putBackProtected (\$text,\%map,$callback) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutProtected.

 

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks
Added:
>
>
  • literal => true, will call fn for each line in literal blocks
 
  • noautolink > true, will call fn for each line in =noautolink blocks
Changed:
<
<
The spec of \&fn is sub fn( \$line, \%options ) -> $newLine; the %options hash passed into this function is passed down to the sub, and the keys in_pre, in_verbatim and in_noautolink are set boolean TRUE if the line is from one (or more) of those block types.
>
>
The spec of \&fn is sub fn( $line, \%options ) -> $newLine. The %options
Added:
>
>
hash passed into this function is passed down to the sub, and the keys in_literal, in_pre, in_verbatim and in_noautolink are set boolean TRUE if the line is from one (or more) of those block types.
  The return result replaces $line in $newText.

Added:
>
>

StaticMethod getReferenceRE ($web,$topic,%options) -> $re

  • $web, $topic - specify the topic being referred to, or web if $topic is undef.
  • %options - the following options are available
    • interweb - if true, then fully web-qualified references are required.
    • grep - if true, generate a GNU-grep compatible RE instead of the default Perl RE.
    • url - if set, generates an expression that will match a TWiki URL that points to the web/topic, instead of the default which matches topic links in plain text.
Generate a regular expression that can be used to match references to the specified web/topic. Note that the resultant RE will only match fully qualified (i.e. with web specifier) topic names and topic names that are wikiwords in text. Works for spaced-out wikiwords for topic names.

The RE returned is designed to be used with s///

 

StaticMethod *replaceTopicReferences ($text,\%options) -> $text

Callback designed for use with forEachLine, to replace topic references. \%options contains:

  • oldWeb => Web of reference to replace
  • oldTopic => Topic of reference to replace
Deleted:
<
<
  • spacedTopic => RE matching spaced out oldTopic
 
  • newWeb => Web of new reference
  • newTopic => Topic of new reference
  • inWeb => the web which the text we are presently processing resides in
  • fullPaths => optional, if set forces all links to full web.topic form
For a usage example see TWiki::UI::Manage.pm

StaticMethod *replaceWebReferences ($text,\%options) -> $text

Callback designed for use with forEachLine, to replace web references. \%options contains:

  • oldWeb => Web of reference to replace
  • newWeb => Web of new reference
For a usage example see TWiki::UI::Manage.pm

ObjectMethod *replaceWebInternalReferences (\$text,\%meta,$oldWeb,$oldTopic)

Change within-web wikiwords in $$text and $meta to full web.topic syntax.

\%options must include topics => list of topics that must have references to them changed to include the web specifier.

Deleted:
<
<

StaticMethod *renderFormFieldArg ($meta,$args) -> $text

Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data.

  • args string containing name of form field

In addition to the name of a field args can be appended with a commas followed by a string format (\d+)([,\s*]\.\.\.)?). This supports the formatted search function $formfield and is used to shorten the returned string or a hyphenated string.

 

StaticMethod breakName ($text,$args) -> $text

  • $text - text to "break"
  • $args - string of format (\d+)([,\s*]\.\.\.)?)
Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long)

_Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_

Added:
>
>

StaticMethod *protectFormFieldValue ($value,$attrs) -> $html

Given the value of a form field, and a set of attributes that control how to display that value, protect the value from further processing.

The protected value is determined from the value of the field after:

  • newlines are replaced with <br> or the value of $attrs->{newline}
  • processing through breakName if $attrs->{break} is defined
  • escaping of $vars if $attrs->{protectdollar} is defined
  • | is replaced with &#124; or the value of $attrs->{bar} if defined
 

Revision 42007-03-03 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer with initial state from preference values (NEWTOPICBGCOLOR, NEWTOPICFONTCOLOR NEWTOPICLINKSYMBOL LINKTOOLTIPINFO)

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod *renderFormField ($web,$topic,$meta,$params) -> $text

Render meta-data for a single formfield

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName -
  • $compatibilityMode -

Build a valid HTML anchor name

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be lunk
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod *takeOutProtected (\$text,$re,\%map) -> $text

  • $text - Text to process
  • $re - Regular expression that matches tag expressions to remove
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

used to extract from $text comment type tags like <!DOCTYPE blah>

WARNING: if you want to take out <!-- comments --> you will need to re-write all the takeOuts to use a different placeholder

Changed:
<
<

ObjectMethod *putBackProtected (\$text,\%map,$tag,$newtag,$callBack) -> $text

>
>

ObjectMethod *putBackProtected (\$text,\%map,$callback) -> $text

  Return value: $text with blocks added back
  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
Added:
>
>
  • $callback - Reference to function to call on each block being inserted (optional)
  Reverses the actions of takeOutProtected.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is sub fn( \$line, \%options ) -> $newLine; the %options hash passed into this function is passed down to the sub, and the keys =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =spacedTopic= => RE matching spaced out oldTopic * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *renderFormFieldArg* ($meta,$args) -> $text Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data. * =args= string containing name of form field In addition to the name of a field =args= can be appended with a commas followed by a string format (\d+)([,\s*]\.\.\.)?). This supports the formatted search function $formfield and is used to shorten the returned string or a hyphenated string. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_

Revision 32007-02-05 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer with initial state from preference values (NEWTOPICBGCOLOR, NEWTOPICFONTCOLOR NEWTOPICLINKSYMBOL LINKTOOLTIPINFO)

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod *renderFormField ($web,$topic,$meta,$params) -> $text

Render meta-data for a single formfield

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName -
  • $compatibilityMode -

Build a valid HTML anchor name

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb) -> $html

Generate a link.

Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be lunk
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod *takeOutProtected (\$text,$re,\%map) -> $text

  • $text - Text to process
  • $re - Regular expression that matches tag expressions to remove
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

used to extract from $text comment type tags like <!DOCTYPE blah>

WARNING: if you want to take out <!-- comments --> you will need to re-write all the takeOuts to use a different placeholder

ObjectMethod *putBackProtected (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks

Reverses the actions of takeOutProtected.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | | =$date= | the date of the rev (no time) | | =$time= | the time of the rev | | =$min=, =$sec=, etc. | Same date format qualifiers as GMTIME | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is sub fn( \$line, \%options ) -> $newLine; the %options hash passed into this function is passed down to the sub, and the keys =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =spacedTopic= => RE matching spaced out oldTopic * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *renderFormFieldArg* ($meta,$args) -> $text Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data.
Added:
>
>
  • args string containing name of form field

In addition to the name of a field args can be appended with a commas followed by a string format (\d+)([,\s*]\.\.\.)?). This supports the formatted search function $formfield and is used to shorten the returned string or a hyphenated string.

 

StaticMethod breakName ($text,$args) -> $text

  • $text - text to "break"
  • $args - string of format (\d+)([,\s*]\.\.\.)?)
Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long)

_Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_

Revision 22007-01-16 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer with initial state from preference values (NEWTOPICBGCOLOR, NEWTOPICFONTCOLOR NEWTOPICLINKSYMBOL LINKTOOLTIPINFO)

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Added:
>
>
 Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Added:
>
>
 Render moved meta-data

ObjectMethod *renderFormField ($web,$topic,$meta,$params) -> $text

Added:
>
>
 Render meta-data for a single formfield

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName -
  • $compatibilityMode -

Build a valid HTML anchor name

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb) -> $html

Generate a link.

Changed:
<
<
SMELL: why can topic be spaced out? is this to support auto squishing of Spaced Topic Naming? and lowercase Spaced Topic Naming
>
>
Note: Topic names may be spaced out. Spaced out names are converted to WikWords, for example, "spaced topic name" points to "SpacedTopicName".
 
  • $theWeb - the web containing the topic
  • $theTopic - the topic to be lunk
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod *takeOutProtected (\$text,$re,\%map) -> $text

  • $text - Text to process
  • $re - Regular expression that matches tag expressions to remove
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

used to extract from $text comment type tags like <!DOCTYPE blah>

WARNING: if you want to take out <!-- comments --> you will need to re-write all the takeOuts to use a different placeholder

ObjectMethod *putBackProtected (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks

Reverses the actions of takeOutProtected.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number |
Deleted:
<
<
$date the date of the rev (no time)
$time the full date and time of the rev
 
$comment the comment
$username the login of the saving user
$wikiname the wikiname of the saving user
$wikiusername the web.wikiname of the saving user
Added:
>
>
$date the date of the rev (no time)
$time the time of the rev
$min, $sec, etc. Same date format qualifiers as GMTIME
 

ObjectMethod *summariseChanges ($user,$web,$topic,$orev,$nrev,$tml) -> $text

Added:
>
>
 
  • $user - user (null to ignore permissions)
  • $web - web
  • $topic - topic
  • $orev - older rev
  • $nrev - later rev
  • $tml - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example)
Generate a (max 3 line) summary of the differences between the revs.

If there is only one rev, a topic summary will be returned.

If $tml is not set, all HTML will be removed.

In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text.

ObjectMethod forEachLine ($text,\&fn,\%options) -> $newText

Iterate over each line, calling \&fn on each. \%options may contain:

  • pre => true, will call fn for each line in pre blocks
  • verbatim => true, will call fn for each line in verbatim blocks
  • noautolink > true, will call fn for each line in =noautolink blocks
The spec of \&fn is sub fn( \$line, \%options ) -> $newLine; the %options hash passed into this function is passed down to the sub, and the keys in_pre, in_verbatim and in_noautolink are set boolean TRUE if the line is from one (or more) of those block types.

The return result replaces $line in $newText.

StaticMethod *replaceTopicReferences ($text,\%options) -> $text

Added:
>
>
 Callback designed for use with forEachLine, to replace topic references. \%options contains:
  • oldWeb => Web of reference to replace
  • oldTopic => Topic of reference to replace
  • spacedTopic => RE matching spaced out oldTopic
  • newWeb => Web of new reference
  • newTopic => Topic of new reference
  • inWeb => the web which the text we are presently processing resides in
  • fullPaths => optional, if set forces all links to full web.topic form
For a usage example see TWiki::UI::Manage.pm

StaticMethod *replaceWebReferences ($text,\%options) -> $text

Added:
>
>
 Callback designed for use with forEachLine, to replace web references. \%options contains:
  • oldWeb => Web of reference to replace
  • newWeb => Web of new reference
For a usage example see TWiki::UI::Manage.pm

ObjectMethod *replaceWebInternalReferences (\$text,\%meta,$oldWeb,$oldTopic)

Change within-web wikiwords in $$text and $meta to full web.topic syntax.

\%options must include topics => list of topics that must have references to them changed to include the web specifier.

StaticMethod *renderFormFieldArg ($meta,$args) -> $text

Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data.

StaticMethod breakName ($text,$args) -> $text

Added:
>
>
 
  • $text - text to "break"
  • $args - string of format (\d+)([,\s*]\.\.\.)?)
Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long)

_Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_

Revision 12006-02-01 - TWikiContributor

 

Package =TWiki::Render

This module provides most of the actual HTML rendering code in TWiki.

On this page:

ClassMethod new ($session)

Creates a new renderer with initial state from preference values (NEWTOPICBGCOLOR, NEWTOPICFONTCOLOR NEWTOPICLINKSYMBOL LINKTOOLTIPINFO)

ObjectMethod renderParent ($web,$topic,$meta,$params) -> $text

Render parent meta-data

ObjectMethod renderMoved ($web,$topic,$meta,$params) -> $text

Render moved meta-data

ObjectMethod *renderFormField ($web,$topic,$meta,$params) -> $text

Render meta-data for a single formfield

ObjectMethod makeAnchorName ($anchorName,$compatibilityMode) -> $anchorName

  • $anchorName -
  • $compatibilityMode -

Build a valid HTML anchor name

ObjectMethod internalLink ($theWeb,$theTopic,$theLinkText,$theAnchor,$doLink,$doKeepWeb) -> $html

Generate a link.

SMELL: why can topic be spaced out? is this to support auto squishing of Spaced Topic Naming? and lowercase Spaced Topic Naming

  • $theWeb - the web containing the topic
  • $theTopic - the topic to be lunk
  • $theLinkText - text to use for the link
  • $theAnchor - the link anchor, if any
  • $doLinkToMissingPages - boolean: false means suppress link for non-existing pages
  • $doKeepWeb - boolean: true to keep web prefix (for non existing Web.TOPIC)

Called by _handleWikiWord and _handleSquareBracketedLink and by Func::internalLink

Calls _renderWikiWord, which in turn will use Plurals.pm to match fold plurals to equivalency with their singular form

SMELL: why is this available to Func?

ObjectMethod renderFORMFIELD (%params,$topic,$web) -> $html

Returns the fully rendered expansion of a tag.

ObjectMethod *getRenderedVersion ($text,$theWeb,$theTopic) -> $html

The main rendering function.

StaticMethod *verbatimCallBack

Callback for use with putBackBlocks that replaces < and > by their HTML entities &lt; and &gt;

ObjectMethod TML2PlainText ($text,$web,$topic,$opts) -> $plainText

Clean up TWiki text for display as plain text without pushing it through the full rendering pipeline. Intended for generation of topic and change summaries. Adds nop tags to prevent TWiki subsequent rendering; nops get removed at the very end.

Defuses TML.

$opts:

  • showvar - shows %VAR% names if not expanded
  • expandvar - expands %VARS%
  • nohead - strips ---+ headings at the top of the text
  • showmeta - does not filter meta-data

ObjectMethod *protectPlainText ($text) -> $tml

Protect plain text from expansions that would normally be done duing rendering, such as wikiwords. Topic summaries, for example, have to be protected this way.

ObjectMethod *makeTopicSummary ($theText,$theTopic,$theWeb,$theFlags) -> $tml

Makes a plain text summary of the given topic by simply trimming a bit off the top. Truncates to $TMTRUNC chars or, if a number is specified in $theFlags, to that length.

ObjectMethod *takeOutProtected (\$text,$re,\%map) -> $text

  • $text - Text to process
  • $re - Regular expression that matches tag expressions to remove
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

used to extract from $text comment type tags like <!DOCTYPE blah>

WARNING: if you want to take out <!-- comments --> you will need to re-write all the takeOuts to use a different placeholder

ObjectMethod *putBackProtected (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks

Reverses the actions of takeOutProtected.

ObjectMethod takeOutBlocks (\$text,$tag,\%map) -> $text

  • $text - Text to process
  • $tag - XHTML-style tag.
  • \%map - Reference to a hash to contain the removed blocks

Return value: $text with blocks removed

Searches through $text and extracts blocks delimited by a tag, appending each onto the end of the @buffer and replacing with a token string which is not affected by TWiki rendering. The text after these substitutions is returned.

Parameters to the open tag are recorded.

This is different to takeOutProtected, because it requires tags to be on their own line. it also supports a callback for post- processing the data before re-insertion.

ObjectMethod putBackBlocks (\$text,\%map,$tag,$newtag,$callBack) -> $text

Return value: $text with blocks added back

  • \$text - reference to text to process
  • \%map - map placeholders to blocks removed by takeOutBlocks
  • $tag - Tag name processed by takeOutBlocks
  • $newtag - Tag name to use in output, in place of $tag. If undefined, uses $tag.
  • $callback - Reference to function to call on each block being inserted (optional)

Reverses the actions of takeOutBlocks.

Each replaced block is processed by the callback (if there is one) before re-insertion.

Parameters to the outermost cut block are replaced into the open tag, even if that tag is changed. This allows things like <verbatim class=''> to be mapped to <pre class=''>

Cool, eh what? Jolly good show.

And if you set $newtag to '', we replace the taken out block with the valuse itself

  • which i'm using to stop the rendering process, but then at the end put in the html directly (for tag. ---++ ObjectMethod *renderRevisionInfo* ($web,$topic,$meta,$rev,$format) -> $string Obtain and render revision info for a topic. * =$web= - the web of the topic * =$topic= - the topic * =$meta= if specified, get rev info from here. If not specified, or meta contains rev info for a different version than the one requested, will reload the topic * =$rev= - the rev number, defaults to latest rev * =$format= - the render format, defaults to =$rev - $time - $wikiusername= =$format= can contain the following keys for expansion: | =$web= | the web name | | =$topic= | the topic name | | =$rev= | the rev number | | =$date= | the date of the rev (no time) | | =$time= | the full date and time of the rev | | =$comment= | the comment | | =$username= | the login of the saving user | | =$wikiname= | the wikiname of the saving user | | =$wikiusername= | the web.wikiname of the saving user | ---++ ObjectMethod *summariseChanges* ($user,$web,$topic,$orev,$nrev,$tml) -> $text * =$user= - user (null to ignore permissions) * =$web= - web * =$topic= - topic * =$orev= - older rev * =$nrev= - later rev * =$tml= - if true will generate renderable TML (i.e. HTML with NOPs. if false will generate a summary suitable for use in plain text (mail, for example) Generate a (max 3 line) summary of the differences between the revs. If there is only one rev, a topic summary will be returned. If =$tml= is not set, all HTML will be removed. In non-tml, lines are truncated to 70 characters. Differences are shown using + and - to indicate added and removed text. ---++ ObjectMethod *forEachLine* ($text,\&fn,\%options) -> $newText Iterate over each line, calling =\&fn= on each. \%options may contain: * =pre= => true, will call fn for each line in pre blocks * =verbatim= => true, will call fn for each line in verbatim blocks * =noautolink= => true, will call fn for each line in =noautolink= blocks The spec of \&fn is sub fn( \$line, \%options ) -> $newLine; the %options hash passed into this function is passed down to the sub, and the keys =in_pre=, =in_verbatim= and =in_noautolink= are set boolean TRUE if the line is from one (or more) of those block types. The return result replaces $line in $newText. ---++ StaticMethod *replaceTopicReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace topic references. \%options contains: * =oldWeb= => Web of reference to replace * =oldTopic= => Topic of reference to replace * =spacedTopic= => RE matching spaced out oldTopic * =newWeb= => Web of new reference * =newTopic= => Topic of new reference * =inWeb= => the web which the text we are presently processing resides in * =fullPaths= => optional, if set forces all links to full web.topic form For a usage example see TWiki::UI::Manage.pm ---++ StaticMethod *replaceWebReferences* ($text,\%options) -> $text Callback designed for use with forEachLine, to replace web references. \%options contains: * =oldWeb= => Web of reference to replace * =newWeb= => Web of new reference For a usage example see TWiki::UI::Manage.pm ---++ ObjectMethod *replaceWebInternalReferences* (\$text,\%meta,$oldWeb,$oldTopic) Change within-web wikiwords in $$text and $meta to full web.topic syntax. \%options must include topics => list of topics that must have references to them changed to include the web specifier. ---++ StaticMethod *renderFormFieldArg* ($meta,$args) -> $text Parse the arguments to a $formfield specification and extract the relevant formfield from the given meta data. ---++ StaticMethod *breakName* ($text,$args) -> $text * =$text= - text to "break" * =$args= - string of format (\d+)([,\s*]\.\.\.)?) Hyphenates $text every $1 characters, or if $2 is "..." then shortens to $1 characters and appends "..." (making the final string $1+3 characters long) _Moved from Search.pm because it was obviously unhappy there, as it is a rendering function_
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiRenderDotPm.