New line inserted when passing a category link as a template parameter - mediawiki-templates

I have a mediawiki template which contains the following code: (there is more, but this is the part relevant to the question)
[[{{#if:{{{page|}}}|{{{page|}}}|{{{ns|}}}{{{1}}}}}]]
I tried to use it where {{{ns}}} is :Category:, but the first colon on :Category: creates an automatic newline (see https://meta.wikimedia.org/wiki/Help:Newlines_and_spaces#Automatic_newline).
How can I fix this template so it correctly creates the link without the automatic newline?
I tried adding <nowiki/> before {{{ns|}}}, but then I got a plain text link ([[:Category:ParameterOne]]) instead of a linkified link

Fortunately I didn't need to add the initial colon in :Category:, so I was able to solve this by simply adding the colon at the beginning of the link inside the Template.
I.e. I passed Category: (without a colon as a prefix) as the parameter {{{ns}}}, and changed the code to:
[[{{:#if:{{{page|}}}|{{{page|}}}|{{{ns|}}}{{{1}}}}}]]
Simply adding a colon before the #if.
Fortunately all other namespaces worked the same as before.

Related

Extract link text from a with webscraping using Google Sheets

I have the following <html> text:
Text
How should I do for getting "Text" value? I am trying with this, but I get an empty value:
=INDEX(importxml("http://www.remoteurl.com";"//a[#href='link.html']");1)
I tried using your syntax and it worked for me. I shortened it a little for testing purposes.
=importxml("https://www.remoteurl.com","//a[#href='link.html']")
Be sure that the href value you are passing in the xpath query is exactly what is present on the web page, e.g. if the web page uses a relative path then you must also use the same relative path.
I was doing it properly, but the problem is that coding was inside an iframe, so it was impossible to reach it.

How to click on a link based on text in a table using selenium

Hi All,
I have the following table with links that I need to select. In this specific example I need to select the DIY Payroll but sometimes this can change its position within the table. The current xpath is:
.//*[#id='catalog-category-div-1']/table/tbody/tr/td1/ul/li[4]/a
So I do a:
By.xpath(".//*[#id='catalog-category-div-1']/table/tbody/tr/td[1]/ul/li[4]/a").click()
But the problem is here is that it can change position where it can be in td[2] or td[3] and li[n'th postion]
Can I have selenium go through the table and click on it based on text. Will the By.linktext() work here ?
You can use the following codes these codes will handle the dynamic changes.
You can use linkText() method as follows:
driver.findElement(By.linkText("DIY Payroll")).click();
If you want to use xpath then you can use following code.
driver.findElement(By.xpath(.//a[contains(text(),'DIY Payroll')).click();
If you need any more clarification you are welcome :)
I would suggest that you try By.linkText() or By.partialLinkText(). It will locate an A tag that contains the desired text.
driver.findElement(By.linkText("DIY Payroll")).click();
A couple issues you might run into:
The link text may exist more than once on the page. In this case, find an element that's easy to find (e.g. by id) that is a parent of only the link you want and then search from that element.
driver.findElement(By.id("someId")).findElement(By.linkText("DIY Payroll")).click();
The A tag may contain extra spaces, other characters, be capitalized, etc. In these case, you'll just have to try using .partialLinkText() or trial and error.
In some cases I've seen a link that isn't an A tag or contains additional tags inside. In this case, you're going to have to find another method to locate the text like XPath.
You should use a CSS selector for this case:
Can you try:
By.CssSelector("a.browse-catalog-categories-link")
You can use XPath to do this. //a will select all 'a' tags. The part inside of the square brackets will select everything with text "DIY Payroll". Combined together you get the desired solution.
//a[contains(text(),'DIY Payroll')]

Mediawiki Extension:RSS

The MediaWiki Extension:RSS (http://www.mediawiki.org/wiki/Extension:RSS) uses the plainlinks class to present the RSS feed link. I have tried all manner of searching, including trying to edit the MediaWiki:Rss-feed template to force the link to presented in non-bolded format.
Has anyone used this extension and can tell me how to change the fonts in the RSS link?
Thanks
As far as I can understand your question, you should be able to remove the boldface formatting from the RSS item titles by editing the page MediaWiki:Rss-item (not MediaWiki:Rss-feed) on your wiki.
What you need to do is two things:
remove the string ''' (MediaWiki markup for bold text) from either side of the title, and
remove the ; (MediaWiki markup for a list definition, which is also bolded by the default style sheet) from the beginning of the line.
That is, change the default content of the page:
; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>'''
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->
to this:
<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->

Alfresco webscript text fromat line break

I created an alfresco webscript and output file as xxx.get.text.ftl file.
In the output file(xxx.get.text.ftl), I am trying to create text version of newsletter. But I am not able to get text lines with line break.
if I put
AAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBB
I am getting as
AAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBB
Any Idea what could be the reason?
EDIT:
in my case i have page, template-instance,template and region. It turns out that when I call web script that fill the region it displays as text.But if I call full url like "www.xxx.com/news/my-news" it includes other components like template, page etc. and it turns the output to html. Because output for template or page is hard coded to text/html in surf.
If is text try to add
\n
at the end of line
Whitespace and especially new-line handling is always an issue for template languages because it is not clear whether the remove the new line after a closing template-tag or not. See the freemarker documentation for discussion: http://freemarker.org/docs/dgui_misc_whitespace.html
I think you just have to add an extra newline.

How to disable header on frontpage of rst2pdf document?

I am generating some PDF's and I would like to disable the header on the frontpage. I know there are built-in templates in rst2pdf and one template is called coverPage but I don't seem to be able to get it to work.
The manual is saying you should use a
..raw:: pdf
PageBreak coverPage
statement but that will insert a empty before the coverpage, so how can I have a coverpage without a header and without using the oddeven directive (I want to use the same header on all remaining pages).
Thanks for your suggestions!
That's how you change the stylesheet after the cover page. You'll need to create a custom stylesheet that specifies what is the format of the first page and then change the style for the rest of document. Have a look at chapter 15 of the manual.
Note: current accepted answer contains broken link (linked website has gone).
The correct answer is simple:
1) In you style-file define:
pageSetup:
firstTemplate: coverPage
2) Then in your template, when you want to start using header/footer add:
..raw:: pdf
PageBreak cutePage
Make sure cutePage has set header/footer to true.

Resources