I don't seem to have received any replies (unsubscribed? server issue?) but (thanks to Mia's blog) I found the archive and saw plenty of replies, so, here are my answers:
Alex: > > So, my first idea would be, instead of adding complexity to the wiki syntax > > to specify ID values, to use the value of the heading as the value of the > > ID > > and output this: > > > > <h2 id="My heading">My heading</h2> > > > > That does not guarantee that we have unique ID values, which is a > > requirement > > in HTML, > > Is there a reason not to use <h2 name="..." ...> instead? name is not an allowed attribute for headings in HTML: https://www.w3.org/TR/html401/struct/global.html#h-7.5.5 Thomas: > > (prin "<" C D " id=\"h" D "-" E "\">") > > which would give us: > > <h2 id="h2-My heading">My heading</h2> > > What if the value of E is something like > > "><script>alert('xss');</script> You mean n{<script>alert('xss');</script>}? I don't understand Alex’ answer: > In final code this would be written as (ht:Prin E) but I guess he is right :) JC > On Sep 11, 2021, at 18:11, Jean-Christophe Helary > <li...@traduction-libre.org> wrote: > > I'm just exploring my very first lines of picolisp code, and it is going to > take some time to get something done... :) > > I was mentioning a few days ago that the wiki would benefit from having links > to internal IDs, so as to create a formal table of contents, or just as a way > to link to (relatively) arbitrary places in other pages. > > The wiki html seems to be generated by _render, which is defined this way: > > (de _render (C D) > (prin "<" C D ">") > (recurse T) > (prin "</" C D ">") ) > > for the code for html headers is: > > (case C > (("1" "2" "3" "4" "5" "6") # Heading > (_render "h" C) > (prinl) > (skip) ) > > with C being equal to the number that was used to define the header (wiki > syntax: n{Heading}). > > The only case where _render uses 2 arguments is for headers. > > So, my first idea would be, instead of adding complexity to the wiki syntax > to specify ID values, to use the value of the heading as the value of the ID > and output this: > > <h2 id="My heading">My heading</h2> > > That does not guarantee that we have unique ID values, which is a requirement > in HTML, in case the author has the idea/requirement to actually create > headers with the same content... But we can reasonably expect that the author > won't create headers with the same tag value and the same contents unless by > mistake. So maybe adding the header tag to the ID could reduce chances to > have non-unique IDs... > > So basically, what we'd need is: > > # I'm not clear why the internal variables are labeled C and D, so maybe I'm > missing something here, that may not be arbitrary, but I can't tell... > > (de _render (C D E) > (prin "<" C D " id=\"h" D "-" E "\">") > (recurse T) > (prin "</" C D ">") ) > > which would give us: > > <h2 id="h2-My heading">My heading</h2> > > and then, the only thing I need to do (hehehe) is to actually make sure that > E actually gets the value of the heading. > > Am I heading (no pun intended) in the right direction ? > > -- > Jean-Christophe Helary @brandelune > https://mac4translators.blogspot.com > https://sr.ht/~brandelune/omegat-as-a-book/ -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe