update#3
Conversation
|
Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges. Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Walkthrough그룹화된 코드 탭 마크업과 언어 처리 방식이 Bootstrap 5 스타일로 변경되고(언어 접두사 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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 |
Bumps [underscore](https://github.com/jashkenas/underscore) from 1.13.7 to 1.13.8. - [Commits](jashkenas/underscore@1.13.7...1.13.8) --- updated-dependencies: - dependency-name: underscore dependency-version: 1.13.8 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@library.js`:
- Line 144: The current langCodeRegex and extraction
(langCodeRegex.exec(codeArray[i])[1].replace(/^language-/, '')) can yield
multi-class values like "language-python hljs" which produce invalid IDs; update
the extraction logic used with langCodeRegex and lang[i] (and its later use in
id="${lang[i] + count + id}") to isolate only the token that starts with
"language-" (for example change the regex to capture only the language token or
split the captured class string on whitespace and pick the element matching
/^language-/), then strip the "language-" prefix to produce a single-word
language identifier for lang[i].
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e9519a56-9a0f-4be8-97f6-0ea5dee31f79
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
README.mdlibrary.jspackage.json
| let lang = []; | ||
| for (let i in codeArray) { | ||
| lang[i] = langCodeRegex.exec(codeArray[i])[1]; // extract lang for code | ||
| lang[i] = langCodeRegex.exec(codeArray[i])[1].replace(/^language-/, ''); // extract lang for code |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for code class patterns in the markdown plugin
# Check how markdown plugin generates code block classes
rg -n 'class=.*language' --type js -C 3Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Find library.js file
find . -name "library.js" -type fRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 93
🏁 Script executed:
# Search for langCodeRegex definition and usage
rg -n "langCodeRegex" -A 5 -B 5Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 1749
🏁 Script executed:
# Check the actual code blocks around line 144
fd "library.js" --exec head -n 160 {} \; | tail -n 30Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 1676
🏁 Script executed:
# Search for markdown plugin references and code block generation
rg -n "language-" -A 2 -B 2 --type jsRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 468
🏁 Script executed:
# Check if there's a markdown plugin or configuration
find . -name "*markdown*" -type f -o -name "*highlight*" -type f | head -20Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 299
🏁 Script executed:
# Search for how <code> tags are generated
rg -n "<code class" -A 1 -B 1 --type jsRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 321
🏁 Script executed:
# Check the package.json to see what markdown/highlight dependencies are used
cat package.json | grep -A 10 -B 10 "mark\|highlight"Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 1267
🏁 Script executed:
# Search for any test files or examples showing code block formats
find . -name "*.test.js" -o -name "*.spec.js" -o -name "*test*" -type f | head -10Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check if there's any configuration or documentation about code block format
rg -n "hljs\|highlight\|language-" --type json --type mdRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check if nodebb-plugin-markdown generates code blocks with multiple classes
# Look at the structure of codeArray elements to understand the format
rg -n "codeArray\|codeTab" -A 3 -B 3 library.js | head -40Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Search NodeBB markdown plugin documentation or look for test patterns
# Check if there's any example showing what classes are added
rg -n "hljs\|highlight\.js\|highlight" --type jsRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Look for any indication of how <code> elements are formatted
cat library.js | grep -n "class=" | head -20Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 1991
🏁 Script executed:
# Check git log to see if there are any commits mentioning code class format
git log --oneline --all | head -20Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 944
🏁 Script executed:
# Look at the README for any documentation about the code block format
cat README.md | head -100Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 3104
🏁 Script executed:
# Search for any mention of how the markdown plugin processes code
rg -n "nodebb-plugin-markdown\|markdown" README.mdRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check if there's any commit message or documentation about code class format
git log --all --grep="language\|class\|code" --oneline | head -10Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 405
🏁 Script executed:
# Look at the actual structure of what's being processed
# Check if there are any tests or examples in the repo
find . -type f \( -name "*.md" -o -name "*.txt" \) -exec grep -l "language-\|hljs" {} \;Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check the exact behavior by examining what nodebb-plugin-markdown likely produces
# Look for any comments in library.js about the expected format
sed -n '135,155p' library.jsRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 1558
🏁 Script executed:
# Check what highlight.js typically generates
# Look for any documentation or examples about the class format
rg -n "hljs\|highlight" . --type md --type jsonRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Verify if the issue would occur by checking what classes markdown produces
# Look for the actual output format in any test or example
find . -type f -name "*.json" -o -name "*.txt" | xargs grep -l "language-" 2>/dev/null | head -5Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check if there's any real-world example in commit history showing the HTML output
git log -p --all | grep -A 3 '<code class=' | head -20Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 63
🏁 Script executed:
# Check the nodebb-plugin-markdown documentation or its typical behavior
# Since it's a peer dependency, let's see if there are any related issues or docs
rg -n "peer" package.json -A 5Repository: fvoci/nodebb-plugin-extended-markdown
Length of output: 181
🏁 Script executed:
# Create a simple test to understand the regex behavior
node <<'EOF'
const langCodeRegex = /<code class="(.+)">/;
// Test cases based on typical markdown/highlight.js output
const testCases = [
'<code class="language-python">',
'<code class="language-python hljs">',
'<code class="python">',
'<code class="language-javascript highlight">',
];
console.log("Testing langCodeRegex behavior:");
testCases.forEach(test => {
const match = langCodeRegex.exec(test);
if (match) {
const extracted = match[1];
const afterReplace = extracted.replace(/^language-/, '');
const isValidId = !afterReplace.includes(' ');
console.log(`\nInput: ${test}`);
console.log(`Captured: "${extracted}"`);
console.log(`After replace: "${afterReplace}"`);
console.log(`Valid HTML ID: ${isValidId}`);
}
});
// Test the proposed fix
const proposedRegex = /<code class="(?:language-)?([^\s"]+)/;
console.log("\n\nTesting proposed regex:");
testCases.forEach(test => {
const match = proposedRegex.exec(test);
if (match) {
const extracted = match[1];
console.log(`\nInput: ${test}`);
console.log(`Captured: "${extracted}"`);
console.log(`Valid HTML ID: ${!extracted.includes(' ')}`);
}
});
EOFRepository: fvoci/nodebb-plugin-extended-markdown
Length of output: 949
langCodeRegex가 여러 클래스를 포함할 경우 유효하지 않은 HTML ID를 생성합니다.
/<code class="(.+)">/ 정규식이 class 속성의 전체 값을 캡처합니다. 마크다운 플러그인이 "language-python hljs" 같은 다중 클래스를 생성하면, .replace(/^language-/, '')를 적용한 후 python hljs 같은 공백을 포함한 문자열이 탭 ID로 사용되어 유효하지 않은 HTML ID가 됩니다 (라인 150-151에서 id="${lang[i] + count + id}"로 사용됨).
🛠️ 언어만 추출하도록 정규식 수정 제안
-const langCodeRegex = /<code class="(.+)">/;
+const langCodeRegex = /<code class="(?:language-)?([^\s"]+)/;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@library.js` at line 144, The current langCodeRegex and extraction
(langCodeRegex.exec(codeArray[i])[1].replace(/^language-/, '')) can yield
multi-class values like "language-python hljs" which produce invalid IDs; update
the extraction logic used with langCodeRegex and lang[i] (and its later use in
id="${lang[i] + count + id}") to isolate only the token that starts with
"language-" (for example change the regex to capture only the language token or
split the captured class string on whitespace and pick the element matching
/^language-/), then strip the "language-" prefix to produce a single-word
language identifier for lang[i].
The tooltipRegex used .* for both the display-text and tooltip-text
captures, which greedily ran to the last ° / ) on the line. When a user
followed a bubble with another parenthesized phrase on the same line,
e.g.
°°(tooltip text) (something else)
the tooltip captured "tooltip text) (something else" instead of just
"tooltip text". A real example surfaced on diy-il.forum where a user
wrote a bubble immediately followed by an explanatory parenthetical and
the rendered title contained both phrases joined by stray parens.
Replace the two .* captures with bounded character classes:
- display text: [^°]* — cannot cross the bubble's own closing °
(also fixes two adjacent bubbles on one line eating each other)
- tooltip text: [^)]* — stops at the first ), the literal terminator
Newlines previously masked the bug (. doesn't cross \n in JS by default),
which is why pressing Enter after the bubble appeared to "fix" it.
Co-authored-by: shraga100 <shraga100@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
library.js (1)
144-151:⚠️ Potential issue | 🟠 Major | ⚡ Quick win그룹 코드 언어 추출이 클래스 전체를 가져와 탭 연결을 깨뜨립니다.
Line 144에서
class전체 문자열을 언어로 사용해 공백이 포함될 수 있고, 이 값이 Line 150-151의id/data-bs-target로 흘러가 탭 패널 매칭이 실패할 수 있습니다. 언어 토큰만 분리해서 사용해야 합니다.수정 예시
-const langCodeRegex = /<code class="(.+)">/; +const langCodeRegex = /<code class="([^"]+)">/; ... - lang[i] = langCodeRegex.exec(codeArray[i])[1].replace(/^language-/, ''); // extract lang for code + const classAttr = langCodeRegex.exec(codeArray[i])?.[1] || ''; + const langToken = classAttr.split(/\s+/).find(token => token.startsWith('language-')) || classAttr.split(/\s+/)[0] || 'text'; + lang[i] = langToken.replace(/^language-/, ''); // extract lang for code🤖 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 `@library.js` around lines 144 - 151, The code is using the entire class attribute string as the language (lang[i] = langCodeRegex.exec(codeArray[i])[1]) which can include spaces and break HTML id/data-bs-target matching; update the extraction in the block that builds lang[] so it normalizes to a single language token (e.g., run the regex result through .trim(), split on whitespace and take the first token or further match only the language token like /^language-([^\s]+)/) before using it in menuTab/contentTab IDs; ensure the rest of code (lang[], menuTab, contentTab, capitalizeFirstLetter, count, id) uses that cleaned single token so generated ids/data-bs-target values are valid and unique.
🤖 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.
Duplicate comments:
In `@library.js`:
- Around line 144-151: The code is using the entire class attribute string as
the language (lang[i] = langCodeRegex.exec(codeArray[i])[1]) which can include
spaces and break HTML id/data-bs-target matching; update the extraction in the
block that builds lang[] so it normalizes to a single language token (e.g., run
the regex result through .trim(), split on whitespace and take the first token
or further match only the language token like /^language-([^\s]+)/) before using
it in menuTab/contentTab IDs; ensure the rest of code (lang[], menuTab,
contentTab, capitalizeFirstLetter, count, id) uses that cleaned single token so
generated ids/data-bs-target values are valid and unique.
Bumps [markdown-it](https://github.com/markdown-it/markdown-it) and [nodebb-plugin-markdown](https://github.com/julianlam/nodebb-plugin-markdown). These dependencies needed to be updated together. Updates `markdown-it` from 12.3.2 to 14.2.0 - [Changelog](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md) - [Commits](markdown-it/markdown-it@12.3.2...14.2.0) Updates `nodebb-plugin-markdown` from 13.1.0 to 13.2.5 - [Commits](NodeBB/nodebb-plugin-markdown@v13.1.0...v13.2.5) --- updated-dependencies: - dependency-name: markdown-it dependency-version: 14.2.0 dependency-type: indirect - dependency-name: nodebb-plugin-markdown dependency-version: 13.2.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Summary by CodeRabbit
새로운 기능
버그 수정
문서
기타