[pmwiki-users] Custom block link : <a href...>short html code rather than strict text link</a>

ABClf languefrancaise at gmail.com
Sat Oct 16 14:45:22 PDT 2021


Adopted. Thank you. PmWiki can do so many things in so many ways.

Le sam. 16 oct. 2021 à 22:53, Petko Yotov <5ko at 5ko.fr> a écrit :
>
> Also this:
>    {{=$FullName}$:vedette}
>
> can be replaced with:
>    {=$:vedette}
>
> Petko
>
> On 16/10/2021 22:46, ABClf wrote:
> > Well, thank you, you are right,
> > [[my link| %h5% Title %% Some text]]
> > is the way to go for me.
> > It does allow pretty verbose command and is good for clickable list
> > item
> >
> > [[#listemots1]]
> > %apply=link class="class"%[[{=$FullName}|%h5%{{=$FullName}$:vedette}%%
> >  %rfloat badge%{=$:attestation}%%\\
> > ''{=$:sens}'']]%%
> > [[#listemots1end]]
> >
> > Tested and adopted.
> >
> > Le sam. 16 oct. 2021 à 10:14, Petko Yotov <5ko at 5ko.fr> a écrit :
> >>
> >> This is not a WikiLink markup so it doesn't convert pagenames to URLs.
> >>
> >> In the href="..." attribute you need to use the "page URL", not the
> >> "page name":
> >>
> >>    (:blocklink href="{=$PageUrl}" :)
> >>
> >>
> >> Note that the current markup allows for the link href to include
> >> JavaScript code, e.g.:
> >>
> >>    (:blocklink href="javascript:alert(document.cookie)":)
> >>
> >> which may allow editors to insert malicious code. So if untrusted
> >> people
> >> can edit the wiki, you shouldn't enable this markup in its current
> >> definition.
> >>
> >> Petko
> >>
> >> On 16/10/2021 04:18, ABClf wrote:
> >> > Playing with last solution ; almost working for my needs, excepted the
> >> > blocklink output which gives me unexpected result :
> >> > my pagelist is on GroupA, printing out a list of blocklinks linking to
> >> > :
> >> > https://www.mysite.fr/GroupA/GroupB.Page1
> >> > where expected result is :
> >> > http://www.mysite.fr/GroupB.Page1
> >> >
> >> > In my own case, I test the blocklink markup in localtemplates,
> >> > defining a new format, like that (code shortened) :
> >> > [[#listesynonyme]]
> >> > (:blocklink href={=$FullName} class="list-group-item":)
> >> > {{=$FullName}$:vedette}
> >> > (:blocklinkend:)
> >> > [[#listesynonymeend]]
> >> >
> >> > then, in group Synonyme, I have a pagelist using quoted format ; which
> >> > gives me a list of blocks, linking as expected, but pointing to
> >> > https://www.mysite.fr/Synonyme/Bob.15887 where
> >> > https://www.mysite.fr/Bob.15887 is expected.
> >> >
> >> > To get rid of this Group issue, one working solution is to write :
> >> > (:blocklink href="https://www.mysite.fr/Bob/{=$Name}"
> >> > class="list-group-item":)
> >> >
> >> > Not sure if I'm doing mistake, if the code works as expected or if it
> >> > needs to be a little improved in how to handle the Group part.
> >> >
> >> > Thank you,
> >> > Gilles.
> >> >
> >> > Le ven. 15 oct. 2021 à 23:45, ABClf <languefrancaise at gmail.com> a écrit
> >> > :
> >> >>
> >> >> Thank you Petko for your top notch answer ;
> >> >> I'm going to try the last one soon.
> >> >> Gilles.
> >> >>
> >> >> Le ven. 15 oct. 2021 à 18:13, Petko Yotov <5ko at 5ko.fr> a écrit :
> >> >> >
> >> >> > Indeed, this is not possible with core PmWiki markup.
> >> >> >
> >> >> > In the past, the HTML standards required links to be inline elements
> >> >> > which could not contain block-level elements like paragraphs or
> >> >> > headings.
> >> >> >
> >> >> > So in PmWiki markup, you can have 2 links, one in the heading, the other
> >> >> > in the text like this:
> >> >> >
> >> >> > !!!!! [[my link|Title]]
> >> >> > [[my link|Some text]]
> >> >> >
> >> >> >
> >> >> > Or you can have a specially formatted and styled link text like this:
> >> >> >
> >> >> > [[my link| %h5% Title %% Some text]]
> >> >> >
> >> >> > then you style .h5 in your pub/css/local.css, for example:
> >> >> >
> >> >> > .h5 {
> >> >> >    display: block;
> >> >> >    font-weight: bold;
> >> >> >    font-size: 105%;
> >> >> > }
> >> >> >
> >> >> > This will work well in <ul> lists for menus and navigation. I'd go with
> >> >> > this solution id I needed the feature.
> >> >> >
> >> >> >
> >> >> > Finally, and as usual, you can define your own markup rule to do this.
> >> >> > For example:
> >> >> >
> >> >> >    Markup('blocklink', 'directives',
> >> >> >      '/^\\(:blocklink(end|)(?: (.*?))?:\\)/',
> >> >> >      'FmtBlockLink');
> >> >> >    function FmtBlockLink($m) {
> >> >> >      if($m[1]) return "<:block></a>";
> >> >> >      return "<:block>".Keep("<a ".PQA($m[2]).">");
> >> >> >    }
> >> >> >
> >> >> > Then in a wiki page, you type:
> >> >> >
> >> >> > (:blocklink href="https://www.pmwiki.org" class=myclass:)
> >> >> > !!!!! Title
> >> >> > Some text
> >> >> > (:blocklinkend:)
> >> >> >
> >> >> >
> >> >> > Petko
> >> >> >
> >> >> >
> >> >> > On 15/10/2021 14:09, ABClf wrote:
> >> >> > > Something I don't know how to do with pmwiki markup, if doable,
> >> >> > > is having an html output like that :
> >> >> > >
> >> >> > > <a href="my link" class="myclass">
> >> >> > >       <h5>Title</h5>
> >> >> > >       <p>Some text</p>
> >> >> > >   </a>
> >> >> > >
> >> >> > > (in order to have the full block working as a link, for easy click in
> >> >> > > bootstrap-like list, and benefit of link's style).
> >> >> > >
> >> >> > > In other words, have some html code embedded in <a> and </a> (not the
> >> >> > > sole text link).
> >> >> > > I believe I can not use regular [[linkadress|linktext]] markup for
> >> >> > > doing that.
> >> >> > >
> >> >> > > Thank you,
> >> >> > > Gilles.



More information about the pmwiki-users mailing list