Hi,

I would like to resolve this issue:
Automatic section anchors: Each section title should automatically generate
an implicit hyperlink target (aka, anchor) pointing to the section. The
text of the hyperlink target (the "reference name") is the same as that of
the section title.

however since I'm not familiar with Pillar I don't know how acceptable this
solution could be

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PRHTMLWriter>>visitHeader: aHeader
| level |
level := self configuration headingLevelOffset + aHeader level. "h1 to h7
exist."
level := level min: 7 max: 1.
canvas tag
name: 'h' , level asString;
parameterAt: 'id' put: (self createIdForHeader: aHeader); "<<< addition"
with: [
self writeCounterForHeader: aHeader.
super visitHeader: aHeader ].
canvas newLine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
createIdForHeader: aHeader
| id |
id := aHeader text.
id := id asLowercase.
"replace banned characters with dashes"
id := '[^0-9a-z\-]' asRegex copy: id replacingMatchesWith: '-'.
"merge multiple dashes"
id := '-{2,}' asRegex copy: id replacingMatchesWith: '-'.
"remove dashes from beginning/end of the id"
id := '^-|-$' asRegex copy: id replacingMatchesWith: ''.
^ id
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Strictly speaking HTML 5 is very permissive with the value of id, but the
question is whether we really want to permit everything. E.g. unicode in
url is always asking for trouble.

Thanks,
Peter

Reply via email to