CODE plugin: Initial trim($data) inappropriate for COBOL, and other indented snippets
- Status
- Pending
- Subject
- CODE plugin: Initial trim($data) inappropriate for COBOL, and other indented snippets
- Version
- 2.x
- Category
- Patch
- Feature
- Wiki Plugin (extends basic syntax)
- Resolution status
- New
- Submitted by
- btiffin
- Lastmod by
- btiffin
- Rating
- Description
Yeah, we're building a COBOL advocacy TikiWiki site. The CODE plugin removes leading indentation. FIXED format COBOL uses a 6 character sequence number, column 7 as a special indicator and actual code starting at column 8. The initial $code = trim($data); is inappropriate for COBOL, and perhaps for other snippets that need to be cut'n'pasted with indentation intact.
I'd almost just go ahead and commit the change, but I'm not experienced enough with the technical details of PHP, and worry that the solution I'm using locally is not an unacceptable performance hit or that using the > v4.1 charlist feature of the trimming functions breaks legacy Tiki installations. I doubt it, but I thought I'd start here and get expert opinions.
Copy to clipboardfunction wikiplugin_code($data, $params) { if ( is_array($params) ) { extract($params, EXTR_SKIP); } $code = trim($data); $parse_wiki = ( isset($wiki) && $wiki == 1 ); // Detect if GeSHI (Generic Syntax Highlighter) is available
All that is required is changing trim($data); to rtrim$data, "\n\r\0\x0B"; so that leading spaces and tabs (tabs, they should be removed ... just because ... but that's not playing nice with others) are left intact.We're using GeSHi, but this trim occurs regardless.
Thanks for listening,
Brian- Solution
A simple workaround for now, is to use an initial sequence number
000000 >>SOURCE FORMAT IS FIXED, but it will be better to leave initial spaces in place.
Copy to clipboardfunction wikiplugin_code($data, $params) { if ( is_array($params) ) { extract($params, EXTR_SKIP); } $code = rtrim(ltrim($data, "\n\r\0\x0B")); $parse_wiki = ( isset($wiki) && $wiki == 1 ); // Detect if GeSHI (Generic Syntax Highlighter) is available- Importance
- 3
- Priority
- 15
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 2131
- Created
- Saturday 08 November, 2008 03:31:42 UTC
by Unknown - LastModif
- Saturday 08 November, 2008 03:31:42 UTC