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

Reply via email to