weixin_39631667
weixin_39631667
2021-01-03 06:24

netscape.javascript.JSException: TypeError: 'undefined' is not an object (evaluating '$scope.DocBook5Converter.$new'

In latest version of asciidoctor, im getting;

netscape.javascript.JSException: TypeError: 'undefined' is not an object (evaluating '$scope.DocBook5Converter.$new'

I'm using Nashorn JS Engine

该提问来源于开源项目:asciidoctor/asciidoctor.js

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

31条回答

  • weixin_39631667 weixin_39631667 3月前

    I've append :doctype: book attribute and rendered again with asciidoctor.

    
    <?xml version="1.0" encoding="UTF-8"?>
    <?asciidoc-toc ?>
    <?asciidoc-numbered ?>
    <book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" lang="tr">
    <info>
    <title>Book title</title>
    <date>2014-08-21</date>
    <author>
    <personname>
    <firstname>Rahman</firstname>
    <surname>Usta</surname>
    </personname>
    </author>
    <authorinitials>RU</authorinitials>
    </info>
    <preface>
    <title></title>
    <simpara>
    Unresolved directive in preface.asc - include::01-one.asc[]
    Unresolved directive in preface.asc - include::02-two.asc[]
    Unresolved directive in preface.asc - include::03-three.asc[]
    </simpara>
    </preface>
    </book>
    

    But, why preface element brokes PDF generation?

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    I've detected that when rendering with asciidoctor, <preface> and <title></title> after it removed concluded result. I must remove it manually.

    In asciidoctor.js, im rendering each included parts and combining them single xml output. When following this path, preface is not removed normally. I will remove it AsciidocFX manually.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    Keep in mind that the preface issue should be handled upstream in Asciidoctor. Thanks!

    点赞 评论 复制链接分享
  • weixin_39997089 weixin_39997089 3月前

    Hi yes I have a repo where I played with Rhino and Nashorn. Currently there are some problems with Nashorn, it seems that during the integration between AsciidoctorJs and AsciidoctorJ using Nashorn I have found a bug in Nashorn. There is one workaround that is using eval method in any case without using getInterface approach. Probably this weekend I will integrate the workaround into my repo and if it works then I will create a branch on asciidoctorJ with asciidoctorjs integrated.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    Excellent! Aha, so this is the same issue you mentioned on the list. I wasn't sure, but now it's clear. Thanks for clarifying.

    I'll definitely lend a hand as soon as I can. I'm still focused on getting Asciidoctor core ready for the 1.5.0 release. I'm confident we'll have this working in Nashorn in no time.

    点赞 评论 复制链接分享
  • weixin_39997089 weixin_39997089 3月前

    Yes I have a workaround so at least I will be able to release it with a workaround on it. But of course I would like to release it with the final version, but if it cannot be then workaround on the way :)

    2014-07-30 11:56 GMT+02:00 Dan Allen notifications.com:

    Excellent! Aha, so this is the same issue you mentioned on the list. I wasn't sure, but now it's clear. Thanks for clarifying.

    I'll definitely lend a hand as soon as I can. I'm still focused on getting Asciidoctor core ready for the 1.5.0 release. I'm confident we'll have this working in Nashorn in no time.

    — Reply to this email directly or view it on GitHub https://github.com/asciidoctor/asciidoctor.js/issues/40#issuecomment-50595461 .

    +----------------------------------------------------------+ Alex Soto Bueno - Computer Engineer www.lordofthejars.com +----------------------------------------------------------+

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    I'm waiting for this workaround :) im using older versions in https://github.com/rahmanusta/AsciidocFX, it works well.

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    When this problem will be solved? :=)

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    Maybe it has something to do with the fact that we aren't registering the DocBook 5 converter when compiling Asciidoctor.js :) I'm okay with doing it, but I think we should compile it in to a separate JavaScript file (asciidoctor-docbook5.js) and only bundle it in asciidoctor-all.js since it's used much less often in a JavaScript environment.

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    I see, but AsciidocFX need it :)

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    I hear you loud and clear :) We'll make it happen, just saying that we didn't need it before and cut the converter to save file size.

    and we need to determine how we want to compile and ship DocBook support for Asciidoctor.js. We can treat it as a separate load path in the build, just like how we convert the extensions.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    I'm curious, for what purpose are you creating DocBook in AsciidocFX? Understanding the use case will also help us test it.

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    very thanks Dan, in AsciidocFX im converting asciidoc book to single docbook file by using asciidoctor.js with Nashorn. And generating PDF book from it by using asciidoctor-fopub. I can use AsciidoctorJ with ruby port but Nashorn and Asciidoctorjs comes me more lightweight. Because of file size and Nashorn's seamless integrity.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    That makes sense. Thanks for clarifying!

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    Thanks from me :)

    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    we need to determine how we want to compile and ship DocBook support for Asciidoctor.js. We can treat it as a separate load path in the build, just like how we convert the extensions.

    Yes we can treat it like that, and then merge it with asciidoctor-core.js

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    I'd like to keep it out of asciidoctor-core.js to keep the filesize down. I'm okay with putting it in asciidoctor-all.js, but ideally we just keep it separate.

    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    Ok, so an asciidoctor-converters.js (with only Docbook5 in a first time) could be a good solution ?

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    asciidoctor-docbook5 is more good, i think.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    I agree. Just keep it simple for now as asciidoctor-docbook.js (or asciidoctor-docbook-converter.js) (include both DocBook 4.5 and 5 since it's not much extra code).

    -Dan

    On Wed, Aug 20, 2014 at 1:26 PM, Rahman Usta notifications.com wrote:

    asciidoctor-docbook5 is more good, i think.

    — Reply to this email directly or view it on GitHub https://github.com/asciidoctor/asciidoctor.js/issues/40#issuecomment-52830704 .

    Dan Allen | http://google.com/profiles/dan.j.allen

    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    can you try with my fork : https://github.com/anthonny/asciidoctor.js/tree/docbook-backend

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    i've tried it with asciidoctor-all.js. Then, im getting JSException: TypeError: 'undefined' is not a function (evaluating 'val.$rpartition(": ")') this.

    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    Can you give me the file and attributes with which you tried ?

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    It's caused when using : character in title . For example;

    [[jsr-356-java-api-for-websocket]] == JSR 356: Java API for WebSocket

    WebSocket protokolü (RFC 6455) IETF kuruluşu tarafından standardize edilmiştir. WebSocket protokolünü destek sunmak isteyen ortamlar ise bu standarda dayanarak kendi API ve şartnamelerini geliştirmektedirler.

    Another problem is that, images surrounded with formalpara instead of figure element.

    
    <formalpara>
    <title>WebSocket bağlantı el sıkışması (Handshake)</title>
    <para><inlinemediaobject>
    <imageobject>
    <imagedata fileref="images/image001.png"></imagedata>
    </imageobject>
    <textobject><phrase>image001.png</phrase></textobject>
    </inlinemediaobject></para>
    </formalpara>
    `
    
    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    I'll look this evening, i will compare asciidoctor result with asciidoctor.js result for the same document.

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    Thanks .

    I've found another issue;

    = Book title :author: Rahman Usta :encoding: utf-8 :lang: tr

    include::01-one.asc[] include::02-two.asc[] include::03-three.asc[]

    when you convert this to docbook with asciidoctorjs, it wraps elements with "preface" element.

    
    <?xml version="1.0" encoding="UTF-8"?>
    <?asciidoc-toc ?>
    <?asciidoc-numbered ?>
    <book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" lang="tr">
    <info>
    <title>Book title</title>
    <date>2014-08-21</date>
    <author>
    <personname>
    <firstname>Rahman</firstname>
    <othername>Usta</othername>
    <surname></surname>
    </personname>
    </author>
    <authorinitials>RU</authorinitials>
    </info>
    <preface>
    <title></title>
    <simpara><link xlink:href="01-one.asc">01-websocket-protokol.asc</simpara>
    <simpara><link xlink:href="02-two.asc">02-w3c-api.asc</simpara>
    <simpara><link xlink:href="03-three.asc">03-jsr356-notasyon.asc</simpara>
    </preface>
    </book>
    

    with preface element, when rendering PDF with apache-fopub, it produces those exceptions.

    org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "fo:page-sequence" is not a valid child of "fo:flow"! (No context info available) at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:303) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130) at com.kodcu.service.FopPdfService.generate(FopPdfService.java:74) at com.kodcu.controller.AsciiDocController$1.call(AsciiDocController.java:181) at com.kodcu.controller.AsciiDocController$1.call(AsciiDocController.java:177) at javafx.concurrent.Task$TaskCallable.call(Task.java:1426) at java.util.concurrent.FutureTask.run(FutureTask.java:266)

    When you remove preface element, errors goes away.

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    On Thu, Aug 21, 2014 at 2:43 AM, Rahman Usta notifications.com wrote:

    org.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException: "fo:page-sequence" is not a valid child of "fo:flow"! (No context info available)

    There's a good chance this is actually a document structure issue. Verify first that you can use the output if generated with AsciidoctorJ or Asciidoctor core?

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    Pretty high chance the rpartition method isn't implemented in Opal. We might have to monkey patch. For now, I think you can workaround if your title doesn't contain a colon.

    点赞 评论 复制链接分享
  • weixin_39631667 weixin_39631667 3月前

    I can workaround with colon by removing it :) I rendered this Asciidoc content with asciidoctor to docbook. it produced like below, there is no preface...

    
    <?xml version="1.0" encoding="UTF-8"?>
    <?asciidoc-toc ?>
    <?asciidoc-numbered ?>
    <article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" lang="tr">
    <info>
    <title>Book title</title>
    <date>2014-08-21</date>
    <author>
    <personname>
    <firstname>Rahman</firstname>
    <surname>Usta</surname>
    </personname>
    </author>
    <authorinitials>RU</authorinitials>
    </info>
    <simpara>
    Unresolved directive in preface.asc - include::01-one.asc[]
    Unresolved directive in preface.asc - include::02-two.asc[]
    Unresolved directive in preface.asc - include::03-three.asc[]
    </simpara>
    </article>
    
    点赞 评论 复制链接分享
  • weixin_39851809 weixin_39851809 3月前

    In https://github.com/asciidoctor/asciidoctor.js/issues/40#issuecomment-52893509 the doctype seems to be book And in https://github.com/asciidoctor/asciidoctor.js/issues/40#issuecomment-52895641 the doctype seems to be article

    Maybe this can explain the difference

    点赞 评论 复制链接分享
  • weixin_39890327 weixin_39890327 3月前

    Would you be willing to write a failing test in AsciidoctorJ? That way, we can not only track down the source of the error but ensure it doesn't break in the future.

    I don't see the Asciidoctor.js integration in AsciidoctorJ yet, but I found a repository Alex has setup for testing Rhino.

    https://github.com/lordofthejars/asciidoctorjs

    Perhaps you can add a test for Nashhorn there or perhaps can advise where to add the test?

    点赞 评论 复制链接分享