wikilabs / plugins

TW5 plugins: https://wikilabs.github.io
30 stars 8 forks source link

Issue With Colon (:) In Parameter Passing ?? #74

Closed pmario closed 3 years ago

pmario commented 3 years ago

Issue With Colon (:) In Parameter Passing ??

I discovered in trial and error that the new method of passing parameters <glyph>:"<param>" works well EXCEPT for colons inside the quoted parameter string where it seems to break. That is an issue in use cases where you really need to be able to pass colons. Here is an example where I wanted to create a short-hand way to invoke a modal. It works well for Tiddlers with NO colons, but breaks for any Tiddler that has a colon in its name :-( ...

\customise braille=HLPcm _element=$macrocall $name=hlpModal _1=srcTid \define hlpModal(src,srcTid) <$button><$action-sendmessage $message="tm-modal" $param="$srcTid$"}/>$src$</$button> \end

⠒HLPcm:"You Want It Darker" Button Label⠶ WORKS

⠒HLPcm:"$:tt/hlp/wikitext-markup-ref" Button Label⠶ FAILS (colon problem)

Q: @pmario Is there anyway around this problem?

Originally posted by @TiddlyTweeter in https://github.com/wikilabs/plugins/discussions/62#discussioncomment-435710

pmario commented 3 years ago

@TiddlyTweeter ... I did a test with ::: in the pragma definition section and I did change the splitter for "local params" to :" see:

Have a very close look at line 1 ... What do you think?

\customize degree=blockquote _element="$macrocall" $name="test" _2="url" _1="citeTxt" _mode=block _endString="---" _params=":::external link:::https://example.com"

\define test(src, citeTxt, url)
<blockquote cite="""$url$""">
$src$
<cite><a class="tc-tiddlylink-external" href="""$url$""" rel="noopener noreferrer" target="_blank">$citeTxt$</a></cite>
</blockquote>
\end

°blockquote
the cite links to example.com, which is defined in the `_params` attribute in the pragma. The link text is also defined in the pragma
---

°blockquote:"a different link text"
the cite links to example.com

The "local" text wins over the pragma text
---

°blockquote:"new text - new link":"https://tiddlywiki.com"
Both params are defined with the cm-call
---
pmario commented 3 years ago

fixed - close

pmario commented 3 years ago

@TiddlyTweeter ... New version is uploaded! ... Other issues tagged "custom-markup" should follow. ... BUT they shouldn't contain breaking changes. .... I think ;)

TiddlyTweeter commented 3 years ago

... I did change the splitter for "local params" to :" ...

@TiddlyTweeter ... New version is uploaded! ... Other issues tagged "custom-markup" should follow. ... BUT they shouldn't contain breaking changes. .... I think ;)

Great! I'll actively test that today. TT

TiddlyTweeter commented 3 years ago

I have tested with the new method for passing _1 and _2 and it works WELL.

In my use cases I'm mainly dynamically passing attributes into tags. I did test how it handles quote marks. Since HTML attributes will take single quotes it is never likely to be an issue for me. I did test with quite extensive paramater passing into tags like this:

»CONSOLE:"fred='unreal: style1; real: style2.2' style='font-size:.85rem;width:28rem;margin:auto;'"

Works fine! Tx!