Skip to content

Conversation

@OAbubakr
Copy link

Fix apostrophes and commas in exclusion reasons

Problem

Users encountered two issues when entering exclusion reasons:

  1. Syntax Error 140 when exclusion reasons contained apostrophes (e.g., "doesn't", "isn't", "won't")
  2. Text truncation when exclusion reasons contained commas - only text before the first comma was displayed

Root Cause

  1. Apostrophes/quotes: DiagrammeR's DOT syntax parser failed when unescaped special characters were inserted directly into the graph definition
  2. Commas: The parsing logic used naive regex (",.*$" and ".*,") that split on the first/last comma, truncating exclusion reasons that legitimately contained commas

Solution

1. Added text escaping for DOT syntax

  • Created PRISMA_escape_text_() utility function in utils.R
  • Escapes backslashes, quotes, and apostrophes before inserting into DiagrammeR graph
  • Applied to both dbr_excluded[, 1] and other_excluded[, 1] text

2. Fixed exclusion reason parsing logic

  • Changed from naive comma splitting to pattern-based parsing
  • Before: gsub(",.*$", "", text) - removed everything after first comma
  • After: gsub(",\\s*\\d+\\s*$", "", text) - removes only final comma + number
  • Before: gsub(".*,", "", text) - removed everything before last comma
  • After: gsub("^.*,\\s*(\\d+)\\s*$", "\\1", text) - extracts only final number

@OAbubakr
Copy link
Author

Screenshot from 2025-10-22 14-58-29

@OAbubakr OAbubakr merged commit dc3d932 into master Oct 22, 2025
11 checks passed
@hammady hammady deleted the tasks/7797 branch October 22, 2025 15:34
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.

4 participants