Macro JS Macro formatting difference

110 views
Skip to first unread message

James Anderson

unread,
Mar 30, 2015, 6:49:10 PM3/30/15
to tiddl...@googlegroups.com
I came across this today while working on some simple YT macros so I can link to specific times within videos on a statically exported blog.


The first video is generated via a JS macro and the 2nd via a plain macro defined with a global scope. the difference in size (at least on Chrome and IE) is because the JS macros output is wrapped in <p> tags. I can probably do some CSS hacking to fix this but is there a way of stopping the <p> tags from being generated in this case?

Thanks,
James

Jeremy Ruston

unread,
Mar 31, 2015, 7:26:54 AM3/31/15
to TiddlyWiki
Hi James

The <p> tags are being generated because the content returned by the JS macro is being parsed in "block" mode, and so the parser is looking for double line breaks to separate paragraphs.

There are several things you may be able to do to fix this but the easiest would be to explicitly call the JS macro with the <$macrocall> widget and specify mode="inline". Would that work here?

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

James Anderson

unread,
Mar 31, 2015, 7:33:53 AM3/31/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
Thanks Jeremy, 

That would work but it's a bit more verbose that I would like. I guess this could be further wrapped in a plain tiddler macro? My setup is to have <<ytif>> to set up the iframe and you can pass the video code or have it come from a field value. CSS trickery seems like an easy solution if a 2nd layer of macro doesn't work, but are the <p> tags likely to change in the future?

James

Jeremy Ruston

unread,
Mar 31, 2015, 7:41:18 AM3/31/15
to James Anderson, TiddlyWiki
Hi James


That would work but it's a bit more verbose that I would like. I guess this could be further wrapped in a plain tiddler macro? My setup is to have <<ytif>> to set up the iframe and you can pass the video code or have it come from a field value. CSS trickery seems like an easy solution if a 2nd layer of macro doesn't work, but are the <p> tags likely to change in the future?

Ah, how are you calling the macro? If the macro call starts at the beginning of a block, and is followed by two line breaks, then the macro content will be parsed in block mode, otherwise in inline mode. So you can force inline mode by ensuring that the macro call doesn't look like a block, for instance by following it with a comment:

<<ytif>><!-- Force inline mode -->

Best wishes

Jeremy

James Anderson

unread,
Mar 31, 2015, 8:43:01 AM3/31/15
to tiddl...@googlegroups.com, james.w....@gmail.com, jeremy...@gmail.com
Thanks Jeremy that is good to know!

James

James Anderson

unread,
Apr 1, 2015, 4:39:48 PM4/1/15
to tiddl...@googlegroups.com, james.w....@gmail.com, jeremy...@gmail.com
I can't seem to get what you mentioned to work, I've uploaded my attempts here. 


I would ideally like the call to <<ytif>> to display with the same format as the [[No P]] Tiddler or the first video from the "ytv" Macro. Would you mind taking a look and seeing what i am doing wrong?

Regards,
James

Jeremy Ruston

unread,
Apr 2, 2015, 9:50:52 AM4/2/15
to James Anderson, TiddlyWiki
Hi James

I would ideally like the call to <<ytif>> to display with the same format as the [[No P]] Tiddler or the first video from the "ytv" Macro. Would you mind taking a look and seeing what i am doing wrong?

After quite a bit of experimentation I found the fix. It's probably a bug, but in order for the iframe that is output by your JS macro to be recognised as a block mode construct you need to follow it with a double line break (ie \n\n), thus:

    var output = ["<iframe class='ytif' name='",name,"' frameborder='0' theme=light  src='http://www.youtube.com/embed/", code, "?start=", start,"&theme=dark&color=red&wmode=opaque' allowfullscreen/>\n\n"];

Best wishes

Jeremy.

James Anderson

unread,
Apr 2, 2015, 3:54:51 PM4/2/15
to tiddl...@googlegroups.com, james.w....@gmail.com, jeremy...@gmail.com
Thank you so much Jeremy, hopefully this didn't take up too much of your time.

Regards,
James

Jeremy Ruston

unread,
Apr 3, 2015, 7:12:54 AM4/3/15
to James Anderson, TiddlyWiki
Hi James

On Thu, Apr 2, 2015 at 8:54 PM, James Anderson <james.w....@gmail.com> wrote:
Thank you so much Jeremy, hopefully this didn't take up too much of your time.

Not at all, it was quite interesting and helped me think about the problems with paragraph handling.

Best wishes

Jeremy
Reply all
Reply to author
Forward
0 new messages