Skip to content

Commit 4cca337

Browse files
committed
fix: remove maybeUnwrapTopLevelPWithA
1 parent fc64a24 commit 4cca337

3 files changed

Lines changed: 4 additions & 42 deletions

File tree

docs/_sidebar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
- [Embed Files](embed-files.md)
2828
- [UI Kit](ui-kit.md)
2929

30-
- [Awesome docsify](awesome.md)
31-
- [Changelog](changelog.md)
30+
* [Awesome docsify](awesome.md)
31+
* [Changelog](changelog.md)

src/core/render/compiler.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { tree as treeTpl } from './tpl.js';
55
import { genTree } from './gen-tree.js';
66
import { slugify } from './slugify.js';
77
import { emojify } from './emojify.js';
8-
import { getAndRemoveConfig, maybeUnwrapTopLevelPWithA } from './utils.js';
8+
import { getAndRemoveConfig } from './utils.js';
99
import { imageCompiler } from './compiler/image.js';
1010
import { headingCompiler } from './compiler/heading.js';
1111
import { highlightCodeCompiler } from './compiler/code.js';
@@ -193,8 +193,7 @@ export class Compiler {
193193

194194
// compile sidebar from _sidebar.md
195195
if (text) {
196-
html = this.compile(text);
197-
return maybeUnwrapTopLevelPWithA(html);
196+
return this.compile(text);
198197
}
199198
// compile sidebar from content's headings toc
200199
for (let i = 0; i < toc.length; i++) {

src/core/render/utils.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -88,40 +88,3 @@ export function getAndRemoveDocsifyIgnoreConfig(content = '') {
8888

8989
return { content, ignoreAllSubs, ignoreSubHeading };
9090
}
91-
92-
/**
93-
* Unwraps <p> tags that directly wrap a single <a> tag inside <li> elements at the top level.
94-
*
95-
* This function processes an HTML string and removes <p> wrappers inside <li> elements
96-
* when the <p> contains exactly one <a> element and no other content.
97-
*
98-
* It does NOT process nested structures.
99-
*
100-
* @see https://github.com/markedjs/marked/issues/1461
101-
* @param {string} html - The HTML string to transform.
102-
* @returns {string} - The transformed HTML with <p> removed from <li><p><a></a></p></li> structures.
103-
*/
104-
export function maybeUnwrapTopLevelPWithA(html) {
105-
// Only unwrap if the pattern <li><p><a exists
106-
if (!html.includes('<li><p><a')) {
107-
return html;
108-
}
109-
110-
const template = document.createElement('template');
111-
template.innerHTML = html;
112-
113-
template.content.querySelectorAll('li').forEach(li => {
114-
const first = li.firstElementChild;
115-
if (
116-
first?.tagName === 'P' &&
117-
first.children.length === 1 &&
118-
first.firstElementChild.tagName === 'A' &&
119-
first.childNodes.length === 1
120-
) {
121-
// Replace the <p> with the <a> inside it
122-
li.replaceChild(first.firstElementChild, first);
123-
}
124-
});
125-
126-
return template.innerHTML;
127-
}

0 commit comments

Comments
 (0)