Modify

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#7826 closed defect (fixed)

Won't edit correct section when heading equal chars are only on the left side

Reported by: shai Owned by: Ryan J Ollos
Priority: normal Component: SectionEditPlugin
Severity: major Keywords: heading equal characters
Cc: Trac Release: 0.12

Description

When using equal characters ("=") only on the left side of the heading, the plugin won't edit the correct section.

Example for testing:

== Single Heading 1
Test
== Single Heading 2
Test
== Single Heading 3
Test
----
== Double Heading 1 ==
Test
== Double Heading 2 ==
Test
== Double Heading 3 ==
Test

Attachments (0)

Change History (6)

comment:1 Changed 14 years ago by shai

Summary: Won't edit correct section when using equal chars are only on the left sideWon't edit correct section when heading equal chars are only on the left side

comment:2 Changed 14 years ago by shai

Trac Release: 0.110.12

comment:3 Changed 14 years ago by erny@…

The problem seems to be the regular expression in web_ui.py near line 99:

if is_code_block == False and re.match(r'^\s*(={1,5}) .+ \1(?:\s*#.+)?\s*$', line):

The \1 expression references the matched (={1,5}) expression. I'll try to see if it works making it optional, i.e., just pust a ? behind \1.

comment:4 in reply to:  3 Changed 13 years ago by Ryan J Ollos

Owner: changed from Catalin BALAN to Ryan J Ollos
Status: newassigned

Replying to erny@yaco.es:

The \1 expression references the matched (={1,5}) expression. I'll try to see if it works making it optional, i.e., just pust a ? behind \1.

Yeah, that essentially works, except that there appears to have been a separate existing issue with the regex. Trac 0.12.0 allows headings like == heading == as well as == heading==. That is, my observation with Trac 0.12.0 is that a whitespace is required between the heading markup character and the text, but not between the text and the trailing markup.

However, the relevant part of the regex was ) .+ \1(, which required a whitespace character between the leading and trailing markup characters.

Looking at the source code for Trac, I think this makes sense. If we look at Trac 0.11.0, the regex for matching a heading is:

r"(?P<heading>^\s*(?P<hdepth>=+)\s.*\s(?P=hdepth)\s*"

In 0.12.0, it is:

r"(?P<heading>^\s*(?P<hdepth>={1,6})\s(?P<htext>.*?)"

Trac 0.12 matches =\s as a heading, but not =. There must be a whitespace character after the heading character, but no other characters are required. I think we should just change the SectionEditPlugin's regex to be the same as that used for extracting a heading in Trac 0.12.

I wonder though, why we are only capturing level 1-5 headings with the SectionEditPlugin rather than levels 1-6.

comment:5 Changed 13 years ago by Ryan J Ollos

Resolution: fixed
Status: assignedclosed

(In [11180]) Fixes #7826: Modified the regex to agree with that used for section headings in Trac 0.12.0. The [Edit] icons should now be attached to every line of markup that Trac identifies as a section heading, which the exception of a level 6 heading. The latter issue was noted in comment:4 of #7826 and it should be investigated further why SectionEditPlugin only looks at level 1-5 headings.

comment:6 Changed 13 years ago by Ryan J Ollos

(In [11186]) Refs #7826: Add Edit links to section headings level 1-6 (previously, only 1-5).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.