prettier 1.5.2 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +41 -12
- data/node_modules/prettier/bin-prettier.js +13848 -11589
- data/node_modules/prettier/doc.js +4961 -0
- data/node_modules/prettier/index.js +19466 -16783
- data/node_modules/prettier/package.json +23 -0
- data/node_modules/prettier/parser-angular.js +67 -0
- data/node_modules/prettier/parser-babel.js +22 -0
- data/node_modules/prettier/parser-espree.js +22 -0
- data/node_modules/prettier/parser-flow.js +22 -0
- data/node_modules/prettier/parser-glimmer.js +1 -0
- data/node_modules/prettier/parser-graphql.js +1 -0
- data/node_modules/prettier/parser-html.js +132 -0
- data/node_modules/prettier/parser-markdown.js +34 -0
- data/node_modules/prettier/parser-meriyah.js +22 -0
- data/node_modules/prettier/parser-postcss.js +22 -0
- data/node_modules/prettier/parser-typescript.js +22 -0
- data/node_modules/prettier/parser-yaml.js +15 -0
- data/node_modules/prettier/third-party.js +1671 -864
- data/package.json +5 -5
- data/rubocop.yml +12 -0
- data/src/haml/parser.js +6 -5
- data/src/haml/parser.rb +8 -3
- data/src/haml/printer.js +428 -18
- data/src/parser/netcat.js +0 -2
- data/src/parser/parseSync.js +153 -14
- data/src/parser/server.rb +5 -0
- data/src/plugin.js +7 -1
- data/src/rbs/parser.js +3 -5
- data/src/rbs/parser.rb +7 -3
- data/src/rbs/printer.js +46 -8
- data/src/ruby/nodes/args.js +111 -19
- data/src/ruby/nodes/calls.js +50 -3
- data/src/ruby/nodes/conditionals.js +47 -45
- data/src/ruby/nodes/hashes.js +5 -14
- data/src/ruby/nodes/params.js +2 -9
- data/src/ruby/nodes/strings.js +97 -2
- data/src/ruby/parser.js +3 -5
- data/src/ruby/parser.rb +76 -31
- data/src/ruby/printer.js +10 -1
- data/src/utils/inlineEnsureParens.js +1 -0
- data/src/utils/noIndent.js +0 -1
- data/src/utils/skipAssignIndent.js +8 -1
- metadata +16 -14
- data/src/haml/nodes/comment.js +0 -27
- data/src/haml/nodes/doctype.js +0 -34
- data/src/haml/nodes/filter.js +0 -16
- data/src/haml/nodes/hamlComment.js +0 -21
- data/src/haml/nodes/plain.js +0 -6
- data/src/haml/nodes/root.js +0 -8
- data/src/haml/nodes/script.js +0 -33
- data/src/haml/nodes/silentScript.js +0 -59
- data/src/haml/nodes/tag.js +0 -193
- data/src/parser/getLang.js +0 -32
- data/src/parser/getNetcat.js +0 -50
- data/src/parser/requestParse.js +0 -74
    
        data/src/ruby/printer.js
    CHANGED
    
    | @@ -127,6 +127,14 @@ function isBlockComment(comment) { | |
| 127 127 | 
             
              return comment.type === "@embdoc";
         | 
| 128 128 | 
             
            }
         | 
| 129 129 |  | 
| 130 | 
            +
            // This function handles adding the format pragma to a source string. This is an
         | 
| 131 | 
            +
            // optional workflow for incremental adoption.
         | 
| 132 | 
            +
            function insertPragma(text) {
         | 
| 133 | 
            +
              const boundary = text.startsWith("#") ? "\n" : "\n\n";
         | 
| 134 | 
            +
             | 
| 135 | 
            +
              return `# @format${boundary}${text}`;
         | 
| 136 | 
            +
            }
         | 
| 137 | 
            +
             | 
