mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 12:32:39 +00:00
Fix multiline IMG tags breaking
This commit is contained in:
@@ -9,6 +9,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
env : {
|
env : {
|
||||||
browser : true,
|
browser : true,
|
||||||
|
node: true
|
||||||
},
|
},
|
||||||
plugins : ['react'],
|
plugins : ['react'],
|
||||||
rules : {
|
rules : {
|
||||||
@@ -66,7 +67,7 @@ module.exports = {
|
|||||||
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
|
multiLine : { beforeColon: true, afterColon: true, align: 'colon' },
|
||||||
singleLine : { beforeColon: false, afterColon: true }
|
singleLine : { beforeColon: false, afterColon: true }
|
||||||
}],
|
}],
|
||||||
'linebreak-style' : ['warn', 'unix'],
|
'linebreak-style' : 'off',
|
||||||
'no-trailing-spaces' : 'warn',
|
'no-trailing-spaces' : 'warn',
|
||||||
'no-whitespace-before-property' : 'warn',
|
'no-whitespace-before-property' : 'warn',
|
||||||
'object-curly-spacing' : ['warn', 'always'],
|
'object-curly-spacing' : ['warn', 'always'],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const _ = require('lodash');
|
|||||||
const Markdown = require('marked');
|
const Markdown = require('marked');
|
||||||
|
|
||||||
// Copied directly from Marked helpers.js source with permission
|
// Copied directly from Marked helpers.js source with permission
|
||||||
function splitCells(tableRow, count) {
|
const splitCells = function(tableRow, count) {
|
||||||
// ensure that every cell-delimiting pipe has a space
|
// ensure that every cell-delimiting pipe has a space
|
||||||
// before it to distinguish it from an escaped pipe
|
// before it to distinguish it from an escaped pipe
|
||||||
const row = tableRow.replace(/\|/g, (match, offset, str)=>{
|
const row = tableRow.replace(/\|/g, (match, offset, str)=>{
|
||||||
@@ -32,26 +32,31 @@ function splitCells(tableRow, count) {
|
|||||||
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
||||||
}
|
}
|
||||||
return cells;
|
return cells;
|
||||||
}
|
};
|
||||||
|
|
||||||
const renderer = {
|
const renderer = {
|
||||||
// Adjust the way html is handled
|
// Adjust the way html is handled
|
||||||
html(html) {
|
html(html) {
|
||||||
html = _.trim(html)
|
html = _.trim(html);
|
||||||
|
|
||||||
// Process the markdown within Divs
|
// Process the markdown within Divs
|
||||||
if(_.startsWith(html, '<div') && html.includes('>')) {
|
if(_.startsWith(html, '<div') && html.includes('>')) {
|
||||||
let openTag = html.substring(0, html.indexOf('>')+1);
|
const openTag = html.substring(0, html.indexOf('>')+1);
|
||||||
html = html.substring(html.indexOf('>')+1);
|
html = html.substring(html.indexOf('>')+1);
|
||||||
return `${openTag} ${Markdown(html)}`;
|
return `${openTag} ${Markdown(html)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't require a blank line after HTML to parse Markdown
|
// Don't require a blank line after HTML to parse Markdown
|
||||||
if(html.includes('\n')) {
|
if(html.includes('\n')) {
|
||||||
if(_.startsWith(html, '<style') || _.startsWith(html, '<pre')) {
|
if(_.startsWith(html, '<style') || _.startsWith(html, '<pre') || _.startsWith(html, '<img')) {
|
||||||
return html; // Style and Pre tags should not parse Markdown
|
if(html.includes('>')) {
|
||||||
|
const openTag = html.substring(0, html.lastIndexOf('>')+1);
|
||||||
|
html = html.substring(html.lastIndexOf('>')+1);
|
||||||
|
return `${openTag} ${Markdown(html)}`;
|
||||||
}
|
}
|
||||||
let openTag = html.substring(0, html.indexOf('\n')+1);
|
return html; // Style, Pre, and Img tags should not parse Markdown
|
||||||
|
}
|
||||||
|
const openTag = html.substring(0, html.indexOf('\n')+1);
|
||||||
html = html.substring(html.indexOf('\n')+1);
|
html = html.substring(html.indexOf('\n')+1);
|
||||||
return `${openTag} ${Markdown(html)}`;
|
return `${openTag} ${Markdown(html)}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user