Skip to content

remove markdown rendering support#676

Open
matmair wants to merge 2 commits into
masterfrom
remove-markdown
Open

remove markdown rendering support#676
matmair wants to merge 2 commits into
masterfrom
remove-markdown

Conversation

@matmair
Copy link
Copy Markdown
Owner

@matmair matmair commented Jun 3, 2026

test to figure some things out around inventree#11971

Summary by CodeRabbit

  • Chores
    • Removed markdown formatting support from notes and descriptions across the application. Content will now display as plain text instead of formatted HTML. Updated report templates and removed related dependencies accordingly.

@matmair matmair requested a review from SchrodingersGat as a code owner June 3, 2026 21:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

Warning

Review limit reached

@matmair, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14e8fdcc-f890-4fad-bdd6-6b7632697edf

📥 Commits

Reviewing files that changed from the base of the PR and between f149006 and 043894a.

📒 Files selected for processing (1)
  • docs/requirements.txt
📝 Walkthrough

Walkthrough

This PR removes the django-markdownify dependency and all associated markdown-to-HTML conversion functionality from InvenTree. Changes span backend sanitization helpers, the clean string pipeline, settings configuration, template rendering, and dependency manifests to complete the removal.

Changes

Markdown Functionality Removal

Layer / File(s) Summary
Core markdown sanitization helper removal
src/backend/InvenTree/InvenTree/helpers.py
Remove the clean_markdown() function that converted markdown to HTML and sanitized with nh3, along with its InvenTree.sanitizer import dependency.
Sanitization pipeline cleanup
src/backend/InvenTree/InvenTree/mixins.py
Update CleanMixin.clean_string to remove markdown field tracking (is_markdown) and the conditional clean_markdown invocation, preserving newline detection and tag stripping.
Settings configuration cleanup
src/backend/InvenTree/InvenTree/settings.py
Remove markdown module import, markdownify from INSTALLED_APPS, and the MARKDOWNIFY configuration block assigning markdown.markdownify_config().
Template markdownify removal
src/backend/InvenTree/report/templates/report/inventree_order_report_base.html, inventree_purchase_order_report.html, inventree_return_order_report.html, inventree_sales_order_report.html, inventree_sales_order_shipment_report.html, inventree_transfer_order_report.html, inventree_build_order_report.html
Remove {% load markdownify %} imports from report templates and change build notes rendering from build.notes|markdownify to direct build.notes output.
Dependency manifest cleanup
src/backend/requirements.in, src/backend/requirements.txt, src/backend/requirements-3.14.txt
Remove django-markdownify==0.9.1 package dependency and transitive packages bleach and markdown, including all associated provenance comments and via references.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through code with glee,
Removing markdown, clean and free,
No more HTML from *.md files,
Just plain text rendering with smiles! 🐰
Bleach and markdownify gone at last,
Legacy code is now in the past. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'remove markdown rendering support' clearly and directly summarizes the main change across all modified files, which consistently removes markdown/markdownify functionality from the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-markdown

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Update the notes contract alongside this behavior change.

InvenTreeNotesField is still described as "Markdown notes (optional)" in src/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

📥 Commits

Reviewing files that changed from the base of the PR and between d38af61 and f149006.

📒 Files selected for processing (14)
  • src/backend/InvenTree/InvenTree/helpers.py
  • src/backend/InvenTree/InvenTree/mixins.py
  • src/backend/InvenTree/InvenTree/setting/markdown.py
  • src/backend/InvenTree/InvenTree/settings.py
  • src/backend/InvenTree/report/templates/report/inventree_build_order_report.html
  • src/backend/InvenTree/report/templates/report/inventree_order_report_base.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/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/requirements-3.14.txt
  • src/backend/requirements.in
  • src/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

Comment on lines 173 to 175
{% if build.notes %}
{{ build.notes|markdownify }}
{{ build.notes }}
{% endif %}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 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 200

Repository: 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 200

Repository: 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 200

Repository: 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 200

Repository: 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 200

Repository: 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
PY

Repository: 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.py

Repository: 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.

Suggested change
{% 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.

@matmair matmair mentioned this pull request Jun 3, 2026
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant