Using Tiddler Sections

130 views
Skip to first unread message

Michael.Tarnowski

unread,
Oct 14, 2008, 9:11:14 AM10/14/08
to TiddlyWiki
Hi community,

Eric explained in http://groups.google.com/group/TiddlyWiki/browse_thread/thread/b43046cbec7a0dd3hl=en
briefly the new feature of tiddler sections in TW 2.3.

>> ---- begin quote: ------

The ability to create and use 'named' parts within a tiddler is now
part of the TW core, and is called "tiddler sections".

A tiddler section begins with a 'heading' formatted line (i.e. a line
beginning with a "!". The text of the heading is used as the name of
the section. The section content includes everything following the
heading line, stopping at the next heading (or the end of the tiddler
if there are no more headings).

A *reference* to a tiddler section is constructed by appending the
section name following the tiddler name, using "##" as a separator,
like this:

TiddlerName##SectionName

As always, if the TiddlerName or SectionName contains spaces, enclose
the entire reference in [[...]], like this:

[[TiddlerName#Some Section Name with Spaces]]
>> -------- end quote -----

Do I understand this correct that with this a kind of anchoring in
tiddlers is possible? For example, MyTiddler contains:

!Section 1
Bla Bla Bla.... Bla, see [[Anchor1|MyTiddler##Section 3]] Bla Bla

!Section 2
Bla Bla see [[Achor2|MyTiddler##Section 1]] Bla Bla ...

!Section 3
Bla Bla Bla

When I tried this in my TW links of the kind [[Achor2|
MyTiddler##Section 1]] were always interpreted as external ones to a
tiddler MyTiddler##Section 1
I'am afraid, I missed this new concept.
Cheers Michael

Eric Shulman

unread,
Oct 14, 2008, 9:40:56 AM10/14/08
to TiddlyWiki
> A *reference* to a tiddler section is constructed by appending the
> section name following the tiddler name, using "##" as a separator,
> like this:
>   [[TiddlerName##Some Section Name with Spaces]]

>
> Do I understand this correct that with this a kind of anchoring in
> tiddlers is possible? For example, MyTiddler contains:

Tiddler section references are intended for use with the <<tiddler>>
macro, so that a subsection of content from one tiddler can be
transcluded into another, like this:
<<tiddler [[TiddlerName##SectionName]]>>

At present, Tiddler sections do not provide support for autoscrolling
to an 'anchor point' within the body of a tiddler and cannot be used
in a TiddlyLink. Sorry.

-e
Eric Shulman
TiddlyTools / ELS Design Studios

Michael.Tarnowski

unread,
Oct 14, 2008, 9:54:30 AM10/14/08
to TiddlyWiki
>> At present, Tiddler sections do not provide support for autoscrolling
>> to an 'anchor point' within the body of a tiddler and cannot be used
>> in a TiddlyLink. Sorry.

What a pitty! -- Then I will use furthermore Udo's PartTiddlerPlugin
for inter-tiddler links.
Thanx for the fast reply Eric!
Have a nice day
Michael

tfer

unread,
Oct 14, 2008, 10:54:59 AM10/14/08
to TiddlyWiki
Hmm, this might be what I need through.

I'm looking to use a lot of memorizable tables to aid in studying
machine steno, and it would be useful to be able to tranclude into
different groups, e.g. Phrases covered up to Lesson 7,... .

But as something with a more general usage pattern, I'd like to have a
hidden/not-rendered section in which to plunk the table values, (e.g.
in tab separated values format), and have TW generate the visible
memorizable table from that data, (when the user accepts an edit of
the tiddler).

Would sections give me access to the TSV's?

Tom Fetherston

Eric Shulman

unread,
Oct 14, 2008, 11:44:29 AM10/14/08
to TiddlyWiki
> But as something with a more general usage pattern, I'd like to have a
> hidden/not-rendered section in which to plunk the table values, (e.g.
> in tab separated values format), and have TW generate the visible
> memorizable table from that data, (when the user accepts an edit of
> the tiddler).
>
> Would sections give me access to the TSV's?

You can enclose a section definition within TW comment markers, like
this:

/%
!SectionName
1,2,3,4...
5,6,7,8...
etc.
!end SectionName
%/

Although the section content will not be rendered (because it is
inside a comment), it *is* still available for use in a section
reference from another tiddler. The trailing "!end..." syntax ensures
that the closing comment marker is not included as part of the section
content.

Note that, because the entire section is enclosed in a comment, you
cannot also use TW comments within the section content itself (because
the comment syntax does not 'nest').

As an alternative approach, you could *hide* the section definition by
wrapping it in some CSS, like this:
@@display:none;
!SectionName
content
!end SectionName
@@
OR
{{hidden{
!SectionName
content
!end SectionName
}}}

(where 'hidden' is a custom CSS class... see
TiddlyTools#StyleSheetShortcuts)

However, unlike comment-wrapped section definitions, hidden sections
are still *rendered*, even though they are not visible. This might
increase the display overhead when viewing that tiddler, but shouldn't
normally cause any problems, unless the hidden section content invokes
some macros that produce side effects.

Once you have defined a commented/hidden section, you can, of course,
display that content by transcluding it using <<tiddler
TiddlerName##SectionName>>. Because the surrounding comment markers
(or CSS syntax) are *not* part of the section content itself, the
content renders as normal when transcluded, even though it is
commented/hidden in the 'source' tiddler that defines it.

For your specific purposes, where the section content is just TSV (tab-
separated values) data, simple transclusion is obviously not
sufficient. You will also need some code that reads the TSV data and
converts that content into a TW table (by replacing the tabs with "|"
and the newlines with "|\n|"). To do this, you can use
InlineJavascriptPlugin to write a script like this:

<script>
var out=store.getTiddlerText("TiddlerName##SectionName"); if (!out)
return;
out=out.replace(/\t/g,"|");
out=out.split("\n").join("|\n|");
out="|"+out+"|\n";
return out;
</script>

The result is that input like this:
1,2,3
4,5,6
7,8
becomes
|1|2|3|
|4|5|6|
|7|8|
(i.e., a TW table... QED)

Note: you can write the above even more compactly:

<script>
var out=store.getTiddlerText("TiddlerName##SectionName"); if (!out)
return;
return "|"+out.replace(/\t/g,"|").split("\n").join("|\n|")+"|\n";
</script>

enjoy,

Eric Shulman

unread,
Oct 17, 2008, 10:18:55 AM10/17/08
to TiddlyWiki
> >> At present, Tiddler sections do not provide support for autoscrolling
> >> to an 'anchor point' within the body of a tiddler...

... but they do now!!

Get the latest update:
http://www.TiddlyTools.com/#CoreTweaks

Tweak #784: allow tiddler sections in TiddlyLinks to be used as anchor
points for intra-tiddler scrolling.

Usage: embed a TiddlyLink containing a section reference, e.g.
[[SomeTiddler##SomeSection]], in tiddler content. When the link is
clicked [[SomeTiddler]] will be opened *AND* auto-scrolled so that the
heading "SomeSection" is in view.

see also: http://trac.tiddlywiki.org/ticket/784

enjoy,

HansWobbe

unread,
Oct 17, 2008, 2:33:21 PM10/17/08
to TiddlyWiki
On Oct 17, 10:18 am, Eric Shulman <elsdes...@gmail.com> wrote:
> Tweak #784: allow tiddler sections in TiddlyLinks to be used as anchor
> points for intra-tiddler scrolling.
>
> Usage: embed a TiddlyLink containing a section reference, e.g.
> [[SomeTiddler##SomeSection]], in tiddler content.  When the link is
> clicked [[SomeTiddler]] will be opened *AND* auto-scrolled so that the
> heading "SomeSection" is in view.
>

Just a quick post to express my gratitude for this "tweak" since it is
particularly valuable, given my personal USE style.

Eric Shulman

unread,
Oct 17, 2008, 8:23:07 PM10/17/08
to TiddlyWiki
>    http://www.TiddlyTools.com/#CoreTweaks
> Tweak #784: allow tiddler sections in TiddlyLinks to be used as anchor
> points for intra-tiddler scrolling.

update: this tweak has been re-written to support auto-scrolling for
section references in permalinks/permaviews as well as TiddlyLinks.
For example, try this link:

http://www.TiddlyTools.com/#CoreTweaks##784

Michael.Tarnowski

unread,
Oct 18, 2008, 5:32:43 AM10/18/08
to TiddlyWiki
Hi Eric,
When trying the link you provided, I got in TiddlyTools the error
message:

"The tiddler 'CoreTweaks##784' doesn't yet exist. Double-click to
create it"

When using the new tweak in my TW the links [Tiddler##Anchor]] is
interpretated as link to an external source.

Cheers Michael

Eric Shulman

unread,
Oct 18, 2008, 9:25:55 AM10/18/08
to TiddlyWiki
> When trying the link you provided, I got in TiddlyTools the error
> message:
> "The tiddler 'CoreTweaks##784' doesn't yet exist. Double-click to
> create it"

Hmm... that sounds like you are still loading an old version of
TiddlyTools. Try flushing your browser's cache (or at least use
"shift-reload" to get a fresh copy of www.TiddlyTools.com).

> When using the new tweak in my TW the links [Tiddler##Anchor]] is
> interpretated as link to an external source.

That's very odd since I only changed the handling for
createTiddlyLink()... not createExternalLink()... my code is only
triggered if the core has already recognized the link as *internal*.
In any case, *without* the tweak (i.e., in a plain TW),
[[Tiddler##Anchor]] should always be treated as an internal TiddlyLink
to a tiddler named "Tiddler##Anchor". With the tweak installed,
[[Tiddler##Anchor]] should still be treated as a internal link to
"Tiddler" (i.e., with the "##Anchor") part removed.

If it's not a cache-related problem, then perhaps it is a plugin
interaction... please try a *minimal* test case on your system: create
a TW document with ONLY the updated CoreTweaks and a simple tiddler
with [[Foo##Bar]] in it and see what happens.

Michael.Tarnowski

unread,
Oct 19, 2008, 7:08:06 AM10/19/08
to TiddlyWiki
Eric,
for CoreTweaks##784 you were right: I refreshed the FF cache, now it
works;
but for my own TW the link [[Tiddler##Anchor]] is still interpreted as
link to file 'Tiddler' with anchor 'Anchor'. I' will follow your
advice to investigate a plugin interference.
Michael

Ty Zucker

unread,
Oct 20, 2008, 7:21:33 PM10/20/08
to TiddlyWiki
Ok, TW noob here. I must be missing something obvious. I'm wanting
to reference a section, just like this thread is talking about.

So let's say I have a tiddler named "Ice Cream".
And in that tiddler, I have headings/sections like:
!Rocky Road

Mmm Delicious

!Mint Chocolate Chip

Yummy, my favorite.


And so forth.

I tried putting [[Ice Cream##Mint Chocolate Chip]] in a different
tiddler and the link was interpreted as a new tiddler instead of a
reference.
I'm running the latest and greatest version of tiddlywiki.

What am I missing?


On Oct 17, 1:33 pm, HansWobbe <hwo...@datafix.com> wrote:
> On Oct 17, 10:18 am, Eric Shulman <elsdes...@gmail.com> wrote:
>
> > Tweak #784: allow tiddler sections in TiddlyLinks to be used as anchor
> > points for intra-tiddler scrolling.
>
> > Usage: embed a TiddlyLink containing asectionreference, e.g.

Eric Shulman

unread,
Oct 20, 2008, 7:32:12 PM10/20/08
to TiddlyWiki
> I tried putting [[Ice Cream##Mint Chocolate Chip]] in a different
> tiddler and the link was interpreted as a new tiddler instead of a
> reference.
> I'm running the latest and greatest version of tiddlywiki.
>
> What am I missing?

The current release of TW (2.4.1) only recognizes
[[TiddlerName##SectionName]] as a parameter for the <<tiddler>> macro,
so that content from a section in one tiddler can be transcluded into
another tiddler. For example, if you define a tiddler like this:
[[SomeTiddler]]
!section1
This is section 1
!section 2
This is section 2
...
Then, in some other tiddler, you can write:
<<tiddler [[SomeTiddler##section1]]>>
which will be displayed as:
This is section 1

In order to use the [[TiddlerName##SectionName]] syntax as a *link*
that goes to a section of a tiddler, you need to install TiddlyTools'
CoreTweaks:
http://www.TiddlyTools.com/#CoreTweaks

Ty Zucker

unread,
Oct 21, 2008, 11:22:49 AM10/21/08
to TiddlyWiki
Ahh, great. Installed CoreTweaks and it works. Thanks much.

Now, next question. Is there a way to use a custom title with this
type of link?

[[SomeTiddler##Section1]] shows up as SomeTiddler##Section1 in screen
output of the tiddler. Functional, but not very pretty looking.

I know that normally you might use [[custom word|TiddlerName]] so that
"custom word" would be a link to TiddlerName.

I tried doing [[CustomName|SomeTiddler##Section1]] but that doesn't
seem to work and actually looks to open a file on my computer. As
shot in the dark I also tried [[CustomName|[[SomeTiddler##Section1]]]]
but as you might imagine, that was a no go either. :)




On Oct 20, 6:32 pm, Eric Shulman <elsdes...@gmail.com> wrote:
> > I tried putting [[Ice Cream##Mint Chocolate Chip]] in a different
> > tiddler and the link was interpreted as a new tiddler instead of a
> > reference.
> > I'm running the latest and greatest version of tiddlywiki.
>
> > What am I missing?
>
> The current release of TW (2.4.1) only recognizes
> [[TiddlerName##SectionName]] as a parameter for the <<tiddler>> macro,
> so that content from asectionin one tiddler can be transcluded into
> another tiddler.  For example, if you define a tiddler like this:
>    [[SomeTiddler]]
>    !section1
>    This issection1
>    !section2
>    This issection2
>    ...
> Then, in some other tiddler, you can write:
>    <<tiddler  [[SomeTiddler##section1]]>>
> which will be displayed as:
>    This issection1
>
> In order to use the [[TiddlerName##SectionName]] syntax as a *link*
> that goes to asectionof a tiddler, you need to install TiddlyTools'

Eric Shulman

unread,
Oct 21, 2008, 11:56:39 AM10/21/08
to TiddlyWiki
> [[SomeTiddler##Section1]] shows up as SomeTiddler##Section1 in screen
> output of the tiddler.  Functional, but not very pretty looking.
>
> I know that normally you might use [[custom word|TiddlerName]] so that
> "custom word" would be a link to TiddlerName.
>
> I tried doing [[CustomName|SomeTiddler##Section1]] but that doesn't
> seem to work and actually looks to open a file on my computer.

The problem is that the core's test for internal vs external
references thinks that every link containing a "#" symbol is
external. Of course, this *was* true before CoreTweaks #784, which
now permits *internal* links that contain a section separator (e.g.,
"##"). To account for this, I've updated the CoreTweak code so that
the core's isExternalLink() test function will now correctly recognize
"TiddlerName##SectionName" as an internal link, while still treating
"filename#anchor" as an external link.

Get the update here:
http://www.TiddlyTools.com/#CoreTweaks

After you get the update, you can then write:
[[text to show|TiddlerName##SectionName]]
to create an internal "PrettyTiddlyLink" that includes a section
reference.

FND

unread,
Oct 21, 2008, 12:07:50 PM10/21/08
to Tiddl...@googlegroups.com
Eric,

This is pretty neat!
Could you raise a ticket for this, preferably with a patch? We might
wanna incorporate this into the TW core.


-- F.

Eric Shulman

unread,
Oct 21, 2008, 12:14:08 PM10/21/08
to TiddlyWiki
> Could you raise a ticket for this, preferably with a patch? We might
> wanna incorporate this into the TW core.

As noted in CoreTweak #784, I have already created an open ticket for
this enhancement:

http://trac.tiddlywiki.org/ticket/784

-e

FND

unread,
Oct 21, 2008, 12:16:59 PM10/21/08
to Tiddl...@googlegroups.com
> As noted in CoreTweak #784, I have already created an open ticket for
> this enhancement

Oh wow, I had actually seen that in the Trac timeline a few days ago -
not sure why I didn't remember it now... My apologies.


-- F.

Michael.Tarnowski

unread,
Oct 22, 2008, 5:31:41 AM10/22/08
to TiddlyWiki
Eric,
the new release of your core tweaks solved my problem interpretation
for external links. With the first release I did, what Ty suggested:
specifiying a nice name in the link, like [[CustomName|
SomeTiddler##Section1]] - this was interpreted as external link.
Thus, no interference with other plugins.
Now everythinks works great! --- Terrific work, well done, Eric!

HAve a nice day.
Michael

kilucas

unread,
Oct 25, 2008, 8:28:01 PM10/25/08
to TiddlyWiki
I've applied CoreTweaks and linking to tiddler headings mostly works
fine. However if I have a tiddler called Triangle structured as:

!Area
!!Area of a right angle triangle
!!Area of an acute triangle
!!Area of an obtuse triangle

and I link to this with [[area of a triangle|Triangle##Area]], the
link takes me to !!Area of an obtuse triangle rather than to !Area.

I am using Bram Chen's HTMLArea as my editor but am using TW markup
for my headings.

Is there a way to force the link to go to !!Area perhaps?

Thanks

Kevin
> > -- F.- Hide quoted text -
>
> - Show quoted text -

kilucas

unread,
Oct 25, 2008, 8:48:34 PM10/25/08
to TiddlyWiki
I've mostly got CoreTweaks to manage links to tiddler headings and
thought I'd try links to sections. I placed the following in a tiddler
called Triangle:

/%
!Lastproof
!end Lastproof
%/

but both "Lastproof" and "end Lastproof" are displayed in the tiddler
as headings.

The first /% is not displayed but the final %/ is displayed like a
normal row.

I'm using Bram Chen's HTMLArea as my editor so do you think this
explains why the section name is visible perhaps?

Thanks

Kevin


On Oct 22, 10:31 am, "Michael.Tarnowski" <emt...@gmx.de> wrote:

BramChen

unread,
Oct 27, 2008, 12:29:26 PM10/27/08
to TiddlyWiki
Kevin

It will be fixed in next release of AsciiMath package.

On 10月26日, 上午8時48分, kilucas <kevin.lu...@concave.co.uk> wrote:
> I've mostly got CoreTweaks to manage links to tiddler headings and
> thought I'd try links to sections. I placed the following in a tiddler
> called Triangle:
>
> /%
> !Lastproof
> !end Lastproof
> %/
>
> but both "Lastproof" and "end Lastproof" are displayed in the tiddler
> as headings.
>
> The first /% is not displayed but the final %/ is displayed like a
> normal row.
>
> I'm using Bram Chen'sHTMLAreaas my editor so do you think this

kilucas

unread,
Oct 27, 2008, 1:31:10 PM10/27/08
to TiddlyWiki
Bram

Thanks for this. Do we know roughly when that'll be available perhaps?

Thanks

Kevin
> > > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages