#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 15 years ago by
| Summary: | Won't edit correct section when using equal chars are only on the left side → Won't edit correct section when heading equal chars are only on the left side |
|---|
comment:2 Changed 15 years ago by
| Trac Release: | 0.11 → 0.12 |
|---|
comment:3 follow-up: 4 Changed 15 years ago by
comment:4 Changed 14 years ago by
| Owner: | changed from Catalin BALAN to Ryan J Ollos |
|---|---|
| Status: | new → assigned |
Replying to erny@yaco.es:
The
\1expression 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 14 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
(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.



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
\1expression references the matched(={1,5})expression. I'll try to see if it works making it optional, i.e., just pust a?behind\1.