Bug: Enter bug title here
Including
BackslashAtEndOfLine here since he identified the bug.
Question
I'm trying to include shell code snippets in verbatim mode
which have lines ending in backslash characters.
Currently TWiki does this in
getRenderedVersion
$text =~ s/\\\n//go; # Join lines ending in "\"
which makes things difficult. I could follow the backslash with
a space to fool the regexp, but this means that anyone attempting
to cut and paste from the page (which is what I want) will end up
with spaces after the backslashes, which causes no end of trouble
for the shell. I tried appending a
<nop> after the backslash,
but getRenderedVersion strips off things like that:
$result =~ s|\n?\n$||os; # clean up clutch
If I insert an html
<br> tag I get extra space between the lines,
which again foils a cut and paste.
I've looked at the code, but can't figure a way around this.
Any suggestions?
Thanks
.
- TWiki version: 20011201
- Web server:
- Server OS:
- Web browser:
- Client OS:
--
DiabJerius - 05 Aug 2002
Answer
Wrap your example in the <verbatim> and </verbatim> tags.
They suppress TWiki's processing of text. E.G.
This line has a \
at the end of it.
It won't let you do inline text, but for cut and paste you don't want inline usage.
Can't believe I suggested this when I had already submitted a ticket that this didn't work 8-)._ rouilj 8/11/02
--
JohnRouillard - 05 Aug 2002
Bizarre. Your example, when viewed, exhibits the problem. When previewed,
it doesn't. I don't quite understand why, as
preview uses
getRenderedVersion.
The code which strips out the backslash in
getRenderedVersion
does so
before performing special processing of the <verbatim> tag, so
<verbatim> isn't quite as pure as it should be.
--
DiabJerius - 05 Aug 2002
I just tried your example on my system, and I don't see the disparity between
previewing and viewing the topic. Does twiki.org run on the alpha release?
--
DiabJerius - 05 Aug 2002
I just took a gander at the version in CVS, and I can now explain the preview/view
disparity.
-
TWiki::getRenderedVersion() calls TWiki::takeOutVerbatim() after joining the lines.
-
preview calls TWiki::takeOutVerbatim() before calling TWiki::getRenderedVersion(), effectively isolating the verbatim text in spite of TWiki::getRenderedVersion().
-
view does not call TWiki::takeOutVerbatim() before calling TWiki::getRenderedVersion(), so the verbatim text is still subject to line joining.
So, either
view should also call
TWiki::takeOutVerbatim() or
TWiki::getRenderedVersion()
should call it before joining the lines.
--
DiabJerius - 05 Aug 2002
This is fix now, see
Codev.VerbatimGobblesBackslashAtEndOfLine
Get the latest
TWikiAlphaRelease, or in
sub getRenderedVersion of
twiki/lib/TWiki.pm move the following lines a few lines down just below the call to
takeOutVerbatim( $text, \@verbatim ) :
$text =~ s/\\\n//go; # Join lines ending in "\"
--
PeterThoeny - 10 Aug 2002
Unfortunately, that fix doesn't work for the
Codev.TWikiRelease01Dec2001 because the
sub takeOutVerbatim isn't in the codebase yet for that release.
An (admittedly hacky) workaround for
Codev.TWikiRelease01Dec2001 users is to put a backslash-space at the end of the verbatim line instead of a backslash. While this is clearly not a perfect solution, it does render to something that
looks right. This should more-or-less work unless the rendering is then copied-and-pasted into some piece of code that subsequently breaks. Watch out for this!
--
FrankHorowitz - 28 Nov 2002
I had a problem with this when putting a directory at the end of a bullet list. e.g.
- item 1
- item 2 with trailing backslash * item 3
- item 4 with trialing backslash and space\
- item 5
What purpose is this for other than to allow joining lines in tables? Could it be limited to just that function?
--
SamHasler - 04 Mar 2004
Test case
BackslashAtEndOfLine
Environment
| TWiki version: |
twiki.org |
| TWiki plugins: |
|
| Server OS: |
|
| Web server: |
|
| Perl version: |
|
| Client OS: |
|
| Web Browser: |
|
--
JohnRouillard - 08 Aug 2002
Follow up
Fix record
This is fixed, in
TWikiAlphaRelease and TWiki.org.
- Removed the verbatim handling in
preview since it is redundant. So view and preview behave now identical
- Backslash inside verbatim is now supported.
--
PeterThoeny - 10 Aug 2002