mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
fix bug where links didn't happen in markdown tables
This commit is contained in:
@@ -52,15 +52,18 @@ marked.use({ extensions: [mermaidExtension] });
|
|||||||
// The renderer only applies to markdown tables.
|
// The renderer only applies to markdown tables.
|
||||||
marked.use({
|
marked.use({
|
||||||
renderer: {
|
renderer: {
|
||||||
tablecell({ text, header, align }) {
|
tablecell(token) {
|
||||||
|
const content = this.parser.parseInline(token.tokens);
|
||||||
|
const { header, align } = token;
|
||||||
const type = header ? "th" : "td";
|
const type = header ? "th" : "td";
|
||||||
const alignAttr = align ? ` align="${align}"` : "";
|
const alignAttr = align ? ` align="${align}"` : "";
|
||||||
const scopeAttr = header ? ' scope="col"' : "";
|
const scopeAttr = header ? ' scope="col"' : "";
|
||||||
return `<${type}${scopeAttr}${alignAttr}>${text}</${type}>\n`;
|
return `<${type}${scopeAttr}${alignAttr}>${content}</${type}>\n`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export function extractImageSources(htmlString: string) {
|
export function extractImageSources(htmlString: string) {
|
||||||
const srcUrls = [];
|
const srcUrls = [];
|
||||||
const regex = /<img[^>]+src=["']?([^"'>]+)["']?/g;
|
const regex = /<img[^>]+src=["']?([^"'>]+)["']?/g;
|
||||||
|
|||||||
16
src/services/markdownReferenceLinks.test.ts
Normal file
16
src/services/markdownReferenceLinks.test.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { markdownToHtmlNoImages } from './htmlMarkdownUtils';
|
||||||
|
|
||||||
|
describe('markdownToHtmlNoImages reference links', () => {
|
||||||
|
it('renders reference links inside a table', () => {
|
||||||
|
const markdown = `
|
||||||
|
| Header |
|
||||||
|
| --- |
|
||||||
|
| [QuickStart][Fort1] |
|
||||||
|
|
||||||
|
[Fort1]: https://example.com/fort1
|
||||||
|
`;
|
||||||
|
const html = markdownToHtmlNoImages(markdown);
|
||||||
|
expect(html).toContain('<a href="https://example.com/fort1">QuickStart</a>');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user