asciidoc-py / asciidoc-py2

Deprecated python2 implementation of AsciiDoc.py. See asciidoc-py/asciidoc-py for current work.
https://asciidoc.org/
GNU General Public License v2.0
466 stars 128 forks source link

How can I escape “/” and "?" characters in asciidoc for inline anchors? #138

Closed repomorphic closed 5 years ago

repomorphic commented 5 years ago

Hi there.I am trying to write a program that automatically converts my website to asciidoc one document. But I have problem with asciidoc anchors.When I add "/" character into the anchor my anchors break down.

For example.The following asciidoc code works:

[[en-USdocs...]]
*Tutorials:*
------------

The following asciidoc code does not work due to the / character.

[[en-US/docs...]]
*Tutorials:*
------------

The following asciidoc code does not work due to the ? character.

[[en-USdocs?=...]]
*Tutorials:*
------------

Is there a way to escape this “/” and "?" characters to allow the anchor work properly?And also that would be awesome If I can use special characters such as “/” and "?" in inline anchors.

elextr commented 5 years ago

There is no way of getting illegal characters in the anchor id.

The anchor has to be a valid ID in all targets and so is limited to:

  1. alphanumerics
  2. underscore (_)
  3. colon(:)
  4. dot (.) and dash (-) anywhere other than the start of the ID

I suggest your conversion script replace the illegal characters with underscore.

repomorphic commented 5 years ago

Thanks. I have written a regex for replacing those illegal characters but I am wondering why these characters are illegal when I can use these characters in HTML id.

elextr commented 5 years ago

Because targets can still be html 4.