MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

Allow controlling inclusion of content on a per-page level #676

Open Xenonym opened 5 years ago

Xenonym commented 5 years ago

Tell us about your environment

Rationale: MediaWiki has a transclusion feature, which is similar to our <include> tag. It also supports transclusion markup to allow control over how contents are included:

Transclusion markup

  • noinclude. The markup <noinclude>...</noinclude> means that the text between the tags will not be transcluded onto another page and will appear only on the page itself. This is useful for template documentation and categories.
  • includeonly. The markup <includeonly>...</includeonly> means that the text between the tags will only be used when the page is transcluded onto another page, and will not appear on the page itself. This can be useful, for example, for adding categories to pages transcluding a template, without adding the template itself to these categories.
  • onlyinclude. The markup <onlyinclude>...</onlyinclude> indicates that only text surrounded by "onlyinclude" markup should be transcluded onto another page, but will appear on the page itself if not accompanied by "includeonly" tags as well. This is the most subtle of the partial transclusion tags because it often overrules the others. If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded. There can be several such sections, and within each such section, some material might be further excluded by "noinclude" tags, and might also be surrounded by "includeonly" tags so that it does not appear on the original page itself. But material outside the "onlyinclude" tags will be ignored when the page is transcluded onto another page. This can be useful, for example, to repeat a small part of one page on a second one: just surround the small part by onlyinclude tags, and transclude it onto the second page. Note that unlike <noinclude> and <includeonly>, <onlyinclude> will take precedence over enclosing <nowiki> tags. In other words, <nowiki><onlyinclude>My content</onlyinclude></nowiki> produces only "My content" when transcluded.

Since page inclusion is one of MarkBind's main features, I am wondering if these additional methods for controlling inclusion might be of value? @damithc

Note that these features to a certain extent can be emulated by page fragments, but these tags do not require the creation of fragments for use.

damithc commented 5 years ago

Thanks for bringing up the MediaWiki's transclusion feature @Xenonym Looks like transclusion and subclusion are smiliar to our include and boilerplates, respectively?

As you have mentioned, transaction markup can be achieved using fragment inclusion. Also note that our tags mechanism and include variables too can be used to create slight variations to a component being included.

Some initial thoughts:

What do you guys think?

yamgent commented 5 years ago
  • Ideally, the component being reused should not know how it is being reused. Marking a fragment includeonly goes against that principle. But marking a frament as definition, summary, optional etc. is more natural because the name is describing the fragment, not how it is used.
  • We cannot assume a certain component is always included in the same way. Fragments that are omitted in one reuse context may not be omitted in another. i.e., marking a fragment includeonly does not give that kind of flexiblity.

I think the final implementation of the tag mechanism (#652) would allow the authors to implement these scenarios. I also agree that components have no business in controlling the inclusion directly (the tags themselves provide a better way to control that, and also provides a better context on why certain things are being included/excluded).

I can't find a good use case for these tags. :/