oleeskild / obsidian-digital-garden

MIT License
1.43k stars 129 forks source link

[BUG] Hashtag in backticked code lets deploy fail #223

Open Yetenol opened 1 year ago

Yetenol commented 1 year ago

Summary

When any of my notes contains a certain valid markdown code element, the deploy fails at this file.

Valid markdown code element:

`\textbf{#1}`

11ty Error message:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble rendering njk template ./src/site/notes/README.md (via TemplateContentRenderError)
[11ty] 2. (./src/site/notes/README.md)
[11ty]   Error: expected end of comment, got end of file (via Template render error)
[11ty]
[11ty] Original error stack trace: Template render error: (./src/site/notes/README.md)
[11ty]   Error: expected end of comment, got end of file
[11ty]     at Object._prettifyError (/opt/build/repo/node_modules/nunjucks/src/lib.js:36:11)
[11ty]     at Template.init (/opt/build/repo/node_modules/nunjucks/src/environment.js:511:19)
[11ty]     at Template.Obj (/opt/build/repo/node_modules/nunjucks/src/object.js:62:15)
[11ty]     at new Template (/opt/build/repo/node_modules/nunjucks/src/environment.js:478:18)
[11ty]     at Nunjucks.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:429:14)
[11ty]     at Markdown.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Markdown.js:68:28)
[11ty]     at TemplateRender.getCompiledTemplate (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateRender.js:269:26)
[11ty]     at Template.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateContent.js:355:42)
[11ty]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[11ty]     at async Template._render (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateContent.js:479:16)

Steps to reproduce

  1. Write the valid markdown code element as shown above to any of you notes.
  2. Publish this note
  3. Deploy fails

Complete error message