| 130 138 | 
             
            module.exports = {
         | 
| 131 139 | 
             
              embed,
         | 
| 132 140 | 
             
              print: printNode,
         | 
| @@ -134,5 +142,6 @@ module.exports = { | |
| 134 142 | 
             
              canAttachComment,
         | 
| 135 143 | 
             
              getCommentChildNodes,
         | 
| 136 144 | 
             
              printComment,
         | 
| 137 | 
            -
              isBlockComment
         | 
| 145 | 
            +
              isBlockComment,
         | 
| 146 | 
            +
              insertPragma
         | 
| 138 147 | 
             
            };
         | 
    
        data/src/utils/noIndent.js
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: prettier
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.6.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kevin Deisz
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-06-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description:
         | 
| 14 14 | 
             
            email:
         | 
| @@ -27,28 +27,30 @@ files: | |
| 27 27 | 
             
            - lib/prettier.rb
         | 
| 28 28 | 
             
            - lib/prettier/rake/task.rb
         | 
| 29 29 | 
             
            - node_modules/prettier/bin-prettier.js
         | 
| 30 | 
            +
            - node_modules/prettier/doc.js
         | 
| 30 31 | 
             
            - node_modules/prettier/index.js
         | 
| 32 | 
            +
            - node_modules/prettier/package.json
         | 
| 33 | 
            +
            - node_modules/prettier/parser-angular.js
         | 
| 34 | 
            +
            - node_modules/prettier/parser-babel.js
         | 
| 35 | 
            +
            - node_modules/prettier/parser-espree.js
         | 
| 36 | 
            +
            - node_modules/prettier/parser-flow.js
         | 
| 37 | 
            +
            - node_modules/prettier/parser-glimmer.js
         | 
| 38 | 
            +
            - node_modules/prettier/parser-graphql.js
         | 
| 39 | 
            +
            - node_modules/prettier/parser-html.js
         | 
| 40 | 
            +
            - node_modules/prettier/parser-markdown.js
         | 
| 41 | 
            +
            - node_modules/prettier/parser-meriyah.js
         | 
| 42 | 
            +
            - node_modules/prettier/parser-postcss.js
         | 
| 43 | 
            +
            - node_modules/prettier/parser-typescript.js
         | 
| 44 | 
            +
            - node_modules/prettier/parser-yaml.js
         | 
| 31 45 | 
             
            - node_modules/prettier/third-party.js
         | 
| 32 46 | 
             
            - package.json
         | 
| 33 47 | 
             
            - rubocop.yml
         | 
| 34 48 | 
             
            - src/haml/embed.js
         | 
| 35 | 
            -
            - src/haml/nodes/comment.js
         | 
| 36 | 
            -
            - src/haml/nodes/doctype.js
         | 
| 37 | 
            -
            - src/haml/nodes/filter.js
         | 
| 38 | 
            -
            - src/haml/nodes/hamlComment.js
         | 
| 39 | 
            -
            - src/haml/nodes/plain.js
         | 
| 40 | 
            -
            - src/haml/nodes/root.js
         | 
| 41 | 
            -
            - src/haml/nodes/script.js
         | 
| 42 | 
            -
            - src/haml/nodes/silentScript.js
         | 
| 43 | 
            -
            - src/haml/nodes/tag.js
         | 
| 44 49 | 
             
            - src/haml/parser.js
         | 
| 45 50 | 
             
            - src/haml/parser.rb
         | 
| 46 51 | 
             
            - src/haml/printer.js
         | 
| 47 | 
            -
            - src/parser/getLang.js
         | 
| 48 | 
            -
            - src/parser/getNetcat.js
         | 
| 49 52 | 
             
            - src/parser/netcat.js
         | 
| 50 53 | 
             
            - src/parser/parseSync.js
         | 
| 51 | 
            -
            - src/parser/requestParse.js
         | 
| 52 54 | 
             
            - src/parser/server.rb
         | 
| 53 55 | 
             
            - src/plugin.js
         | 
| 54 56 | 
             
            - src/prettier.js
         | 
    
        data/src/haml/nodes/comment.js
    DELETED
    
    | @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            const { concat, group, hardline, indent, join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#html-comments-
         | 
| 4 | 
            -
            function comment(path, _opts, print) {
         | 
| 5 | 
            -
              const { children, value } = path.getValue();
         | 
| 6 | 
            -
              const parts = ["/"];
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              if (value.revealed) {
         | 
| 9 | 
            -
                parts.push("!");
         | 
| 10 | 
            -
              }
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              if (value.conditional) {
         | 
| 13 | 
            -
                parts.push(value.conditional);
         | 
| 14 | 
            -
              } else if (value.text) {
         | 
| 15 | 
            -
                parts.push(" ", value.text);
         | 
| 16 | 
            -
              }
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              if (children.length > 0) {
         | 
| 19 | 
            -
                parts.push(
         | 
| 20 | 
            -
                  indent(concat([hardline, join(hardline, path.map(print, "children"))]))
         | 
| 21 | 
            -
                );
         | 
| 22 | 
            -
              }
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              return group(concat(parts));
         | 
| 25 | 
            -
            }
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            module.exports = comment;
         | 
    
        data/src/haml/nodes/doctype.js
    DELETED
    
    | @@ -1,34 +0,0 @@ | |
| 1 | 
            -
            const { join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            const types = {
         | 
| 4 | 
            -
              basic: "Basic",
         | 
| 5 | 
            -
              frameset: "Frameset",
         | 
| 6 | 
            -
              mobile: "Mobile",
         | 
| 7 | 
            -
              rdfa: "RDFa",
         | 
| 8 | 
            -
              strict: "Strict",
         | 
| 9 | 
            -
              xml: "XML"
         | 
| 10 | 
            -
            };
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            const versions = ["1.1", "5"];
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#doctype-
         | 
| 15 | 
            -
            function doctype(path, _opts, _print) {
         | 
| 16 | 
            -
              const { value } = path.getValue();
         | 
| 17 | 
            -
              const parts = ["!!!"];
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              if (value.type in types) {
         | 
| 20 | 
            -
                parts.push(types[value.type]);
         | 
| 21 | 
            -
              } else if (versions.includes(value.version)) {
         | 
| 22 | 
            -
                parts.push(value.version);
         | 
| 23 | 
            -
              } else {
         | 
| 24 | 
            -
                parts.push(value.type);
         | 
| 25 | 
            -
              }
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              if (value.encoding) {
         | 
| 28 | 
            -
                parts.push(value.encoding);
         | 
| 29 | 
            -
              }
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              return join(" ", parts);
         | 
| 32 | 
            -
            }
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            module.exports = doctype;
         | 
    
        data/src/haml/nodes/filter.js
    DELETED
    
    | @@ -1,16 +0,0 @@ | |
| 1 | 
            -
            const { concat, group, hardline, indent, join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#filters
         | 
| 4 | 
            -
            function filter(path, _opts, _print) {
         | 
| 5 | 
            -
              const { value } = path.getValue();
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              return group(
         | 
| 8 | 
            -
                concat([
         | 
| 9 | 
            -
                  ":",
         | 
| 10 | 
            -
                  value.name,
         | 
| 11 | 
            -
                  indent(concat([hardline, join(hardline, value.text.trim().split("\n"))]))
         | 
| 12 | 
            -
                ])
         | 
| 13 | 
            -
              );
         | 
| 14 | 
            -
            }
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            module.exports = filter;
         | 
| @@ -1,21 +0,0 @@ | |
| 1 | 
            -
            const { concat, hardline, indent, join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#haml-comments--
         | 
| 4 | 
            -
            function hamlComment(path, opts, _print) {
         | 
| 5 | 
            -
              const node = path.getValue();
         | 
| 6 | 
            -
              const parts = ["-#"];
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              if (node.value.text) {
         | 
| 9 | 
            -
                if (opts.originalText.split("\n")[node.line - 1].trim() === "-#") {
         | 
| 10 | 
            -
                  const lines = node.value.text.trim().split("\n");
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  parts.push(indent(concat([hardline, join(hardline, lines)])));
         | 
| 13 | 
            -
                } else {
         | 
| 14 | 
            -
                  parts.push(" ", node.value.text.trim());
         | 
| 15 | 
            -
                }
         | 
| 16 | 
            -
              }
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              return concat(parts);
         | 
| 19 | 
            -
            }
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            module.exports = hamlComment;
         | 
    
        data/src/haml/nodes/plain.js
    DELETED
    
    
    
        data/src/haml/nodes/root.js
    DELETED
    
    
    
        data/src/haml/nodes/script.js
    DELETED
    
    | @@ -1,33 +0,0 @@ | |
| 1 | 
            -
            const { concat, group, hardline, indent, join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby
         | 
| 4 | 
            -
            function script(path, opts, print) {
         | 
| 5 | 
            -
              const { children, value } = path.getValue();
         | 
| 6 | 
            -
              const parts = [];
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              if (value.escape_html) {
         | 
| 9 | 
            -
                parts.unshift("&");
         | 
| 10 | 
            -
              }
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              if (value.preserve) {
         | 
| 13 | 
            -
                parts.push("~");
         | 
| 14 | 
            -
              } else if (!value.interpolate) {
         | 
| 15 | 
            -
                parts.push("=");
         | 
| 16 | 
            -
              }
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              if (value.escape_html && !value.preserve && value.interpolate) {
         | 
| 19 | 
            -
                parts.push(" ", value.text.trim().slice(1, -1));
         | 
| 20 | 
            -
              } else {
         | 
| 21 | 
            -
                parts.push(" ", value.text.trim());
         | 
| 22 | 
            -
              }
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              if (children.length > 0) {
         | 
| 25 | 
            -
                parts.push(
         | 
| 26 | 
            -
                  indent(concat([hardline, join(hardline, path.map(print, "children"))]))
         | 
| 27 | 
            -
                );
         | 
| 28 | 
            -
              }
         | 
| 29 | 
            -
             | 
| 30 | 
            -
              return group(concat(parts));
         | 
| 31 | 
            -
            }
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            module.exports = script;
         | 
| @@ -1,59 +0,0 @@ | |
| 1 | 
            -
            const { concat, group, hardline, indent, join } = require("../../prettier");
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            function findKeywordIndices(children, keywords) {
         | 
| 4 | 
            -
              const indices = [];
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              children.forEach((child, index) => {
         | 
| 7 | 
            -
                if (child.type !== "silent_script") {
         | 
| 8 | 
            -
                  return;
         | 
| 9 | 
            -
                }
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                if (keywords.includes(child.value.keyword)) {
         | 
| 12 | 
            -
                  indices.push(index);
         | 
| 13 | 
            -
                }
         | 
| 14 | 
            -
              });
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              return indices;
         | 
| 17 | 
            -
            }
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#running-ruby--
         | 
| 20 | 
            -
            function silentScript(path, _opts, print) {
         | 
| 21 | 
            -
              const { children, value } = path.getValue();
         | 
| 22 | 
            -
              const parts = [`- ${value.text.trim()}`];
         | 
| 23 | 
            -
             | 
| 24 | 
            -
              if (children.length > 0) {
         | 
| 25 | 
            -
                const scripts = path.map(print, "children");
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                if (value.keyword === "case") {
         | 
| 28 | 
            -
                  const keywordIndices = findKeywordIndices(children, ["when", "else"]);
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                  parts.push(
         | 
| 31 | 
            -
                    concat(
         | 
| 32 | 
            -
                      scripts.map((script, index) => {
         | 
| 33 | 
            -
                        const concated = concat([hardline, script]);
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                        return keywordIndices.includes(index) ? concated : indent(concated);
         | 
| 36 | 
            -
                      })
         | 
| 37 | 
            -
                    )
         | 
| 38 | 
            -
                  );
         | 
| 39 | 
            -
                } else if (["if", "unless"].includes(value.keyword)) {
         | 
| 40 | 
            -
                  const keywordIndices = findKeywordIndices(children, ["elsif", "else"]);
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  parts.push(
         | 
| 43 | 
            -
                    concat(
         | 
| 44 | 
            -
                      scripts.map((script, index) => {
         | 
| 45 | 
            -
                        const concated = concat([hardline, script]);
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                        return keywordIndices.includes(index) ? concated : indent(concated);
         | 
| 48 | 
            -
                      })
         | 
| 49 | 
            -
                    )
         | 
| 50 | 
            -
                  );
         | 
| 51 | 
            -
                } else {
         | 
| 52 | 
            -
                  parts.push(indent(concat([hardline, join(hardline, scripts)])));
         | 
| 53 | 
            -
                }
         | 
| 54 | 
            -
              }
         | 
| 55 | 
            -
             | 
| 56 | 
            -
              return group(concat(parts));
         | 
| 57 | 
            -
            }
         | 
| 58 | 
            -
             | 
| 59 | 
            -
            module.exports = silentScript;
         | 
    
        data/src/haml/nodes/tag.js
    DELETED
    
    | @@ -1,193 +0,0 @@ | |
| 1 | 
            -
            const {
         | 
| 2 | 
            -
              align,
         | 
| 3 | 
            -
              concat,
         | 
| 4 | 
            -
              fill,
         | 
| 5 | 
            -
              group,
         | 
| 6 | 
            -
              hardline,
         | 
| 7 | 
            -
              ifBreak,
         | 
| 8 | 
            -
              indent,
         | 
| 9 | 
            -
              join,
         | 
| 10 | 
            -
              line,
         | 
| 11 | 
            -
              softline
         | 
| 12 | 
            -
            } = require("../../prettier");
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            function getDynamicAttributes(header, attributes) {
         | 
| 15 | 
            -
              const pairs = attributes
         | 
| 16 | 
            -
                .slice(1, -2)
         | 
| 17 | 
            -
                .split(",")
         | 
| 18 | 
            -
                .map((pair) => pair.slice(1).split('" => '));
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              const parts = [concat([pairs[0][0], "=", pairs[0][1]])];
         | 
| 21 | 
            -
              pairs.slice(1).forEach((pair) => {
         | 
| 22 | 
            -
                parts.push(line, concat([pair[0], "=", pair[1]]));
         | 
| 23 | 
            -
              });
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              return group(concat(["(", align(header + 1, fill(parts)), ")"]));
         | 
| 26 | 
            -
            }
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            function getHashValue(value, opts) {
         | 
| 29 | 
            -
              if (typeof value !== "string") {
         | 
| 30 | 
            -
                return value.toString();
         | 
| 31 | 
            -
              }
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              // This is a very special syntax created by the parser to let us know that
         | 
| 34 | 
            -
              // this should be printed literally instead of as a string.
         | 
| 35 | 
            -
              if (value.startsWith("&")) {
         | 
| 36 | 
            -
                return value.slice(1);
         | 
| 37 | 
            -
              }
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              const quote = opts.rubySingleQuote ? "'" : '"';
         | 
| 40 | 
            -
              return `${quote}${value}${quote}`;
         | 
| 41 | 
            -
            }
         | 
| 42 | 
            -
             | 
| 43 | 
            -
            function getHashKey(key, opts) {
         | 
| 44 | 
            -
              let quoted = key;
         | 
| 45 | 
            -
              const joiner = opts.rubyHashLabel ? ":" : " =>";
         | 
| 46 | 
            -
             | 
| 47 | 
            -
              if (key.includes(":") || key.includes("-")) {
         | 
| 48 | 
            -
                const quote = opts.rubySingleQuote ? "'" : '"';
         | 
| 49 | 
            -
                quoted = `${quote}${key}${quote}`;
         | 
| 50 | 
            -
              }
         | 
| 51 | 
            -
             | 
| 52 | 
            -
              return `${opts.rubyHashLabel ? "" : ":"}${quoted}${joiner}`;
         | 
| 53 | 
            -
            }
         | 
| 54 | 
            -
             | 
| 55 | 
            -
            function getKeyValuePair(key, value, opts) {
         | 
| 56 | 
            -
              return `${getHashKey(key, opts)} ${getHashValue(value, opts)}`;
         | 
| 57 | 
            -
            }
         | 
| 58 | 
            -
             | 
| 59 | 
            -
            function getStaticAttributes(header, attributes, opts) {
         | 
| 60 | 
            -
              const keys = Object.keys(attributes).filter(
         | 
| 61 | 
            -
                (name) => !["class", "id"].includes(name)
         | 
| 62 | 
            -
              );
         | 
| 63 | 
            -
             | 
| 64 | 
            -
              const parts = [getKeyValuePair(keys[0], attributes[keys[0]], opts)];
         | 
| 65 | 
            -
             | 
| 66 | 
            -
              keys.slice(1).forEach((key) => {
         | 
| 67 | 
            -
                parts.push(",", line, getKeyValuePair(key, attributes[key], opts));
         | 
| 68 | 
            -
              });
         | 
| 69 | 
            -
             | 
| 70 | 
            -
              return group(concat(["{", align(header + 1, fill(parts)), "}"]));
         | 
| 71 | 
            -
            }
         | 
| 72 | 
            -
             | 
| 73 | 
            -
            function getAttributesObject(object, opts, level = 0) {
         | 
| 74 | 
            -
              if (typeof object !== "object") {
         | 
| 75 | 
            -
                return getHashValue(object, opts);
         | 
| 76 | 
            -
              }
         | 
| 77 | 
            -
             | 
| 78 | 
            -
              const boundary = level === 0 ? softline : line;
         | 
| 79 | 
            -
              const parts = Object.keys(object).map((key) =>
         | 
| 80 | 
            -
                concat([
         | 
| 81 | 
            -
                  getHashKey(key, opts),
         | 
| 82 | 
            -
                  " ",
         | 
| 83 | 
            -
                  getAttributesObject(object[key], opts, level + 1)
         | 
| 84 | 
            -
                ])
         | 
| 85 | 
            -
              );
         | 
| 86 | 
            -
             | 
| 87 | 
            -
              return group(
         | 
| 88 | 
            -
                concat([
         | 
| 89 | 
            -
                  "{",
         | 
| 90 | 
            -
                  indent(group(concat([boundary, join(concat([",", line]), parts)]))),
         | 
| 91 | 
            -
                  boundary,
         | 
| 92 | 
            -
                  "}"
         | 
| 93 | 
            -
                ])
         | 
| 94 | 
            -
              );
         | 
| 95 | 
            -
            }
         | 
| 96 | 
            -
             | 
| 97 | 
            -
            function getHeader(value, opts) {
         | 
| 98 | 
            -
              const { attributes } = value;
         | 
| 99 | 
            -
              const parts = [];
         | 
| 100 | 
            -
             | 
| 101 | 
            -
              if (value.name !== "div") {
         | 
| 102 | 
            -
                parts.push(`%${value.name}`);
         | 
| 103 | 
            -
              }
         | 
| 104 | 
            -
             | 
| 105 | 
            -
              if (attributes.class) {
         | 
| 106 | 
            -
                parts.push(`.${attributes.class.replace(/ /g, ".")}`);
         | 
| 107 | 
            -
              }
         | 
| 108 | 
            -
             | 
| 109 | 
            -
              if (attributes.id) {
         | 
| 110 | 
            -
                parts.push(`#${attributes.id}`);
         | 
| 111 | 
            -
              }
         | 
| 112 | 
            -
             | 
| 113 | 
            -
              if (value.dynamic_attributes.new) {
         | 
| 114 | 
            -
                parts.push(
         | 
| 115 | 
            -
                  getDynamicAttributes(parts.join("").length, value.dynamic_attributes.new)
         | 
| 116 | 
            -
                );
         | 
| 117 | 
            -
              }
         | 
| 118 | 
            -
             | 
| 119 | 
            -
              if (
         | 
| 120 | 
            -
                Object.keys(attributes).some((name) => name !== "class" && name !== "id")
         | 
| 121 | 
            -
              ) {
         | 
| 122 | 
            -
                parts.push(getStaticAttributes(parts.join("").length, attributes, opts));
         | 
| 123 | 
            -
              }
         | 
| 124 | 
            -
             | 
| 125 | 
            -
              if (value.dynamic_attributes.old) {
         | 
| 126 | 
            -
                if (parts.length === 0) {
         | 
| 127 | 
            -
                  parts.push("%div");
         | 
| 128 | 
            -
                }
         | 
| 129 | 
            -
             | 
| 130 | 
            -
                if (typeof value.dynamic_attributes.old === "string") {
         | 
| 131 | 
            -
                  parts.push(value.dynamic_attributes.old);
         | 
| 132 | 
            -
                } else {
         | 
| 133 | 
            -
                  parts.push(getAttributesObject(value.dynamic_attributes.old, opts));
         | 
| 134 | 
            -
                }
         | 
| 135 | 
            -
              }
         | 
| 136 | 
            -
             | 
| 137 | 
            -
              if (value.object_ref) {
         | 
| 138 | 
            -
                if (parts.length === 0) {
         | 
| 139 | 
            -
                  parts.push("%div");
         | 
| 140 | 
            -
                }
         | 
| 141 | 
            -
                parts.push(value.object_ref);
         | 
| 142 | 
            -
              }
         | 
| 143 | 
            -
             | 
| 144 | 
            -
              if (value.nuke_outer_whitespace) {
         | 
| 145 | 
            -
                parts.push(">");
         | 
| 146 | 
            -
              }
         | 
| 147 | 
            -
             | 
| 148 | 
            -
              if (value.nuke_inner_whitespace) {
         | 
| 149 | 
            -
                parts.push("<");
         | 
| 150 | 
            -
              }
         | 
| 151 | 
            -
             | 
| 152 | 
            -
              if (value.self_closing) {
         | 
| 153 | 
            -
                parts.push("/");
         | 
| 154 | 
            -
              }
         | 
| 155 | 
            -
             | 
| 156 | 
            -
              if (value.value) {
         | 
| 157 | 
            -
                const prefix = value.parse ? "= " : ifBreak("", " ");
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                return group(
         | 
| 160 | 
            -
                  concat([
         | 
| 161 | 
            -
                    group(concat(parts)),
         | 
| 162 | 
            -
                    indent(concat([softline, prefix, value.value]))
         | 
| 163 | 
            -
                  ])
         | 
| 164 | 
            -
                );
         | 
| 165 | 
            -
              }
         | 
| 166 | 
            -
             | 
| 167 | 
            -
              // In case none of the other if statements have matched and we're printing a
         | 
| 168 | 
            -
              // div, we need to explicitly add it back into the array.
         | 
| 169 | 
            -
              if (parts.length === 0 && value.name === "div") {
         | 
| 170 | 
            -
                parts.push("%div");
         | 
| 171 | 
            -
              }
         | 
| 172 | 
            -
             | 
| 173 | 
            -
              return group(concat(parts));
         | 
| 174 | 
            -
            }
         | 
| 175 | 
            -
             | 
| 176 | 
            -
            // https://haml.info/docs/yardoc/file.REFERENCE.html#element-name-
         | 
| 177 | 
            -
            function tag(path, opts, print) {
         | 
| 178 | 
            -
              const { children, value } = path.getValue();
         | 
| 179 | 
            -
              const header = getHeader(value, opts);
         | 
| 180 | 
            -
             | 
| 181 | 
            -
              if (children.length === 0) {
         | 
| 182 | 
            -
                return header;
         | 
| 183 | 
            -
              }
         | 
| 184 | 
            -
             | 
| 185 | 
            -
              return group(
         | 
| 186 | 
            -
                concat([
         | 
| 187 | 
            -
                  header,
         | 
| 188 | 
            -
                  indent(concat([hardline, join(hardline, path.map(print, "children"))]))
         | 
| 189 | 
            -
                ])
         | 
| 190 | 
            -
              );
         | 
| 191 | 
            -
            }
         | 
| 192 | 
            -
             | 
| 193 | 
            -
            module.exports = tag;
         |