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