Skip to content

Commit

Permalink
feat(md): add hlx_replaceTag function
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe committed Mar 16, 2021
1 parent 0207dd4 commit f2f2534
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/importer/PageImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,16 @@ export default abstract class PageImporter implements Importer {
}

postProcessMD(md: string): string {
return md.replace(/\\\\\~/gm, '\\~');
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}>`);
});

return ret;
}

async download(url: string): Promise<string> {
Expand Down

0 comments on commit f2f2534

Please sign in to comment.