List of tiddlers with clickable tags formated as links - tiddlywiki

I want to display a list of tiddlers with a specific tags. Each item/tiddler should be displayed with a list of clickable tags (its tags formatted as hyperlinks). How do I have to modify the following code (which displays the tags as plain text) in order to achieve this?
<$list filter="[!tag[hidden]tag[contact]sort[]]">
* <$link to={{!!title}}><$view field="title"/></$link> <$view field="tags"/>
</$list>

This will work:
<$list filter="[!tag[hidden]tag[contact]sort[]]">
* <$link to={{!!title}}><$view field="title"/></$link> -<$list filter="[all[current]tags[]![contact]]"><$link to={{!!title}}> <$view field="title"/></$link></$list>
</$list>

Related

How can I xpath target text() "only" directly under a html tag, instead of the text contained under "other html child tags"

How can I xpath target text() "only" directly under a html tag, instead of the text contained under "other html child tags"
Consider
<li class="one">
<label class="two">
<span class="two-one">Unwanted text</span>
Wanted text only directly under under label (not under span)
</label>
Two options :
If you have multiple lines to fetch :
//label/text()[normalize-space()]
If you have just one line to fetch, use position. For your sample data:
//label/text()[last()]
[last()] could be replaced with [1],[2],[3],... to specify the position of the text you're trying to get.

xpath remove an attribute from an dynamic attribute list

I want remove an xml attribute via xpath, but
the xml element could have more atrributes in the future.
html code:
<p class="red, blue, green">test/<p>
xpath:
<xpath expr="//p[contains(#class, 'green')]" position="attributes">
<attribute name="class">red, blue</attribute>
</xpath>
Is where a better way for fixtext "red, blue"?
In order to suppport possible new version of the html file like
"<p class="red, blue, green, brown">test</p>" in the future without need to change the xpath code again.
for instance actual attribute list as var + an xpath function
What about setting the #class to
concat(substring-before(#class, "green"), substring-after(#class, "green"))
You'll need to solve the abandoned commas, too, but as Björn Tantau commented, in real HTML the classes would be separated by spaces, so you can just wrap the result into normalize-space.

XPath exclude given class

I'm trying to extract text from a div but excluding a given class:
This is what i'm trying:
$pattern = "//div/#title[not(contains (#class, 'second_card local_impact_icon impact-2'))]";
but its not excluding the given class, i need to extract just the text of title='' but just from the first div title.
This is the html:
<div class="match_info"><div title='Yellow Card' class='local_impact_icon impact-1'></div><div title='Red Card' class='second_card local_impact_icon impact-2'></div></div>
Following XPath
//div/div[not(contains (#class, 'second_card local_impact_icon impact-2'))]/#title
returns
title="Yellow Card"
Simplified explanation - just select the div that doesn't contain the class you want to exclude and retrieve the title attribute for this div only. When you set this exclude at the position ../#title you already are at the title-attributes of both divs.
And as the question is how to retrieve the text - in given example
string(//div/div[not(contains (#class, 'second_card local_impact_icon impact-2'))]/#title)
returns Yellow Card

How to extract inner text of multiple Paragraph tags which are nested withing an anchor tag

Here is the code:
<a id='Letter1'>
<p>Dear Sir, </p>
<p>This is with.........</p>
<p>I would be.......</p>
<p>Hoping to hear from you soon</p>
<p>Regards.</p>
</a>
Using Xpath I want to extract the inner text of all the Paragraph tags which are contained inside the anchor tag as a single text entity.
The final result i want is
string letterBody= document.DocumentNode.SelectSingleNode("//XPATH QUERY").innerText;
where letterBody="Dear Sir, This is with...................Regards."
You need to just get the <a> element and you will get all the text nodes which are under <a> as its innertext.
So your xpath would be /a[#id='Letter1'] or just /a.

XPath / XQuery: find text in a node, but ignoring content of specific descendant elements

I am trying to find a way to search for a string within nodes, but excluding ythe content of some subelements of those nodes. Plain and simple, I want to search for a string in paragraphs of a text, excluding the footnotes which are children elements of the paragraphs.
For example,
My document being:
<document>
<p n="1">My text starts here/</p>
<p n="2">Then it goes on there<footnote>It's not a very long text!</footnote></p>
</document>
When I'm searching for "text", I would like the Xpath / XQuery to retrieve the first p element, but not the second one (where "text" is contained only in the footnote subelement).
I have tried the contains() function, but it retrieves both p elements.
Any help would be much appreciated :)
I want to search for a string in
paragraphs of a text, excluding the
footnotes which are children elements
of the paragraphs
An XPath 1.0 - only solution:
Use:
//p//text()[not(ancestor::footnote) and contains(.,'text')]
Against the following XML document (obtained from yours but added p s within a footnote to make this more interesting):
<document>
<p n="1">My text starts here/</p>
<p n="2">Then it goes on there
<footnote>It's not a very long text!
<p>text</p>
</footnote>
</p>
</document>
this XPath expression selects exactly the wanted text node:
My text starts here/
//p[(.//text() except .//footnote//text())[contains(., 'text')]]
/document/p[text()[contains(., 'text')]] should do.
For the record, as a complement to the other answers, I've found this workaround that also seems to do the job:
//p[contains(child::text()|not(descendant::footnote), "text")]

Resources