Fixed section delimiter conflict with html blocks
This commit is contained in:
parent
7880a5c87d
commit
7c0e6f74e7
@ -35,28 +35,32 @@ define([
|
|||||||
converter.hooks.chain("preConversion", function(text) {
|
converter.hooks.chain("preConversion", function(text) {
|
||||||
eventMgr.previewStartTime = new Date();
|
eventMgr.previewStartTime = new Date();
|
||||||
var tmpText = text + "\n\n";
|
var tmpText = text + "\n\n";
|
||||||
|
function addSection(startOffset, endOffset) {
|
||||||
|
var sectionText = tmpText.substring(offset, endOffset);
|
||||||
|
sectionList.push({
|
||||||
|
text: sectionText,
|
||||||
|
textWithDelimiter: '\n~~~SectionDelimiter~~~\n\n' + sectionText + '\n'
|
||||||
|
});
|
||||||
|
}
|
||||||
var sectionList = [], offset = 0;
|
var sectionList = [], offset = 0;
|
||||||
// Look for delimiters
|
// Look for delimiters
|
||||||
tmpText.replace(regexp, function(match, matchOffset) {
|
tmpText.replace(regexp, function(match, matchOffset) {
|
||||||
// Create a new section with the text preceding the delimiter
|
// Create a new section with the text preceding the delimiter
|
||||||
var sectionText = tmpText.substring(offset, matchOffset);
|
addSection(offset, matchOffset);
|
||||||
sectionList.push({
|
|
||||||
text: sectionText,
|
|
||||||
textWithDelimiter: '\n<div class="se-section-delimiter"></div>\n\n' + sectionText + '\n'
|
|
||||||
});
|
|
||||||
offset = matchOffset;
|
offset = matchOffset;
|
||||||
});
|
});
|
||||||
// Last section
|
// Last section
|
||||||
var sectionText = tmpText.substring(offset, text.length);
|
addSection(offset, text.length);
|
||||||
sectionList.push({
|
|
||||||
text: sectionText,
|
|
||||||
textWithDelimiter: '\n<div class="se-section-delimiter"></div>\n\n' + sectionText + '\n'
|
|
||||||
});
|
|
||||||
eventMgr.onSectionsCreated(sectionList);
|
eventMgr.onSectionsCreated(sectionList);
|
||||||
return _.reduce(sectionList, function(result, section) {
|
return _.reduce(sectionList, function(result, section) {
|
||||||
return result + section.textWithDelimiter;
|
return result + section.textWithDelimiter;
|
||||||
}, '');
|
}, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
converter.hooks.chain("postConversion", function(text) {
|
||||||
|
// Convert delimiters into hidden elements
|
||||||
|
return text.replace(/<p>~~~SectionDelimiter~~~<\/p>/g, '<div class="se-section-delimiter"></div>');
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return markdownSectionParser;
|
return markdownSectionParser;
|
||||||
|
Loading…
Reference in New Issue
Block a user