Comments (5)
Improvements on the filter expression:
[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data, guaranteeing that in the decades to come you will still be able to use the notes you take today.]search-replace:g:regexp[(.{40}).*],[$1]search-replace:g:regexp[(.*)\s(\w+)$],[$1]]
or
[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data, guaranteeing that in the decades to come you will still be able to use the notes you take today.]search-replace:g:regexp[^(.{30,45})\s.*$],[$1]]
The latter is potentially more brittle if there is no word boundary between 30th and 45th character.
from streams.
Can also check for only whitespace in the text body and avoid the recursive macro while we are at it:
\whitespace trim
\define stream-show-breadcrumbs()
<$list filter="[<currentTiddler>has[stream-type]]">
<$list filter="[<currentTiddler>get-stream-root:includeall[]]">
<$wikify name="display-title" text={{{ [<currentTiddler>!is[binary]get[text]trim[]!is[blank]] ~[{!!title}] }}}>
<span class="sq-breadcrumbs-fragment">
<$link to=<<currentTiddler>>>
<$text text={{{ [<display-title>split[]first[50]join[]] }}}/>
</$link>>
</span>
</$wikify>
</$list>
</$list>
\end
<$list filter="[{$:/config/sq/streams/enable-breadcrumbs}match[yes]]" variable="_NULL">
<<stream-show-breadcrumbs>>
</$list>
This does not include the above breadcrumb improvements. Also, use :reduce
.
from streams.
One thing I have noted when tweaked this macro myself for improved readability was that just testing whether text
field is blank can occasionally lead to a blank fragment when the wikified text
field is "effectively" blank, e.g. when the tiddler only contains a image tag or some macros.
To circumvent the issue, I prepared a regex pattern that detects some common non-blank content. The breadcrumb shall only fall back to using the title
field if the text
field appears to contain effectively blank content:
<$set name="pattern" value="^\s*(\w|\[\[|`|''|//|__)">
<$wikify name="display-title" text={{{ [<currentTiddler>!is[binary]regexp:text<pattern>get[text]] ~[{!!title}] }}}>
<span class="sq-breadcrumbs-fragment">
<$link to=<<currentTiddler>>>
<$text text={{{ [<display-title>split[]first[50]join[]] }}}/>
</$link>>
</span>
</$wikify>
</$set>
from streams.
@zhangxiubo thank you for the input, it is very helpful.
You have helped me to realize that there is a better way to check for blank fragments, since wikify will always return plain text. So we should check if the text is blank after we wikify. This will be more reliable and accurate than a regular expression.
Something like this (untested):
<$wikify name="display-title" text={{{ [<currentTiddler>!is[binary]get[text]trim[]] }}}>
<span class="sq-breadcrumbs-fragment">
<$link to=<<currentTiddler>>>
<$text text={{{ [<display-title>!is[blank]else<currentTiddler>split[]first[50]join[]] }}}/>
</$link>>
</span>
</$wikify>
from streams.
@saqimtiaz That's definitely a better solution!
from streams.
Related Issues (20)
- Rename tiddlers when dragging and dropping HOT 1
- ios 14 merge node using backspace (with "prompt before merging with previous" OFF) deletes last character of previous node HOT 1
- Docs for transcluding a Stream
- Make it easier to manipulate tags when editing nodes using the inline editor HOT 4
- Support for streams in tiddlyclip HOT 3
- Docs for exporting as wikitext with divs
- IDEA: for nodes with no content use title as displayed body
- root buttons compatibility for shadow tiddlers
- Enable relink on rename for demo site
- Input fields in settings can be too narrow
- Add a field "caption" HOT 1
- Replace current UI for renaming tiddlers
- swiping for context menu not working on 5.2.0 pre-release in ios 14.8 safari HOT 3
- Use tiddlywiki's sidebar breakpoint in streams/styles HOT 2
- bug: when the fold-bar is switched on, the breadcrumbs are obscured HOT 3
- Messy "recent" tab HOT 2
- Error when editing node after changing to markdown HOT 1
- [bug?] Bullets become offset when font size is changed from the default
- Root's buttons missing when displayed on ipad
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from streams.