Mediawiki 1.16: labeled section transclusion - mediawiki

We have installed the Labeled section transclusion extension which basically allows you to transclude particular sections from another page or explicitly mark off a portion of the page to be transcluded.
I've been using #lsth to transclude headers, but have noted that it doesn't include the section header itself, which means the "Edit" link to the section isn't there.
Now I could always explicitly write an edit link to that section, but if I hardcode the section number and add more sections to the source page, the edit links would point to the wrong sections.
Is there a way to get the Edit link to the transcluded section?
Here is an example: I have a News page that will list all sorts of general happenings that occurs on the wiki. It consists of "project news" and "administrative news", and some other categories.
They will be used in many places, so it's easiest to transclude them. I didn't want to create separate pages for each type of news, so I decided to use section transclusion. However, if a user wanted to update the news, there is no convenient way to click on an EDIT link that goes straight to the section.

I tried this with the following:
test is
==hi!==
Original is
==1==
{{test}}
==2==
It renders as:
==1==
==hi!==
==2==
So, this must be a problem with the extension, not with the transclusion mechanism. Make sense to you?

Don't transclude the header, transclude the whole section including the header by putting LST tag from before the header till the end of the section.

When you use a section as a transclusion container in LST, it removes the header intentionally; I suspect that this is so you can easily label a bunch of transcludable text on a page with purely organizational headers (like numbered sections) without worrying about them showing up. So in your case, instead of using the {{#lsth} function, you'll have to use the slightly more complicated {{#lst}} function. Wrap the whole section in <section begin/><section end/> tags, including the header, and then it will transclude properly. For example:
<section begin="mySection" />
== My Section ==
My long block of text.
<section end="mySection" />
Then simply place a {{#lst:myPage|mySection}} function on the page where you want it to appear, and the header (and edit block) will come with it.
Alternatively, use an embedded level of headers. If you have this page:
== My Transclusion ==
=== My Section ===
My block of text
== My Second Transclusion ==
And you use a {{#lsth:myPage|My Transclusion}} function, it will transclude everything until the next header of the same level (My Second Transclusion, in this case), including the "My Section" header. If you want My Section to be a normal (<h2>) header, then do this:
= My Transclusion =
== My Section ==
My block of text
= My Second Transclusion =

Related

Redirect a Python-Sphinx generated webpage with Jinja2

My Python Sphinx restructuredtext project includes empty 1st level sections. How can I redirect users to the first subsection of the HTML output without resorting to raw Javascript?
Hi,
index.rst is as follows:
Title
=====
.. toctree::
:hidden:
foo.rst
bar.rst
To avoid displaying a blank index.html page, I automatically display the 1st subsection, namely foo.html, via the following trick:
Title
=====
.. raw:: html
<script type="text/javascript">
window.location.href = "foo.html"
</script>
.. toctree::
:hidden:
foo.rst
bar.rst
Is it possible to apply the same behavior to all sections with Jinja in Python-Sphinx, i.e: if section body is empty and subsections exists, then fall back to 1st subsection?
Add a label.
If you place a label directly before a section title, you can reference to it with :ref:[backtick]label-name[backtick]. For example:
.. _my-reference-label:
Section to cross-reference
--------------------------
This is the text of the section.
It refers to the section itself, see :ref:`my-reference-label`.
The :ref: role would then generate a link to the section, with the link title being “Section to cross-reference”. This works just as well when section and reference are in different source files.

Can we auto-expand an HTML 'details' when a hyperlink points to it?

I am creating a page with language information. Since it is extremely long, I collapse each language with details/summary tags and have them in alphabetic sections with each initial letter also a collapsed details. Currently, each language is coded like
<details>
<summary id="am"><b>am — Amharic</b></summary>
<p><img src="/wp-content/uploads/2018/05/GBV-Amharic-150.jpg"/>About 22 million native speakers, … [more info]</p><br clear="all"/>
</details>
If I put a link elsewhere like http://domain.TLD/path/#am, I'd like to take the user to that page, scroll to that section, and expand the details. If that's possible, do I have the wrong syntax for one or both sides? It is not working now—nothing expands and it goes to the top of the page as if the # were not there. But the address field shows the full URI of the link, #id included.
"path/" is interpreted by Wordpress and/or a Wordpress-generated .htaccess, so perhaps that somehow prevents it working correctly.
You have the correct syntax for directing a user to an element with the id "am."
You can check the URL the browser used to display the page with jQuery. For your example if a link sent a user to http://domain.TLD/path/#am the following code would trigger if the browser contained "path/#am" as part of the URL.
jQuery(document).ready(function($) {
if(window.location.href.indexOf("path/#am")){
/* do something to the element in jQuery -- likely apply a class.
*/
}
There are many animation and scrolling libraries related to jQuery as well.

Gitbook header add id and internal links

I am new to the programming community and new to Gitbook. I have searched gitbook doc but still having some syntax problems.
I have been trying to add internal links so that, on a long web page, I can click links on the top of the page and it will directs me to content blocks contained in the bottom of the page. I also have a few long pages.
[Clickable Link1](redirects to headerId1 in the same page)
[Clickable Link2](redirects to headerId2 in the same page)
...
Real Content
Header 1 with id = headerId1
Content1
Header 2 with id = headerId2
Content2
...
The resources I had looked for involves:
https://gitbookio.gitbooks.io/markdown/content/syntax/links.html
The problems I am having is:
add id to headings.
I tried to type ### Header1 {#id=myheader1} After typing ### and followed by a space, the Header1 {#id=myheader1} became big and shows as heading3 size texts. How do I escape and make sure it only shows Header 1 with heading 1 font and assigned with id of header1?
Refer to internal headings
I tried to follow the doc, but still, it only shows the original text with [] and does not turn into clickable links.
Please share some tips and help. Thank you very much.
I strongly advise against manually building a table of contents. It's a pain to make them, and even more of a pain to maintain them.
Instead, let software take care of this for you. Here are two GitBook plugins that I just found for making tables of contents:
https://www.npmjs.com/package/gitbook-plugin-page-toc
https://www.npmjs.com/package/gitbook-plugin-simple-page-toc
Plugins can be enabled within the editor or by editing the book.json file.
I know this question was asked a long time ago. Just in case anyone come across this because there is no official docs for this:
You could define your custom anchor to a header using the syntax ## My heading {#my-anchor} and reference it normally with [my text](#my-anchor). This will show the heading correctly as My heading and navigation will work properly.

Fragment link not working

Total newbie question, but I cant figure out what im doing wrong. I want a make a link that jumps down the page to a header. I believe these are called fragment links. Here is my code thats not working:
My Link
<div id="cont">
<p>Lots of content here, abbreviated in this example to save space</p>
<h2 id="Frag">Header I want to jump to</h2>
</div>
Pretty sure you need to specify the name attribute for an anchor to work, for example:
Skip to content
<div name="content" id="content"></div>
Okay, so 'pretty sure' was a euphemism for 'guess' and I thought I'd look it up, so, from the HTML 4.01 Specification we get this from section 12.2.3 Anchors with the id attribute:
The id attribute may be used to create an anchor at the start tag of
any element (including the A element). This example illustrates the use of the id attribute to position an anchor in an H2 element. The anchor is linked to via the A element.
You may read more about this in Section Two.
...later in the document
<H2 id="section2">Section Two</H2>
...later in the document
<P>Please refer to Section Two above for more details.`
To carry on the convention of guesswork, perhaps your page isn't long enough to allow jumping to that content (that is, your page might have nowhere to jump and the content to jump to is already visible.)
Other than that, and from the same section of the spec previously linked, here is some general info on when to use what as the anchor identifier (in terms of the link its self) that could be otherwise valuable:
Use id or name? Authors should consider the following issues when
deciding whether to use id or name for an anchor name:
The id attribute can act as more than just an anchor name (e.g., style sheet selector, processing identifier, etc.).
Some older user agents don't support anchors created with the id attribute.
The name attribute allows richer anchor names (with entities).
Your code works fine in firefox anyway you can use as well name instead of id..
http://www.w3schools.com/tags/att_a_name.asp
if you want to have a nice scrolling you can use jquery scroll http://api.jquery.com/scroll/

What data should I care when retrieving only the contents of a HTML webpage?

We all know that the contents of an HTML page aren't just the data between open and closed tags, for example, <p></p>.
Beyond image "alt" and any "title" attributes, what HTML offer to me that I should consider as a content?
Any suggestions?
Getting Your Text...
Titles (<h1> - <h6>), images (<img />), paragraphs (<p>) and links (<a>). Not much more than that. Unless you want to count tables too.
If you want to pull all of the text from the Body, you can do so easily with a scraper-tool like phpQuery (requires PHP):
phpQuery::newDocument(file_get_contents("http://www.somesite.com"));
$body = pq("body")->text();
print $body;
In that example, $text would be the total content of your entire page. You could then search for keywords in there to help you determine the content.
Scanning Your Text for Keywords...
As you stated in your comment, you're wanting to guard against porn-url's being submitted. Using this method, you can get the text. Once you have the text, you could scan it and build a list of keywords/instances. That list should give you a good idea about the content/subject of the page (unless the page is just a video of some sort).
To learn how you can build these keywords/instances list, view the following Question:
Quickly Build List of Keywords from Text, Including # of Instances