Skip to content

Commit

Permalink
feat(md): catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Mar 16, 2021
1 parent f2f2534 commit 9d71a3d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/importer/PageImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,15 @@ export default abstract class PageImporter implements Importer {
postProcessMD(md: string): string {
let ret = md.replace(/\\\\\~/gm, '\\~');

const hlxReplaceTags = ret.match(/hlx_replaceTag\(.*?\)/gm).filter((i, p, s) => s.indexOf(i) === p);
hlxReplaceTags.forEach(r => {
const by = r.substring(0, r.length -1).split('(')[1];
const regex = new RegExp(r.replace('(', '\\(').replace(')', '\\)'), 'gm');
ret = ret.replace(regex, `<${by}>`);
});
const match = ret.match(/hlx_replaceTag\(.*?\)/gm);
if (match) {
const hlxReplaceTags = match.filter((i, p, s) => s.indexOf(i) === p);
hlxReplaceTags.forEach(r => {
const by = r.substring(0, r.length -1).split('(')[1];
const regex = new RegExp(r.replace('(', '\\(').replace(')', '\\)'), 'gm');
ret = ret.replace(regex, `<${by}>`);
});
}

return ret;
}
Expand Down

0 comments on commit 9d71a3d

Please sign in to comment.