0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 18:12:40 +00:00
[EDITOR] Fix div links #2680
This commit is contained in:
Trevor Buckner
2023-03-23 12:16:27 -04:00
committed by GitHub
3 changed files with 17 additions and 5 deletions

View File

@@ -80,6 +80,15 @@ pre {
## changelog
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).
### XXXXday DD/MM/2023 - v3.8.0
{{taskList
##### G-Ambatte
* [x] Fix internal links inside `<div>` blocks not automatically receiving the `target=_self` attribute
Fixes issues [#2680](https://github.com/naturalcrit/homebrewery/issues/2680)
}}
### Monday 13/03/2023 - v3.7.2
{{taskList

View File

@@ -239,7 +239,7 @@ const definitionLists = {
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists] });
Marked.use(MarkedExtendedTables());
Marked.use(mustacheInjectBlock);
Marked.use({ smartypants: true });
Marked.use({ renderer: renderer, smartypants: true });
//Fix local links in the Preview iFrame to link inside the frame
renderer.link = function (href, title, text) {
@@ -347,10 +347,7 @@ module.exports = {
render : (rawBrewText)=>{
rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n<div class='columnSplit'></div>\n`)
.replace(/^(:+)$/gm, (match)=>`${`<div class='blank'></div>`.repeat(match.length)}\n`);
return Marked.parse(
sanatizeScriptTags(rawBrewText),
{ renderer: renderer }
);
return Marked.parse(sanatizeScriptTags(rawBrewText));
},
validate : (rawBrewText)=>{

View File

@@ -13,3 +13,9 @@ test('Processes the markdown within an HTML block if its just a class wrapper',
const rendered = Markdown.render(source);
expect(rendered).toBe('<div> <p><em>Bold text</em></p>\n </div>');
});
test('Check markdown is using the custom renderer; specifically that it adds target=_self attribute to internal links in HTML blocks', function() {
const source = '<div>[Has _self Attribute?](#p1)</div>';
const rendered = Markdown.render(source);
expect(rendered).toBe('<div> <p><a href="#p1" target="_self">Has _self Attribute?</a></p>\n </div>');
});