fix: Improve reliability of inter-linking documents through importer. closes OLN-156
This commit is contained in:
22
server/utils/turndown/inlineLink.ts
Normal file
22
server/utils/turndown/inlineLink.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import TurndownService from "turndown";
|
||||
|
||||
/**
|
||||
* A turndown plugin for converting anchors to inline links without a title.
|
||||
*
|
||||
* @param turndownService The TurndownService instance.
|
||||
*/
|
||||
export default function underlines(turndownService: TurndownService) {
|
||||
turndownService.addRule("inlineLink", {
|
||||
filter(node, options) {
|
||||
return !!(
|
||||
options.linkStyle === "inlined" &&
|
||||
node.nodeName === "A" &&
|
||||
node.getAttribute("href")
|
||||
);
|
||||
},
|
||||
replacement(content, node: HTMLElement) {
|
||||
const href = node.getAttribute("href");
|
||||
return "[" + content + "](" + href + ")";
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user