Click to expand ``` 12:32:33 AM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/netlify-f3jzcuw/builds 12:32:49 AM: build-image version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97 (focal) 12:32:49 AM: buildbot version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97 12:32:49 AM: Fetching cached dependencies 12:32:49 AM: Starting to download cache of 142.7MB 12:32:50 AM: Finished downloading cache in 403ms 12:32:50 AM: Starting to extract cache 12:32:51 AM: Finished extracting cache in 816ms 12:32:51 AM: Finished fetching cache in 1.281s 12:32:51 AM: Starting to prepare the repo for build 12:32:51 AM: Preparing Git Reference refs/heads/main 12:32:52 AM: Parsing package.json dependencies 12:32:53 AM: Starting build script 12:32:53 AM: Installing dependencies 12:32:53 AM: Python version set to 2.7 12:32:53 AM: Started restoring cached Node.js version 12:32:54 AM: Finished restoring cached Node.js version 12:32:54 AM: v16.19.1 is already installed. 12:32:54 AM: Now using node v16.19.1 (npm v8.19.3) 12:32:54 AM: Enabling Node.js Corepack 12:32:54 AM: Started restoring cached build plugins 12:32:54 AM: Finished restoring cached build plugins 12:32:54 AM: Attempting Ruby version 2.7.2, read from environment 12:32:55 AM: Using Ruby version 2.7.2 12:32:55 AM: Using PHP version 8.0 12:32:55 AM: Started restoring cached corepack dependencies 12:32:55 AM: Finished restoring cached corepack dependencies 12:32:55 AM: No npm workspaces detected 12:32:55 AM: Started restoring cached node modules 12:32:55 AM: Finished restoring cached node modules 12:32:56 AM: Installing npm packages using npm version 8.19.3 12:32:57 AM: up to date, audited 512 packages in 976ms 12:32:57 AM: 85 packages are looking for funding 12:32:57 AM: run `npm fund` for details 12:32:57 AM: 8 vulnerabilities (5 high, 3 critical) 12:32:57 AM: Some issues need review, and may require choosing 12:32:57 AM: a different dependency. 12:32:57 AM: Run `npm audit` for details. 12:32:57 AM: npm packages installed 12:32:57 AM: Started restoring cached go cache 12:32:57 AM: Finished restoring cached go cache 12:32:57 AM: go version go1.19.7 linux/amd64 12:32:57 AM: Detected 1 framework(s) 12:32:57 AM: "eleventy" at version "2.0.0" 12:32:57 AM: Section completed: initializing 12:32:59 AM: ​ 12:32:59 AM: Netlify Build 12:32:59 AM: ──────────────────────────────────────────────────────────────── 12:32:59 AM: ​ 12:32:59 AM: ❯ Version 12:32:59 AM: @netlify/build 29.6.4 12:32:59 AM: ​ 12:32:59 AM: ❯ Flags 12:32:59 AM: baseRelDir: true 12:32:59 AM: buildId: 64091b11d21e2b0008fdf25a 12:32:59 AM: deployId: 64091b11d21e2b0008fdf25c 12:32:59 AM: ​ 12:32:59 AM: ❯ Current directory 12:32:59 AM: /opt/build/repo 12:32:59 AM: ​ 12:32:59 AM: ❯ Config file 12:32:59 AM: /opt/build/repo/netlify.toml 12:32:59 AM: ​ 12:32:59 AM: ❯ Context 12:32:59 AM: production 12:32:59 AM: ​ 12:32:59 AM: 1. build.command from netlify.toml 12:32:59 AM: ──────────────────────────────────────────────────────────────── 12:32:59 AM: ​ 12:32:59 AM: $ npm install && npm run build 12:33:00 AM: up to date, audited 512 packages in 647ms 12:33:00 AM: 85 packages are looking for funding 12:33:00 AM: run `npm fund` for details 12:33:00 AM: 8 vulnerabilities (5 high, 3 critical) 12:33:00 AM: Some issues need review, and may require choosing 12:33:00 AM: a different dependency. 12:33:00 AM: Run `npm audit` for details. 12:33:00 AM: > web@1.0.0 build 12:33:00 AM: > npm-run-all get-theme build:* 12:33:00 AM: > web@1.0.0 get-theme 12:33:00 AM: > node src/site/get-theme.js 12:33:00 AM: > web@1.0.0 build:eleventy 12:33:00 AM: > cross-env ELEVENTY_ENV=prod NODE_OPTIONS=--max-old-space-size=4096 eleventy 12:33:04 AM: [11ty] Problem writing Eleventy templates: (more in DEBUG output) 12:33:04 AM: [11ty] 1. Having trouble rendering njk template ./src/site/notes/README.md (via TemplateContentRenderError) 12:33:04 AM: [11ty] 2. (./src/site/notes/README.md) 12:33:04 AM: [11ty] Error: expected end of comment, got end of file (via Template render error) 12:33:04 AM: [11ty] 12:33:04 AM: [11ty] Original error stack trace: Template render error: (./src/site/notes/README.md) 12:33:04 AM: [11ty] Error: expected end of comment, got end of file 12:33:04 AM: [11ty] at Object._prettifyError (/opt/build/repo/node_modules/nunjucks/src/lib.js:36:11) 12:33:04 AM: [11ty] at Template.init (/opt/build/repo/node_modules/nunjucks/src/environment.js:511:19) 12:33:04 AM: [11ty] at Template.Obj (/opt/build/repo/node_modules/nunjucks/src/object.js:62:15) 12:33:04 AM: [11ty] at new Template (/opt/build/repo/node_modules/nunjucks/src/environment.js:478:18) 12:33:04 AM: [11ty] at Nunjucks.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Nunjucks.js:429:14) 12:33:04 AM: [11ty] at Markdown.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/Engines/Markdown.js:68:28) 12:33:04 AM: [11ty] at TemplateRender.getCompiledTemplate (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateRender.js:269:26) 12:33:04 AM: [11ty] at Template.compile (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateContent.js:355:42) 12:33:04 AM: [11ty] at processTicksAndRejections (node:internal/process/task_queues:96:5) 12:33:04 AM: [11ty] at async Template._render (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateContent.js:479:16) 12:33:04 AM: [11ty] Copied 20 files / Wrote 0 files in 3.46 seconds (v2.0.0) 12:33:05 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2) 12:33:04 AM: ERROR: "build:eleventy" exited with 1. 12:33:04 AM: ​ 12:33:04 AM: "build.command" failed 12:33:04 AM: ──────────────────────────────────────────────────────────────── 12:33:04 AM: ​ 12:33:04 AM: Error message 12:33:04 AM: Command failed with exit code 1: npm install && npm run build (https://ntl.fyi/exit-code-1) 12:33:04 AM: ​ 12:33:04 AM: Error location 12:33:04 AM: In build.command from netlify.toml: 12:33:04 AM: npm install && npm run build 12:33:04 AM: ​ 12:33:04 AM: Resolved config 12:33:04 AM: build: 12:33:04 AM: command: npm install && npm run build 12:33:04 AM: commandOrigin: config 12:33:04 AM: publish: /opt/build/repo/dist 12:33:04 AM: publishOrigin: config 12:33:04 AM: functionsDirectory: /opt/build/repo/netlify/functions 12:33:04 AM: redirects: 12:33:05 AM: - from: /api/* status: 200 to: /.netlify/functions/:splat - from: /* status: 404 to: /404 redirectsOrigin: configCaching artifacts 12:33:05 AM: Started saving node modules 12:33:05 AM: Finished saving node modules 12:33:05 AM: Started saving build plugins 12:33:05 AM: Finished saving build plugins 12:33:05 AM: Started saving corepack cache 12:33:05 AM: Finished saving corepack cache 12:33:05 AM: Started saving pip cache 12:33:05 AM: Finished saving pip cache 12:33:05 AM: Started saving emacs cask dependencies 12:33:05 AM: Finished saving emacs cask dependencies 12:33:05 AM: Started saving maven dependencies 12:33:05 AM: Finished saving maven dependencies 12:33:05 AM: Started saving boot dependencies 12:33:05 AM: Finished saving boot dependencies 12:33:05 AM: Started saving rust rustup cache 12:33:05 AM: Finished saving rust rustup cache 12:33:05 AM: Started saving go dependencies 12:33:05 AM: Finished saving go dependencies 12:33:05 AM: Build failed due to a user error: Build script returned non-zero exit code: 2 12:33:05 AM: Failing build: Failed to build site 12:33:05 AM: Finished processing build request in 15.87s ```
Hailst0rm1 commented 1 year ago

Having the same issue...

Yetenol commented 1 year ago

Posted it on Eleventy itself and a contributor wrote:

I believe this is because Eleventy parses Markdown files as Liquid first before interpreting the Markdown syntax. Liquid has {# ... #} syntax for comments which is probably what it is expecting here. If you don’t want this, you can set markdownTemplateEngine: false to disable this behavior.

https://github.com/11ty/eleventy/issues/2894#issuecomment-1497415737