#101 Can not handle filenames with hash sign.

open
nobody
None
5
2012-09-14
2009-01-04
Guido Leenders
No

When trying to generate natural docs documentation with Natural Docs 1.4, I have used a file with name:

itgen#attribute_rules.spc (Oracle PL/SQL).

ND correctly generates output, named itgen#attribute_rules-spc.html

However, the URL in the menu links to itgen#attribute_rules-spc.html, which is page 'itgen' with anchor 'attribute_rules-spc.html'

When you replace the hyperlink by:

itgen%23attribute_rules-spc.html

it works fine.

Discussion

  • Greg Valure
    Greg Valure
    2009-01-05

    Open [ND Dir]/Modules/NaturalDocs/Menu.pm and search for "if ($keyword eq 'file')". Change this:

    if ($keyword eq 'file')
    {
    my $flags = 0;

    if ($value =~ /^(.+)(([^(]+))$/)
    {
    my ($title, $file) = ($1, $2);

      $title =~ s/ +$//;
    

    to this:

    if ($keyword eq 'file')
    {
    my $flags = 0;
    my ($title, $file);

      if ($value =~ /^(.+)\(([^\(]+)\)$/)
         {
         ($title, $file) = ($1, $2);
         }
      elsif (defined $comment)
         {
         $value .= $comment;
    
         if ($value =~ /^([^\(\)]+?) ?\(([^\)]+)\) ?(?:#.*)?$/)
            {
            ($title, $file) = ($1, $2);
            };
         };
    
      if ($title)
         {
         $title =~ s/ +$//;
    

    This allows # characters in File: entries in Menu.txt using the hack I used to allow them in Link: entries. Now open [ND Dir]/Modules/NaturalDocs/Builder/HTMLBase.pm and search for:

    $relativeSourceFile =~ tr/ &?(){};/_/;

    Change it to:

    $relativeSourceFile =~ tr/ &?(){};#/_/;

    This adds # to the list of characters that get replaced with underscores in the output file name. Now run Natural Docs with -r to apply the changes everywhere.