Transclusion context or avoiding wikify

I have a macro that ultimately transclude the content of a tiddlers.

If that tiddler is complex, and contains wikicode, it may fails. For instance, it does not produce a dotted liste with content such as

shoping list:

* sugar
* apple
* flour

A working but slow solution is to use the wikify widget. But this is slow. Although I’m sure I was already told about a similar problem, I don’t remember any solution and I can’t find a topic aout just that kind of need within this site.

Any way, here is my macro:

\define insert(codeInfo, consigne)
  <$let display = {{{
		[[$:/user/data/info/]addsuffix[$codeInfo$]is[tiddler]get[text]]
		:else[[$consigne$]!is[blank]addprefix[<span class="consigne">]addsuffix[</span>]]
		:else[[<span class="missing">NO INFORMATION about $codeInfo$!</span>]]
	}}}>
		<$wikify output=html name=wiki text=<<display>>><<wiki>></$wikify>
	</$let>
\end

The use is simple: <<insert someTopic>>.

Notice than even with wikify, I have a problem: To get the dotted list, I have to be in block mode, but when I only have a few words, it should be in inline mode. This issue can be fixed by different solutions. But if there was a method where I would not have to elaborate such a solution, then it would be great!

1 Like

Mostly If you transclude in block mode it will be in block mode it you transclude in inline mode it will be inline and not wikify.

  • The first responce is to use <$transclude tiddler=tiddlername mode=block/>
  • Sometime just having a blank line before the transclude is enough to put it in block mode
<$list ...

{{||template}}

{{template}}

</$list>

eg; this is broken

<hr>
{{||transcludeme}}

This is not

<hr>

{{||transcludeme}}
1 Like

thank you @TW_Tones . I I grasp your explication clearly, the context cannot be set FROM the transcluded content, but can only be determined by the transcluding content (one way or another).

For my use case, this mean the transcluding must examine the to-be-transcluded content to set the mode for the transclusion. So far, I’ve decided that a content with one logical line should be treated as inline and any other content as block. Would you agree with that?

Not nesasarily, the transcluded content could start with an empty line, or contain a html “div” which is a block and you can add . There are quite a few options here.

  • Add a css style=“display: block;”
  • Create a class .myclass {display: block;}

If you had a minimal example eg a transclude statement and a “simple” tiddler it is transcluding, that is not working for you, it would be helpful.

I suppose this points out that exploring the issues with block and inline cant be avoided with tiddlywiki because it depends on HTML, and tiddlywiki’s parsing trys to guess.

example of use:

This documentsis about the architecture of the application <<insert application>> and describes it in great details.

Here an inline context is supposed.

The next one would surely be a block context:

We can illistrate this with the following diagram:

<<insert diagram "draw a diagram of fluxes">>

And here is my macro as of now.

\procedure insert(codeInfo, consigne, example)
  \function .sample() [<div class="example">\n$(example)$\n</div>\n]substitute[]dump[illustrated example]]
  <$let display = {{{
		[[$:/user/data/info/]addsuffix<codeInfo>is[tiddler]get[text]]
		:else[<consigne>!is[blank]addprefix[<span class="consigne">]addsuffix[</span>]]
		:else[[<span class="missing">PAS D'INFORMATION sur «&nbsp;$(codeInfo)$&nbsp;»&nbsp;!</span>]substitute[]]
	}}}
	  newline = {{{ [charcode[10]] }}}
	  mode = {{{ [<display>split<newline>!is[blank]count[]match[1]then[inline]else[block]] }}}
	  illustration = {{{ [<example>!is[blank]then<.sample>] }}}
	>
		<$wikify output=html mode=<<mode>> name=wiki text=<<display>>><<wiki>><<illustration>></$wikify>
	</$let>
\end

The first change I would make is to move all the html you are including in your filter into variables or macros so there is no risk of unwanted outcomes due to the content of the html. It would also make it easier to read the filters.

In your example I don’t see a transclusion, is this your attempt at using wikify because you could not use a transclusion?

  • This forces me/us to reverse engineer to help you, which is hard work and prone to errors.

I really would encourage you to stop working on the specific code and try and create a minimal example of “Transclusion context or avoiding wikify” that demonstrates the problem.

  • When I do this I often find my own answer just trying to prepare the question.
  • If I don’t, it is much easier for people to help, and the answer less likely to confuse me and future readers.

@TW_Tones I shall try what you tell me to do. And report there what I’ll found out. The idea of using variables or function for html bits is a very nice one indeed.