docbook-apps

  • 1.  webhelp javascript error

    Posted 03-19-2014 05:30
    I have encountered the following javascript error in webhelp:

    Uncaught Error: Syntax error, unrecognized expression: [name=section4.id]

    This only happens when I have a section which is four levels deep or more
    and I have given the section a manually generated id (i.e. it is a section
    to which I want to refer via an xref) which contains a dot(.) character.

    The error occurs when I click on the section in question in the navigation
    sidebar.

    My browser reports that the problem is in:

    jquery-1.7.2.min.js:3

    This is a docbook sample which demonstrates the problem:


    <book id="DocId" xmlns="http://docbook.org/ns/docbook">


    <chapter>











    <para>And finally some text.</para>







    <para>And some more text.</para>




    </chapter>
    </book>

    It doesn't seem to like manually generated 'id's with the dot character in
    them.

    Has anyone else found this? Is this a limitation of this format? Are there
    any other characters which are not permitted? Is it confusing the string
    literal for a regexp?

    Nat



  • 2.  Re: [docbook-apps] webhelp javascript error

    Posted 03-19-2014 09:21
    I believe this is a bug. I was able to re-produce the error with the
    docbook sample you have provided. We have introduced following code segment
    [1] to main.js in order to fix an issue with the page-scroll-down when
    clicking on url anchors (the urls with #).

    The culprit is the jquery function, $('[name=' + this.hash.slice(1) +']').
    In your case, this.hash.slice(1) return section4.id, but jquery fails to
    process it.

    One option you can do is to get rid of this code, and implement the
    alternative as suggested in [2].

    [1]
    // When you click on a link to an anchor, scroll down
    // 105 px to cope with the fact that the banner
    // hides the top 95px or so of the page.
    // This code deals with the problem when
    // you click on a link within a page.
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') ==
    this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
    var $target = $(this.hash);
    $target = $target.length && $target
    || $('[name=' + this.hash.slice(1) +']');
    if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv"
    || this.hash == "") && $target.length) {
    var targetOffset = $target.offset().top - 120;
    $('html,body')
    .animate({scrollTop: targetOffset}, 200);
    return false;
    }
    }
    });


    [2] http://sourceforge.net/p/docbook/bugs/1219/




    On Wed, Mar 19, 2014 at 11:00 AM, natk <nkershaw@gmail.com> wrote:

    > I have encountered the following javascript error in webhelp:
    >
    > Uncaught Error: Syntax error, unrecognized expression: [name=section4.id]
    >
    > This only happens when I have a section which is four levels deep or more
    > and I have given the section a manually generated id (i.e. it is a section
    > to which I want to refer via an xref) which contains a dot(.) character.
    >
    > The error occurs when I click on the section in question in the navigation
    > sidebar.
    >
    > My browser reports that the problem is in:
    >
    > jquery-1.7.2.min.js:3
    >
    > This is a docbook sample which demonstrates the problem:
    >
    >
    > <book id="DocId" xmlns="http://docbook.org/ns/docbook">
    >
    >
    > <chapter>
    >

    >

    >

    >

    >

    >

    >

    >
    >

    >

    >

    > <para>And finally some text.</para>
    >

    >

    >

    >
    >

    >

    >

    > <para>And some more text.</para>
    >

    >

    >

    >

    > </chapter>
    > </book>
    >
    > It doesn't seem to like manually generated 'id's with the dot character in
    > them.
    >
    > Has anyone else found this? Is this a limitation of this format? Are there
    > any other characters which are not permitted? Is it confusing the string
    > literal for a regexp?
    >
    > Nat
    >



    --
    ~~~*******'''''''''''''*******~~~
    *Kasun Gajasinghe*
    Software Engineer; WSO2 Inc.; http://wso2.com,
    *linked-in: *http://lk.linkedin.com/in/gajasinghe
    *blog: **http://blog.kasunbg.org* <http://blog.kasunbg.org/>


    *twitter: **http://twitter.com/kasunbg* <http://twitter.com/kasunbg>



  • 3.  Re: [docbook-apps] webhelp javascript error

    Posted 03-20-2014 01:14
    Thanks for that. I don't really want to modify the js, as that is going to
    create a divergence between the released version and my local version. Are
    there any plans to fix this?

    Nat


    On Wed, Mar 19, 2014 at 8:20 PM, Kasun Gajasinghe <kasunbg@gmail.com> wrote:

    > I believe this is a bug. I was able to re-produce the error with the
    > docbook sample you have provided. We have introduced following code segment
    > [1] to main.js in order to fix an issue with the page-scroll-down when
    > clicking on url anchors (the urls with #).
    >
    > The culprit is the jquery function, $('[name=' + this.hash.slice(1) +']').
    > In your case, this.hash.slice(1) return section4.id, but jquery fails to
    > process it.
    >
    > One option you can do is to get rid of this code, and implement the
    > alternative as suggested in [2].
    >
    > [1]
    > // When you click on a link to an anchor, scroll down
    > // 105 px to cope with the fact that the banner
    > // hides the top 95px or so of the page.
    > // This code deals with the problem when
    > // you click on a link within a page.
    > $('a[href*=#]').click(function() {
    > if (location.pathname.replace(/^\//,'') ==
    > this.pathname.replace(/^\//,'')
    > && location.hostname == this.hostname) {
    > var $target = $(this.hash);
    > $target = $target.length && $target
    > || $('[name=' + this.hash.slice(1) +']');
    > if (!(this.hash == "#searchDiv" || this.hash == "#treeDiv"
    > || this.hash == "") && $target.length) {
    > var targetOffset = $target.offset().top - 120;
    > $('html,body')
    > .animate({scrollTop: targetOffset}, 200);
    > return false;
    > }
    > }
    > });
    >
    >
    > [2] http://sourceforge.net/p/docbook/bugs/1219/
    >
    >
    >
    >
    > On Wed, Mar 19, 2014 at 11:00 AM, natk <nkershaw@gmail.com> wrote:
    >
    >> I have encountered the following javascript error in webhelp:
    >>
    >> Uncaught Error: Syntax error, unrecognized expression: [name=section4.id]
    >>
    >> This only happens when I have a section which is four levels deep or more
    >> and I have given the section a manually generated id (i.e. it is a section
    >> to which I want to refer via an xref) which contains a dot(.) character.
    >>
    >> The error occurs when I click on the section in question in the
    >> navigation sidebar.
    >>
    >> My browser reports that the problem is in:
    >>
    >> jquery-1.7.2.min.js:3
    >>
    >> This is a docbook sample which demonstrates the problem:
    >>
    >>
    >> <book id="DocId" xmlns="http://docbook.org/ns/docbook">
    >>
    >>
    >> <chapter>
    >>

    >>

    >>

    >>

    >>

    >>

    >>

    >>
    >>

    >>

    >>

    >> <para>And finally some text.</para>
    >>

    >>

    >>

    >>
    >>

    >>

    >>

    >> <para>And some more text.</para>
    >>

    >>

    >>

    >>

    >> </chapter>
    >> </book>
    >>
    >> It doesn't seem to like manually generated 'id's with the dot character
    >> in them.
    >>
    >> Has anyone else found this? Is this a limitation of this format? Are
    >> there any other characters which are not permitted? Is it confusing the
    >> string literal for a regexp?
    >>
    >> Nat
    >>
    >
    >
    >
    > --
    > ~~~*******'''''''''''''*******~~~
    > *Kasun Gajasinghe*
    > Software Engineer; WSO2 Inc.; http://wso2.com,
    > *linked-in: *http://lk.linkedin.com/in/gajasinghe
    > *blog: **http://blog.kasunbg.org* <http://blog.kasunbg.org/>
    >
    >
    > *twitter: **http://twitter.com/kasunbg* <http://twitter.com/kasunbg>
    >