Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#3757 closed defect (fixed)

Changeset 3610 changes ReST formatter behaviour

Reported by: alastair@… Owned by: Christian Boos
Priority: normal Milestone: 0.10
Component: wiki system Version: 0.10b1
Severity: minor Keywords: reStructuredText
Cc: alastair@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I've just upgraded a trac installation to 0.10b1 and discovered that reST links that previously worked were marked as "broken trac links." I trawled through at the code, I traced it down to [3610].

Previously, if a link was not in CamelCase, the reST formatter would make it into a "to be added" link, rather than a warning box. Similarly, if a link was in non-conforming CamelCase such as "AddingMySQLAccounts", it would still link to the right page. With the refactoring patch in [3610], all this behaviour has changed. Instead, these links will now cause a warning box to show up.

I'm not sure what the best way to approach it is, but it seems some more thought on the rst.py refactoring is needed.

Attachments (0)

Change History (6)

comment:1 by Christian Boos, 18 years ago

Owner: changed from Jonas Borgström to Christian Boos
Severity: normalminor

Well, you can still link to your non-conforming CamelCase links, by using the wiki: link resolver prefix, as you would in TracWiki.

e.g.

{{{
#!rst
:trac:`wiki:AddingMySQLAccounts`
}}}

renders as:

However we could also decide to link to a Wiki page by default, if the target is not otherwise detected as a TracLinks. The "risk" would then be that a malformed TracLinks would not be immediately identifiable.

comment:2 by alastair@…, 18 years ago

Cc: alastair@… added

Sorry, I didn't realise that being the reporter doesn't mean I get email when this ticket get's updated.

Adding the wiki prefix is ugly and doesn't behave the same way as the regular TracWiki syntax behaves. I think the way the ReST way of parsing links should follow as closely as what TracWiki does. Given in 0.10, the default behaviour is to default to a wiki page when no prefix is specified, I think the old behaviour should be restored. Or, at the very least, the outputted HTML should not have "wiki:" in it.

in reply to:  2 comment:3 by Christian Boos, 18 years ago

Keywords: reStructuredText added
Milestone: 0.10.1

Replying to alastair@liquidx.net:

Adding the wiki prefix is ugly and doesn't behave the same way as the regular TracWiki syntax behaves. I think the way the ReST way of parsing links should follow as closely as what TracWiki does.

It's exactly what happens, actually.

Given in 0.10, the default behaviour is to default to a wiki page when no prefix is specified,

Only if the target is a WikiPageName. You might have been confused by a short period of time during 0.10 development in which any target not otherwise recognized was interpreted as a Wiki link, but this behavior has been reverted, as it triggered too many "false positives".

I think the old behaviour should be restored.

That being said, the reST link syntax is certainly less ambiguous than the TracLinks [...] one, and I think we could turn any unrecognized target into a Wiki link.

Can you please try out the following change:

Index: rst.py
===================================================================
--- rst.py	(revision 3774)
+++ rst.py	(working copy)
@@ -59,14 +59,20 @@
 
         def trac_get_reference(rawtext, target, text):
             link = wiki_to_link(target, self.env, req)
+            uri = None
+            missing = False
             if isinstance(link, Element):
-                uri = link.attr.get('href', '')
-                if uri:
-                    reference = nodes.reference(rawtext, text or target)
-                    reference['refuri']= uri
-                    if 'missing' in link.attr.get('class', ''):
-                        reference.set_class('missing')
-                    return reference
+                uri = link.attr.get('href', '')
+                missing = 'missing' in link.attr.get('class', '')
+            else:
+                uri = req.href.wiki(target)
+                missing = not WikiSystem(self.env).has_page(target)
+            if uri:                    
+                reference = nodes.reference(rawtext, text or target)
+                reference['refuri']= uri
+                if missing:
+                    reference.set_class('missing')
+                return reference
             return None
 
         def trac(name, arguments, options, content, lineno,

(targetting for 0.10.1, but depending on feedback and timeframe, this might eventually end-up in 0.10)

comment:4 by alastair@…, 18 years ago

Thanks for the quick reply. It just applied the patch along with the change from trac.util.markup to trac.util.html and it is working like it used to.

It would be great if this was in 0.10.0.

comment:5 by Christian Boos, 18 years ago

Milestone: 0.10.10.10

Thanks for the test and feedback, I applied the patch in r3784.

Working on the topic, I noticed another small issue, TracLinks with space are not working well due to an early "brute force" split on space. I'll try to follow-up with a fix for this too.

comment:6 by Christian Boos, 18 years ago

Resolution: fixed
Status: newclosed

[3785:3786] are two more bug fixes related to WikiRestructuredTextLinks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.