Last modified: 2014-09-23 19:44:50 UTC
As described at http://sourceforge.net/project/shownotes.php?release_id=618638, there is a "table" type for headers, designed to fix FF's copy+paste badness The proposed solution is to add a new keyword: enclose="table" to join "div" "pre" and others. In the main class, it would have hooks to: $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); Not to add to the discussion going on around Bug 19416 https://bugzilla.wikimedia.org/show_bug.cgi?id=19416 , but this will be yet another set of presentation code to deal with there. As it stands now, this copy+paste bug is a real ugliness in wikibooks for me. If some other way of ensuring that unformatted code is selectable is available, I'd hear it.
Created attachment 6620 [details] patch for 20760, adding enclose="table" functionality
[Attached bugfix] Examined cases: wrap='table' with line numbers has the correct copy and paste behaviour in Firefox. Without line numbers, it looks very similar to other preformatted code. Problems with bugfix: it's hackish. It relies on the particular format coming back to protect the embedded newlines from Parser::doBlockLevels. The 'righter' solution would be to only replace newlines with <br /> inside the <pre> tags. Alternate Solutions: Wrapping $out in <nowiki> tags doesn't seem to help protect things from Parser::doBlockLevels. Example Markup: <syntaxhighlight lang='python'> def hello(): ''' print hello and exit''' print "hello" </syntaxhighlight> --- <syntaxhighlight line="GESHI_FANCY_LINE_NUMBERS" lang='python' enclose='div'> def hello(): ''' print hello and exit''' print "hello" </syntaxhighlight> --- <syntaxhighlight line="GESHI_FANCY_LINE_NUMBERS" lang='python' enclose='none'> def hello(): ''' print hello and exit''' print "hello" </syntaxhighlight> --- TABLEBASED <syntaxhighlight line="GESHI_FANCY_LINE_NUMBERS" lang='python' enclose='table'> def hello(): ''' print hello and exit''' print "hello" </syntaxhighlight> --- TABLE,NOLINE <syntaxhighlight lang='python' enclose='table'> def hello(): ''' print hello and exit''' print "hello" </syntaxhighlight>
Created attachment 6621 [details] simple diff based format
Created attachment 6622 [details] corrected order of diff
Created attachment 6626 [details] diff from current source to better implementation of fix cf: http://stackoverflow.com/questions/1517102/replace-newlines-with-br-tags-but-only-inside-pre-tags/ and protect.php for discussion and example usage
Created attachment 6627 [details] example usage for _protect_newline; assertion test
Created attachment 6628 [details] svn-diff version of 2nd (improved) patch
Created attachment 6633 [details] patch with improved naming conventions line_numbers (with underscores) retained for consistency with GeSHI methods.
*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*
Unassigning default assignments. http://article.gmane.org/gmane.science.linguistics.wikipedia.technical/54734
Gregg, thank you for the patch, and my apologies that no one has responded yet. I'm adding a keyword to this bug, "need-review," to signal that the patch awaits review. Could you comment and clarify which of the patches you want reviewed? attachment 6633 [details], right? then we can mark the others as obsolete.
Gregg: Thanks again for the patch. Are you interested in using developer access to directly suggest it into our Git source control system? https://www.mediawiki.org/wiki/Developer_access https://www.mediawiki.org/wiki/Git/Workflow#How_to_submit_a_patch