|
|
@@ -40,10 +40,11 @@ Crowi.appendEditSectionButtons = function(contentId, markdown) {
|
|
|
$('h1,h2,h3,h4,h5,h6', $content).each(function(idx, elm) {
|
|
|
// get header text string
|
|
|
const text = $(this).text();
|
|
|
+ const escapedText = escapeStringRegexp(text);
|
|
|
|
|
|
// search pos for '# ...'
|
|
|
// https://regex101.com/r/y5rpO5/1
|
|
|
- const regexp = new RegExp(`[^\r\n]*#+[^\r\n]*${text}[^\r\n]*`);
|
|
|
+ const regexp = new RegExp(`[^\r\n]*#+[^\r\n]*${escapedText}[^\r\n]*`);
|
|
|
let position = markdown.search(regexp);
|
|
|
if (position < 0) { // if not found, search with header text only
|
|
|
position = markdown.search(text);
|