Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12638 closed defect (fixed)

format_to_html generates invalid HTML for definition list

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.2.1
Component: wiki system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fix invalid xhtml being generated for definition list after paragraph.

API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

Discussed in th:#12056, I found that the HTML generated by format_to_html is incorrect:

>>> from trac.test import EnvironmentStub, MockRequest
>>> from trac.wiki.formatter import format_to_html
>>> from trac.web.chrome import web_context
>>> env = EnvironmentStub()
>>> req = MockRequest(env)
>>> context = web_context(req)
>>> markup = """[main] Tagging system for Trac.
... 
... Associating resources with tags is easy, faceted content classification.
... 
... Available components are marked according to their relevance as follows:
...  `[main]`:: provide core with a generic tagging engine as well as support
...  for common realms 'ticket' (TracTickets) and 'wiki' (TracWiki).
...  `[opt]`:: add more features to improve user experience and maintenance
...  `[extra]`:: enable advanced features for specific use cases
... Make sure to understand their purpose before deactivating `[main]` or
... activating `[extra]` components.
... """
>>> format_to_html(env, context, markup)
<Markup u'<p>\n[main] Tagging system for Trac.\n</p>\n<p>\nAssociating resources with tags is easy, faceted content classification.\n</p>\n<p>\nAvailable components are marked according to their relevance as follows:\n<dl class="wiki"><dt><code>[main]</code></dt><dd>provide core with a generic tagging engine as well as support\nfor common realms \'ticket\' (<a class="missing wiki" href="/trac.cgi/wiki/TracTickets" rel="nofollow">TracTickets?</a>) and \'wiki\' (<a class="missing wiki" href="/trac.cgi/wiki/TracWiki" rel="nofollow">TracWiki?</a>).\n</dd><dt><code>[opt]</code></dt><dd>add more features to improve user experience and maintenance\n</dd><dt><code>[extra]</code></dt><dd>enable advanced features for specific use cases\n</dd></dl>\nMake sure to understand their purpose before deactivating <code>[main]</code> or\nactivating <code>[extra]</code> components.\n</p>\n'>

Here's the output formatted by selectively decoding newlines to emphasize the issue:

<p>\n[main] Tagging system for Trac.\n</p>\n<p>Associating resources with tags is easy, faceted content classification.\n</p>\n
<p>
Available components are marked according to their relevance as follows:
<dl class="wiki"><dt><code>[main]</code></dt><dd>provide core with a generic tagging engine as well as support\nfor common realms \'ticket\' (<a class="missing wiki" href="/trac.cgi/wiki/TracTickets" rel="nofollow">TracTickets?</a>) and \'wiki\' (<a class="missing wiki" href="/trac.cgi/wiki/TracWiki" rel="nofollow">TracWiki?</a>).\n</dd><dt><code>[opt]</code></dt><dd>add more features to improve user experience and maintenance\n</dd><dt><code>[extra]</code></dt><dd>enable advanced features for specific use cases\n</dd>
</dl>
Make sure to understand their purpose before deactivating <code>[main]</code> or activating <code>[extra]</code> components.
</p>

The dl is wrapped in p.

Chrome and Firefox seem to handle the scenario okay by removing the p that wraps the dl:

<p>
Available components are marked according to their relevance as follows:
</p><dl class="wiki"><dt><tt>[main]</tt></dt><dd>provide core with a generic tagging engine as well as support
for common realms 'ticket' (<a class="wiki" href="/proj-1.0/wiki/TracTickets">TracTickets</a>) and 'wiki' (<a class="wiki" href="/proj-1.0/wiki/TracWiki">TracWiki</a>).
</dd><dt><tt>[opt]</tt></dt><dd>add more features to improve user experience and maintenance
</dd><dt><tt>[extra]</tt></dt><dd>enable advanced features for specific use cases
</dd></dl>
Make sure to understand their purpose before deactivating <tt>[main]</tt> or
activating <tt>[extra]</tt> components.
<p></p>

Attachments (0)

Change History (7)

comment:1 by Jun Omae, 8 years ago

Component: generalwiki system
Description: modified (diff)

comment:2 by Jun Omae, 8 years ago

Similar issue occurs when definition list is at last line.

>>> print(format_to_html(env, context, "A paragraph.\n def:: word\n"))
<p>
A paragraph.
<dl class="wiki"><dt>def</dt><dd>word
</p>
</dd></dl>

Invalid xml would be generated. </p> is between <dd> and </dd>.

comment:3 by Jun Omae, 8 years ago

Proposed changes in [27ba89ddc/jomae.git] (jomae.git@t12638).

comment:4 by Christian Boos, 8 years ago

Changes look good to me.

comment:5 by Jun Omae, 8 years ago

Milestone: next-stable-1.2.x1.2.1
Owner: set to Jun Omae
Release Notes: modified (diff)
Status: newassigned

Thanks for the reviewing. Committed in [15305] and merged in [15306].

comment:6 by Jun Omae, 8 years ago

Resolution: fixed
Status: assignedclosed

comment:7 by Ryan J Ollos, 8 years ago

Description: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.