Page MenuHomePhabricator

Transclusion of page sections
Open, LowestPublic

Description

It would be very useful as well as natural that the transclusion functionality is enhanced to allow transclusion of particular sections by section title. For example, if a user wants to transclude only the section titled "History" of the "Philosophy" article, s/he should be able to do:

{{:Philosophy#History}}

This would agree with the way we link to particular sections of a page: [[Philosophy#History]]

Additionally, the introduction of an article should be transcludable with the following syntax:

{{:Philosophy#}}

This would make sense as the empty hash indicates that the software should transclude the section "without title" of the Philosophy article, and the only section without title is the introduction.

Related Objects

StatusSubtypeAssignedTask
OpenFeatureNone
OpenNone

Event Timeline

Sophivorus claimed this task.
Sophivorus raised the priority of this task from to Medium.
Sophivorus updated the task description. (Show Details)
Sophivorus subscribed.
Sophivorus updated the task description. (Show Details)
Sophivorus set Security to None.
Sophivorus updated the task description. (Show Details)
Sophivorus updated the task description. (Show Details)

Transcluding sections by heading is possible with LabeledSectionTransclusion extension. See documentation. Do you mean that this should be moved to MediaWiki core with {{Title#Section}}? I'm not sure about how useful it would be to transclude by section number.

I'm aware of the LabeledSectionTransclusion extension, which provides a similar but different functionality, more flexible, but less convenient when you simply want to transclude a section.

Yes, I suggest we try to add this functionality to the core, as it would be a useful and natural addition, and in some cases more convenient than the LabeledSectionTransclusion extension, while remaining compatible with it.

Transcluding by section number may not be too useful, I agree, though it's hard to predict what users may come up with. However, transcluding the introduction of a page may very well prove to be the most useful application of this new feature. I think there should be some way to do it, and using section numbers seemed like the most natural to me. Many Wikipedia articles contain short introductions to other articles, which in some cases may be replaced with transclusions of their introductions. For example, the article about fallacies in the Spanish Wikipedia has about ten sections containing short descriptions of various fallacies, which could easily be replaced by transclusions of the introduction of each particular fallacy (I know because I wrote most of them), therefore avoiding duplicate content, reducing maintenance and speeding up the transfer of improvements from one part of the wiki to others.

However, I just realised that each functionality could be implemented separately. It may be worth it, or not, to start a task or subtask for transclusions by title, and another for transclusions by section number.

PS: I didn't mean to remove you as a subscriber. I was editing the task when you added yourself, and when I saved, it removed you.

With the {{:Philosophy#3}} syntax, if I remove or add a section before section 3, then the wrong section will be transcluded. With the {{:Philosophy#History}} syntax, if I rename the history section to something else then the transclusion will break.

Accordingly, this has the potential to be an incredible fragile feature. I don't think it's possible to do this in a non-fragile way without adopting some other method of annotating sections for transclusion.

In LaTeX, you can label a section with a unique identifier which lets you refer to it later in the document. This does not affect the display of the section at all. Example:

\section{History}
\label{historysection}

In short, this would be nontrivial to implement in any kind of rigorous fashion, and would involve extending wikitext even further which does not seem like a great idea given the push to move people towards VisualEditor.

Wouldn't it just be easier all around to have any sections that one wishes to transclude into multiple articles in its own page somewhere?

If someone renames a section and a transclusion breaks, users watching the transcluded page will fix it quick enough. Most sections don't change titles too often. Transcluding by section number has more potential for trouble, but again, its main use may be to transclude the introduction, whose section number doesn't change. And if someone wants to use it for other sections, the risk will be obvious enough.

About the push to move people to the VisualEditor, I'd also like to see a turn towards that, but transcluding sections is a functionality that can easily migrate to the VisualEditor. I mean, today, the VisualEditor only has an interface for transcluding templates by name (right?). This interface could easily be extended so that if you enter ¨:Philosophy¨ you transclude the Philosophy article, and if you enter ":Philosophy#History" or ":Philosophy#3" you transclude a section, and in fact this may turn out to be an advantage over the "labeled section" approach.

On the other hand, you're right in that adding this functionality may just be too complicated to be worth it. But anyone knows the actual code in the area to be sure? I'll take a close look asap, but I haven't yet.

In T108484#1527600, @lfschenone wrote:

If someone renames a section and a transclusion breaks, users watching the transcluded page will fix it quick enough. Most sections don't change titles too often. Transcluding by section number has more potential for trouble, but again, its main use may be to transclude the introduction, whose section number doesn't change. And if someone wants to use it for other sections, the risk will be obvious enough.

There's no real reason to shunt manual work onto people to clean things up when the product could simply be designed in a better, more robust way to avoid making that work necessary. The number of breakages will increase as the feature is used more, which means not only is it fragile, but that fragility with get worse with usage. Similarly, one smaller wikis heavily constrained by manpower, that could be even worse. These things are the hallmark of a poorly designed solution, and in my experience will make users angry for the failure to consider their workload.

This is the reason why I could consider a much simpler solution of using subpages to be far better in terms of reward per unit effort.

On the other hand, you're right in that adding this functionality may just be too complicated to be worth it. But anyone knows the actual code in the area to be sure? I'll take a close look asap, but I haven't yet.

This is hard because the product is difficult to design in an intuitive and robust manner. The code is actually besides the point for the purposes of my argument, although it could certainly complicate things even further once you're past designing the solution and are actually getting to implementation.

Anyway, I just thought I'd give some advice from someone who spends all day doing product design. It's up to you to take it or leave it. :-)

Thanks for the advice. I'm still not sure if it's worth it to implement this, but in case I do, or someone else does, I thought of a design improvement. As already noted, transcluding sections by section number may be problematic and mostly useless. The main use would be to offer a consistent way to transclude the introduction of an article. However, this could also be achieved by the following syntax:

{{:Philosophy#}}

This syntax would mean: transclude the section "without title" of the Philosophy article (aka the introduction). This way of transcluding the introduction would be reasonably consistent with the syntax for transcluding sections by title, and would therefore avoid the "need" to implement transclusions by section number in order to offer a consistent way to transclude the introduction.

Regardless of wether this ends up implemented or not, I think this is a clear design improvement that may also simplify the implementation, so I've updated the task description accordingly.

My motivation for this task was to use it within Wikipedia, but now I can do section transclusions (and more) with the Excerpt Lua Module, so I don't really need this done anymore. Still it would be a nice-to-have feature on MediaWiki, so I'm leaving it open, but I no longer plan to work on it.

Aklapper lowered the priority of this task from Medium to Lowest.Mar 19 2020, 10:37 AM