Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed CSS to generated html file #4

Open
padupuy opened this issue Feb 24, 2015 · 6 comments · Fixed by #17
Open

Embed CSS to generated html file #4

padupuy opened this issue Feb 24, 2015 · 6 comments · Fixed by #17

Comments

@padupuy
Copy link

padupuy commented Feb 24, 2015

Which option can I set to embed asciidoctor css to my generated html ?
I try to set linkcss to true, but without success.

I also try to find an option to copy the asciidoctor css in the same destination folder but it still to be "./asciidoctor.css"

Here is my code

gulp.src('doc.adoc')
        .pipe(asciidoctor({
            safe: false,
            linkcss: false
        }))
        .pipe(gulp.dest('target/doc/'));
@patlau
Copy link

patlau commented Mar 5, 2015

I have a similar problem generating one html file from multiple include files with embedded css using

    gulp.src('arc42-template.adoc')
        .pipe(asciidoctor({
            safe: 'unsafe',
            doctype: 'book',
            header_footer: true,
            attributes: ['showtitle', 'toc', 'toc-position=left']
        }))
        .pipe(gulp.dest('dest'));

Resulted in

node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:11782
ata = (($b = $opal.Object._scope.IO) == null ? $opal.cm('IO') : $b).$read((($b
                                                                    ^
TypeError: Object IO has no method '$read'
    at $Stylesheets.def.$primary_stylesheet_data
    ...

I currently fixed it by changing the asciidoctor-core-min.js file in _node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm_ (first renamed asciidoctor-core.js to asciidoctor-core-min.js):

//return ((($a = self.primary_stylesheet_data) !== false && $a !== nil) ? $a : self.primary_stylesheet_data = (($b = $opal.Object._scope.IO) == null ? $opal.cm('IO') : $b).$read((($b = $opal.Object._scope.File) == null ? $opal.cm('File') : $b).$join($scope.STYLESHEETS_DATA_PATH, "asciidoctor.css")).$chomp());
return ((($a = self.primary_stylesheet_data) !== false && $a !== nil) ? $a : self.primary_stylesheet_data = (($b = $opal.Object._scope.File) == null ? $opal.cm('File') : $b).$read((($b = $opal.Object._scope.File) == null ? $opal.cm('File') : $b).$join($scope.STYLESHEETS_DATA_PATH, "asciidoctor.css")).$chomp());

Then I got the next error:

fs.js:438
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'c:\stylesheets\asciidoctor.css'

Fixed it again by changing a line in asciidoctor-core-min.js:

//$opal.cdecl($scope, 'STYLESHEETS_DATA_PATH', (($a = $opal.Object._scope.File) == null ? $opal.cm('File') : $a).$join($scope.DATA_PATH, "stylesheets"));
$opal.cdecl($scope, 'STYLESHEETS_DATA_PATH', (($a = $opal.Object._scope.File) == null ? $opal.cm('File') : $a).$join("node_modules\\gulp-asciidoctor\\node_modules\\asciidoctor.js\\dist", "css"));

@dongwq
Copy link
Contributor

dongwq commented Mar 6, 2015

@padupuy , linkcss is a attribute. so it shoud be used as

     attributes: ['showtitle', 'linkcss!']

sorry, it's not tested yet.

@padupuy
Copy link
Author

padupuy commented Mar 6, 2015

@dongwq thanks for your answer but I try to add the attribute parameter and it didn't work.

Here is my gulp task

gulp.task('generate-doc', function() {
    var destFolder = 'target/doc/';
    gulp.src('doc/**/*.adoc')
        .pipe(asciidoctor({
            attributes: ['showtitle', 'linkcss!']
        }))
        .pipe(gulp.dest(destFolder));
});

@patlau
Copy link

patlau commented Mar 6, 2015

Works for me when setting the "safe" option to 'unsafe' (not false).

        .pipe(asciidoctor({
            safe: 'unsafe',
            attributes: ['showtitle', 'linkcss!']
        }))

@padupuy
Copy link
Author

padupuy commented Mar 6, 2015

@patlau when I add the safe argument, I got the same kind of problem as you

\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:9
primary_stylesheet_data=(null==(d=a.Object._scope.IO)?a.cm("IO"):d).$read((nul
                                                                    ^
TypeError: Object IO has no method '$read'
    at g.j.$primary_stylesheet_data (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:9:22247)
    at g.j.$embed_primary_stylesheet (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:9:22439)
    at h.j.$document (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:4:19377)
    at h.$opal.defn.TMP_1 (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\node_modules\opal-npm-wrapper\index.js:1793:21)
    at h.i.$convert (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:4:8231)
    at i.o.$convert (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:6:18069)
    at OpalModule.b._proto.$convert (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\node_modules\asciidoctor.js\dist\npm\asciidoctor-core.min.js:10:29517)
    at Transform._transform (D:\Ws\Ci_Iznogoud\node_modules\gulp-asciidoctor\index.js:47:30)
    at Transform._read (_stream_transform.js:179:10)
    at Transform._write (_stream_transform.js:167:12)

@henriette-einstein
Copy link
Contributor

henriette-einstein commented May 13, 2020

This should work now. Use the Asciidoctor option 'standalone'.
Please recheck.

@henriette-einstein henriette-einstein linked a pull request May 13, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants