[Bug 12730] New: Suggestion: Codeblock element

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12730

           Summary: Suggestion: Codeblock element
           Product: HTML WG
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HTML5 spec (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: amoore@uat.edu
         QAContact: public-html-bugzilla@w3.org
                CC: mike@w3.org, public-html-wg-issue-tracking@w3.org,
                    public-html@w3.org


Suggestion in section 4.5 Grouping Content

Problem: I'm building webpages that give lessons in C#. They are pages with
multiple blocks of code between paragraphs explaining the code. The code blocks
are enclosed by PRE and CODE tags

Example:

<pre class="c-sharp"><code>
public class MyException : ApplicationException
{
    private ExceptionLevel exceptionLevel;
    private LogLevel logLevel;
    private Exception myException;
    private string exceptionMessage;

    public string ExceptionMessage
    {
        get { return this.exceptionMessage; }
        set { this.exceptionMessage = value; }
    }

    public MyException()
    { }

    public MyException(ExceptionLevel exceptionLevel,
                        LogLevel logLevel,
                        Exception exception,
                        string exceptionMessage)
    {
        this.exceptionLevel = exceptionLevel;
        this.logLevel = logLevel;
        this.myException = exception;
        this.exceptionMessage = exceptionMessage;
    }
}
</code></pre>

Because these pages are for students learning the programming language, syntax
highlighting is necessary for the pages to be readable. There is far too much
content to go through and add all the color formatting with span tags, so I
have decided to use a syntax highlighting script. Thus far, the only syntax
highlighting script I have found requires the PRE tag to have a class of the
programming language that is enclosed by the CODE tag.  This is backwards - the
Code tag should describe the programming language enclosed within, not the PRE
tag. Plus, there is code smell in the source of my html document. Well over
half of the code tags are enclosed in pre tags simply because I need to display
a block of pre-formatted code. This is a very common need, probably more common
than displaying a single line of code.

Solution:
<codeblock>

Codeblock would be an element used to enclose a block of pre-formatted code
without having to nest a code element within a pre element.

Old: <pre class="c-sharp"><code>
New: <codeblock class="c-sharp">

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Monday, 23 May 2011 23:39:20 UTC