I have tiddler mymacros tagged $:/tags/Macro
and defining the pdf
function and the p
macro:
\function pdf() [[$:/temp/$1$.pdf]substitute<currentTiddler>]
\define p()
<%if [<pdf>get[state]else[missing]match[show]] %>
<$button>Close
<$action-setfield $tiddler=<<pdf>> state=hide/>
</$button>
<$transclude $tiddler=<<pdf>> $mode=block/>
<%else%>
<$button>Open PDF
<$action-setfield $tiddler=<<pdf>> state=show type="application/pdf" _canonical_uri={{{ [[https://twtalk.sirv.com/$1$.pdf]substitute<currentTiddler>] }}}/>
</$button>
<%endif%>
\end p
Then I have two normal tiddlers having as title the filename of a pdf file, but without the pdf extension. They contain the OCR text extracted from the pdf. After the OCR text I add a blank line and the call of the p macro: <<p>>
. When I open the tiddler, I see the OCR text followed by a blank line and the button Open PDF. When I click the button, the pdf file is retrieved from the sirv.com site and displayed in full width below the text. That is ok. I then wanted to avoid to have to add the call of the p
macro on every pdf tiddler, so I created a tiddler tagged $:/tags/ViewTemplate
and added <<p>>
as text. I also removed the p macro from one of the pdf tiddlers, to see whether the template works. Well, it worked, but partially: the button Open PDF was there, but when clicked it opened the pdf file in a small textarea, not filling the available width. In addition, this textarea was immediately following the button Close on the same line, instead of appearing after a newline as it was before. So I thought the problem was that the template tiddler parsed its content (<<p>>
) in inline mode instead of in block mode. So I tried to replace <<p>>
in the template with <$transclude $variable=p $mode=block/>
but with no difference. So I am forced to append a call of macro p
to all pdf tiddlers and abandon the idea of a view template. Any idea what the problem is?
A working example of the problem is available at https://twtalk.tiddlyhost.com