dprint icon indicating copy to clipboard operation
dprint copied to clipboard

Error if parenthesis `()` in image path: `Unexpected open container char`

Open SamuelT-Beslogic opened this issue 1 year ago • 3 comments

Version: 0.47.5

Formatting the markdown of a DevOps wiki. I replaced most of the path with .s, but they have the same length

PS .....................................................................> dprint fmt
Error formatting .....................................................................\Useful-code-snippets-(TODO%3A-to-move-and%7Cor-make-utils-libraries).md. Message: Line 7, column 71: Unexpected open container char `(`.

  rosoftTeams-image%20(18)-ecdeac
                      ~
Error formatting .....................................................................\Continuous-Integration-&-Continuous-Delivery-(CI-%7C-CD)\Automatically-Apply-Git-Changes-&-Autofixes.md. Message: Line 4, column 40: Unexpected open container char `(`.

  attachments/image%20(4)-cc40f26
                      ~
Error formatting .....................................................................\Continuous-Integration-&-Continuous-Delivery-(CI-%7C-CD)\Developing-and-Deploying-Azure-DevOps-extension.md. Message: Line 26, column 40: Unexpected open container char `(`.

  attachments/image%20(2)-17617b6
                      ~
Had 3 errors formatting.

.dprint.jsonc:

{
  // https://dprint.dev/config/#extending-a-different-configuration-file
  "extends": "https://raw.githubusercontent.com/Samuel-Therrien-Beslogic/beslogic-dprint-configuration/main/dprint.json"
}

Which expands to:

{
  // https://dprint.dev/config/#global-configuration
  "lineWidth": 100,
  "indentWidth": 2,
  "newLineKind": "auto",
  "useTabs": false,
  // https://dprint.dev/plugins/typescript/config/
  "typescript": {
    "quoteStyle": "preferSingle",
    "quoteProps": "asNeeded",
    "semiColons": "asi",
    "arrowFunction.useParentheses": "preferNone",
    "binaryExpression.linePerExpression": true,
    // Not convinced yet
    // "memberExpression.linePerExpression": true,
    "typeLiteral.separatorKind": "comma",
    "enumDeclaration.memberSpacing": "newLine",
    "importDeclaration.forceSingleLine": true,
    // conflicts with simple-import-sort/imports
    "module.sortImportDeclarations": "maintain",
    "module.sortExportDeclarations": "maintain"
  },
  // https://dprint.dev/plugins/json/config/
  "json": {
    "associations": [
      "*.json",
      "*.jsonc",
      "*.json5",
      "*.nswag",
      "*.dmw"
    ]
  },
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.84.1.wasm",
    "https://plugins.dprint.dev/json-0.17.1.wasm",
    "https://plugins.dprint.dev/markdown-0.15.2.wasm",
    "https://plugins.dprint.dev/dockerfile-0.3.0.wasm",
    "https://plugins.dprint.dev/toml-0.5.4.wasm"
  ],
  "excludes": [
    "**/node_modules",
    "**/*-lock.json",
    "**/.yalc",
    "**/coverage", // created on install by nx
    "**/build",
    "**/cache",
    "**/dist",
    "**/tmp",
    "**/obj",
    "**/.storybook/documentation.json",
    "**/storybook-static",
    // capacitor folders
    "**/*/android/app",
    "**/*/ios/App"
  ]
}

SamuelT-Beslogic avatar Nov 28 '24 17:11 SamuelT-Beslogic

Oh wait, I just realized this is an error in dprint itself. I thought it was a link in markdown. Sorry for the transfering, going to transfer back to dprint/dprint.

dsherret avatar Dec 02 '24 03:12 dsherret

Wait, but this error is in dprint-plugin-markdown (https://github.com/dprint/dprint-plugin-markdown/blob/78ec6d71cb9301c06dd9a56a65680a9c7033efa8/src/generation/cmark/parsing/common.rs#L27). Can you provide the contents of one of these markdown files or a reproduction? Does the error happen on the line and column indicated?

dsherret avatar Dec 02 '24 03:12 dsherret

I initially thought the problem was related to filenames on disk (hence I opened on dprint). I think you were right to transfer. It seems the issue happens when when an image reference contains parenthesis. The parser probably thinks I forgot to close

Passes: [Link name (a)](/filename_(a)) Fails: ![Link name (a)](/filename_(a))

I also updated to https://plugins.dprint.dev/markdown-0.17.8.wasm and can confirm the issue is still present.

SamuelT-Beslogic avatar Dec 02 '24 04:12 SamuelT-Beslogic