remove markdown rendering support#676
Conversation
|
Warning Review limit reached
More reviews will be available in 24 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughThis PR removes the ChangesMarkdown Functionality Removal
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/backend/InvenTree/InvenTree/mixins.py (1)
56-80:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate the notes contract alongside this behavior change.
InvenTreeNotesFieldis still described as"Markdown notes (optional)"insrc/backend/InvenTree/InvenTree/models.py:1248-1250, but this path now treats those values as plain text. Without updating that contract, API/UI consumers are still told to author markdown that will now render literally.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/backend/InvenTree/InvenTree/mixins.py` around lines 56 - 80, The public contract for InvenTreeNotesField must be updated to reflect that values are treated as plain text (markdown is no longer interpreted): update the field's descriptive text/help/verbose string on the InvenTreeNotesField declaration (the model field currently described as "Markdown notes (optional)") so it clearly states "Notes (plain text, markdown not supported)" or equivalent; ensure the change is made next to the InvenTreeNotesField definition in models (the model field declaration) to keep docs/UI/serializers consistent with the mixins.py behavior that now strips/escapes markdown.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/backend/InvenTree/report/templates/report/inventree_build_order_report.html`:
- Around line 173-175: In the template inventree_build_order_report.html the
build.notes block currently renders raw text ({{ build.notes }}) which collapses
newline characters; update the template to render notes with preserved line
breaks (e.g., use the Django template filter linebreaksbr: {{
build.notes|linebreaksbr }} or an equivalent nl2br-style filter) so multi-line
InvenTreeNotesField content appears with line breaks in the generated report.
---
Outside diff comments:
In `@src/backend/InvenTree/InvenTree/mixins.py`:
- Around line 56-80: The public contract for InvenTreeNotesField must be updated
to reflect that values are treated as plain text (markdown is no longer
interpreted): update the field's descriptive text/help/verbose string on the
InvenTreeNotesField declaration (the model field currently described as
"Markdown notes (optional)") so it clearly states "Notes (plain text, markdown
not supported)" or equivalent; ensure the change is made next to the
InvenTreeNotesField definition in models (the model field declaration) to keep
docs/UI/serializers consistent with the mixins.py behavior that now
strips/escapes markdown.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fd550f37-d114-44da-ac90-be94f24875d2
📒 Files selected for processing (14)
src/backend/InvenTree/InvenTree/helpers.pysrc/backend/InvenTree/InvenTree/mixins.pysrc/backend/InvenTree/InvenTree/setting/markdown.pysrc/backend/InvenTree/InvenTree/settings.pysrc/backend/InvenTree/report/templates/report/inventree_build_order_report.htmlsrc/backend/InvenTree/report/templates/report/inventree_order_report_base.htmlsrc/backend/InvenTree/report/templates/report/inventree_purchase_order_report.htmlsrc/backend/InvenTree/report/templates/report/inventree_return_order_report.htmlsrc/backend/InvenTree/report/templates/report/inventree_sales_order_report.htmlsrc/backend/InvenTree/report/templates/report/inventree_sales_order_shipment_report.htmlsrc/backend/InvenTree/report/templates/report/inventree_transfer_order_report.htmlsrc/backend/requirements-3.14.txtsrc/backend/requirements.insrc/backend/requirements.txt
💤 Files with no reviewable changes (10)
- src/backend/InvenTree/report/templates/report/inventree_sales_order_report.html
- src/backend/InvenTree/report/templates/report/inventree_sales_order_shipment_report.html
- src/backend/InvenTree/report/templates/report/inventree_transfer_order_report.html
- src/backend/InvenTree/report/templates/report/inventree_purchase_order_report.html
- src/backend/InvenTree/report/templates/report/inventree_return_order_report.html
- src/backend/InvenTree/InvenTree/setting/markdown.py
- src/backend/InvenTree/report/templates/report/inventree_order_report_base.html
- src/backend/InvenTree/InvenTree/helpers.py
- src/backend/requirements.in
- src/backend/requirements-3.14.txt
| {% if build.notes %} | ||
| {{ build.notes|markdownify }} | ||
| {{ build.notes }} | ||
| {% endif %} |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the template and show the surrounding lines for context
sed -n '130,210p' src/backend/InvenTree/report/templates/report/inventree_build_order_report.html
# Inspect mixins around the cited newline-preservation logic
sed -n '1,140p' src/backend/InvenTree/InvenTree/mixins.py
# Find where build.notes is set/derived (search across backend for ".notes" in build order report context)
rg -n "build\.notes|notes\s*=" src/backend/InvenTree | head -n 200
# Search for markdownify usage/removal in the report rendering pipeline
rg -n "markdownify|markdown|linebreaksbr|linebreaks|preform|pre\s*|" src/backend/InvenTree/report src/backend/InvenTree/InvenTree | head -n 200
# Find definition/usage of InvenTreeNotesField
rg -n "InvenTreeNotesField" src/backend/InvenTree | head -n 200Repository: matmair/InvenTree
Length of output: 36603
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect InvenTreeNotesField implementation
sed -n '150,280p' src/backend/InvenTree/fields.py
# Inspect build model notes field to see how it stores/represents notes
sed -n '1180,1285p' src/backend/InvenTree/build/models.py
# Search for how notes are rendered in templates elsewhere
rg -n "build\.notes|\.notes\b" src/backend/InvenTree/report/templates | head -n 200
rg -n "linebreaksbr|markdownify|markdown|safe\W*\|.*safe" src/backend/InvenTree/report/templates | head -n 200
# Search globally for use of linebreaksbr with notes fields
rg -n "linebreaksbr" src/backend/InvenTree | head -n 200Repository: matmair/InvenTree
Length of output: 136
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect InvenTreeNotesField implementation (correct path)
sed -n '180,270p' src/backend/InvenTree/InvenTree/fields.py
# Inspect build model notes field usage (for representation hints)
sed -n '1210,1275p' src/backend/InvenTree/build/models.py
# Inspect template(s) for how notes are rendered elsewhere
rg -n "build\.notes|\.notes\b" src/backend/InvenTree/report/templates | head -n 200
# Check whether any note-related templates already use linebreaksbr/markdown/linebreak conversion
rg -n "linebreaksbr|markdownify|markdown|<br\s*/?>|pre\s*|white-space" src/backend/InvenTree/report/templates | head -n 200
# Find any template usage of |linebreaksbr globally
rg -n "\|linebreaksbr" src/backend/InvenTree | head -n 200
# Find any template usage of markdownify globally in report/templates
rg -n "markdownify" src/backend/InvenTree/report/templates | head -n 200Repository: matmair/InvenTree
Length of output: 10207
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show more context around the notes block in the build order report template
sed -n '1,120p' src/backend/InvenTree/report/templates/report/inventree_build_order_report.html
sed -n '150,200p' src/backend/InvenTree/report/templates/report/inventree_build_order_report.html
# Check for any filters/tags used in templates for notes rendering (linebreaksbr, markdownify, etc.)
rg -n "markdownify|linebreaksbr|linebreaks|pre-wrap|white-space:\s*pre|<pre|<br\s*/?>" src/backend/InvenTree/report/templates/report | head -n 200
# Search globally for markdownify usage in backend
rg -n "markdownify" src/backend/InvenTree | head -n 200
# Search globally for markdown filter usage (could be custom)
rg -n "markdown\s*ify|markdown\s*\(" src/backend/InvenTree | head -n 200
# Search for any custom template filter applying markdown to notes fields
rg -n "templatetag|register\.filter|`@register`\.filter" src/backend/InvenTree | head -n 200Repository: matmair/InvenTree
Length of output: 3622
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the base report template CSS for whitespace handling
sed -n '1,140p' src/backend/InvenTree/report/templates/report/inventree_report_base.html
# Search for CSS rules or template filters affecting whitespace/newlines in report templates
rg -n "white-space\s*:\s*pre|white-space\s*:\s*pre-wrap|pre-wrap|linebreaksbr|newline" src/backend/InvenTree/report/templates/report/inventree_report_base.html src/backend/InvenTree/report/templates/report -S
# Inspect inventree_extras templatetags for any markdown/linebreak helper
fd -i "inventree_extras" src/backend/InvenTree -a 2>/dev/null || true
fd -i "inventree_extras\.py" src/backend/InvenTree -a 2>/dev/null || true
fd -i "*extras*" src/backend/InvenTree/report src/backend/InvenTree -a 2>/dev/null | head
# Locate the template tag implementation file and inspect for filters like markdownify/linebreaksbr
rg -n "register\.filter|markdownify|linebreaksbr|linebreak" src/backend/InvenTree -S --glob='*.py' | head -n 200Repository: matmair/InvenTree
Length of output: 2439
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect helper functions used by CleanMixin
rg -n "def remove_non_printable_characters" -S src/backend/InvenTree | head -n 20
rg -n "def strip_html_tags" -S src/backend/InvenTree | head -n 20
# Show implementations
python3 - <<'PY'
import subprocess, textwrap, os, sys, re, json, pathlib
PYRepository: matmair/InvenTree
Length of output: 300
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the exact implementations for newline/HTML stripping behavior
sed -n '860,980p' src/backend/InvenTree/InvenTree/helpers.pyRepository: matmair/InvenTree
Length of output: 3865
Preserve line breaks in build order report notes
build.notes is rendered as raw text ({{ build.notes }}), so any \n preserved for InvenTreeNotesField collapses in normal HTML flow, flattening multi-line notes in the generated report.
Suggested fix
{% if build.notes %}
-{{ build.notes }}
+{{ build.notes|linebreaksbr }}
{% endif %}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {% if build.notes %} | |
| {{ build.notes|markdownify }} | |
| {{ build.notes }} | |
| {% endif %} | |
| {% if build.notes %} | |
| {{ build.notes|linebreaksbr }} | |
| {% endif %} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@src/backend/InvenTree/report/templates/report/inventree_build_order_report.html`
around lines 173 - 175, In the template inventree_build_order_report.html the
build.notes block currently renders raw text ({{ build.notes }}) which collapses
newline characters; update the template to render notes with preserved line
breaks (e.g., use the Django template filter linebreaksbr: {{
build.notes|linebreaksbr }} or an equivalent nl2br-style filter) so multi-line
InvenTreeNotesField content appears with line breaks in the generated report.
test to figure some things out around inventree#11971
Summary by CodeRabbit