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

Error: Could not parse CSS stylesheet #105

Closed
MurakamiShinyu opened this issue Jan 19, 2021 · 0 comments
Closed

Error: Could not parse CSS stylesheet #105

MurakamiShinyu opened this issue Jan 19, 2021 · 0 comments
Labels

Comments

@MurakamiShinyu
Copy link
Member

CLI v3.0.0-pre のbuildまたはpreviewコマンドで、inputがHTMLファイルであり、そのHTML内にstyle要素でスタイルシートがあるとき "Error: Could not parse CSS stylesheet" が発生することがあります。
CSS Paged MediaなどブラウザでサポートされていないようなCSSルールをCSS parserが扱えないためのようです。

例: inputが https://github.com/vivliostyle/vivliostyle.js/blob/master/packages/core/test/files/named-strings/named-strings.html をローカルにコピーしたファイルの場合、

$ vivliostyle preview named-strings/named-strings.html 
◡ Preparing previewError: Could not parse CSS stylesheet
    at exports.createStylesheet (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js:34:21)
    at HTMLStyleElementImpl._updateAStyleBlock (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/jsdom/lib/jsdom/living/nodes/HTMLStyleElement-impl.js:68:5)
    at HTMLStyleElementImpl._poppedOffStackOfOpenElements (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/jsdom/lib/jsdom/living/nodes/HTMLStyleElement-impl.js:42:10)
    at OpenElementStack.pop (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/jsdom/lib/jsdom/browser/parser/html.js:43:12)
    at Object.endTagInText [as END_TAG_TOKEN] (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/parser/index.js:2153:20)
    at Parser._processToken (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/parser/index.js:657:55)
    at Parser._processInputToken (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/parser/index.js:684:18)
    at Parser._runParsingLoop (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/parser/index.js:440:18)
    at Parser.parse (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/parser/index.js:344:14)
    at Object.parse (/Users/shinyu/viv/vivliostyle-cli--develop/node_modules/parse5/lib/index.js:10:19) 
      @page {
        size: 15cm 10cm;
        margin: 1.5cm;

        @top-left {
          content: "first: " string(heading, first);
        }
        @top-center {
          content: "start: " string(heading, start);
        }
        @top-right {
          content: "last: " string(heading, last);
        }
        @bottom-left {
          content: "first-except: " string(heading, first-except);
        }
        @bottom-right {
          content: "Page " counter(page);
        }
      }

      body {
        margin: 0;
      }

      h2 {
        string-set: heading content();
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants