Modify

Opened 6 years ago

Closed 4 months ago

#9537 closed enhancement (fixed)

Only Include a Section of a wikipage or a regular expression match

Reported by: suddani@… Owned by: Ryan J Ollos
Priority: high Component: IncludeMacro
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

This Patch allows you to include a Section(with all its subsections) into another wiki page with:

[[Include(wiki:Page#Section)]]

and it allows you to match for regular expressions in a wiki page and only include those like:

[[Include(wiki:Page@/== Section ==(.*?)==/)]]

it than returns the first saved group of the regular expression in this case everything inside the Section with name "Section" but without its subsections.

Attachments (2)

includeSectionOnlyPatch.diff (3.2 KB) - added by suddani@… 6 years ago.
IncludeSectionPatch
IncludeSection.diff (6.2 KB) - added by David Robins 4 months ago.
Patch implementing #section to include section.

Download all attachments as: .zip

Change History (17)

Changed 6 years ago by suddani@…

IncludeSectionPatch

comment:1 Changed 5 years ago by anonymous

I vote for this to be added to master.

comment:2 Changed 5 years ago by anonymous

I retract that statement because I was unable to get the patch to work...

comment:3 Changed 5 years ago by Ryan J Ollos

#8972 and #3882 closed as duplicates. The higher numbered ticket is being retained since it has a patch.

comment:4 Changed 4 years ago by Ryan J Ollos

Owner: changed from Noah Kantrowitz to Ryan J Ollos
Status: newassigned

comment:5 Changed 3 years ago by Markus Vuori <markus@…>

This would be really nice. Badly needed. :)

comment:6 Changed 3 years ago by Ryan J Ollos

I'm pretty busy working on other Trac-related things, but if you can test the patch and provide feedback, that would be a good start to getting it incorporated.

comment:7 Changed 3 years ago by Markus Vuori <markus@…>

I didn't manage to apply the patch to the newest version of includemacro. The first two hunks were succesful and two latter ones unsuccesful.

comment:8 Changed 3 years ago by Ryan J Ollos

Status: assignedaccepted

comment:9 Changed 2 years ago by Ryan J Ollos

#10639 closed as a duplicate.

comment:10 Changed 2 years ago by Ryan J Ollos

Status: acceptednew

Refocusing.

Changed 4 months ago by David Robins

Attachment: IncludeSection.diff added

Patch implementing #section to include section.

comment:11 Changed 4 months ago by David Robins

We found this useful so I implemented the top syntax - [[Include(wiki:Page#Section)]] - patch is against the trunk (3.0.0) source and was tested against Trac 1.2.

comment:12 Changed 4 months ago by Ryan J Ollos

Status: newaccepted

comment:13 Changed 4 months ago by Ryan J Ollos

In 16429:

TracIncludeMacro 3.1.0dev: Allow linking to a page section

Refs #9537.

comment:14 Changed 4 months ago by Ryan J Ollos

In 16430:

TracIncludeMacro 3.1.0dev: Extract up to heading of the same level

Refs #9537.

comment:15 Changed 4 months ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

I reworked the patch to use the same heading regex as the Trac wiki parser. Ideally we should match the implicit ids that are created for each section, but I didn't come up with a way to do that, and so the change requires that an explicit id be created for the heading. For example:

== The heading #headingid

... and then you can link to [[Include(page#headingid)]]. If in the future we can map from implicit id to heading, then having an explicit id won't be required.

I also think it's probably possible to implement the match in a single regex, but I didn't figure it out yet.

Modify Ticket

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

Add Comment


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

 
Note: See TracTickets for help on using tickets.