Edgewall Software

Opened 7 years ago

Last modified 7 years ago

#12638 closed defect

format_to_html generates invalid HTML for definition list — at Version 1

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

Description (last modified by Jun Omae)

Discussed in th:#12056, I found that while the HTML generated by format_to_html seems to be 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>

Change History (1)

comment:1 by Jun Omae, 7 years ago

Component: generalwiki system
Description: modified (diff)
Note: See TracTickets for help on using tickets.