This commit is contained in:
ZigHolding 2025-07-05 23:42:18 +08:00
parent 09cb452eb7
commit f9c9a2ca65
3 changed files with 19 additions and 5 deletions

View file

@ -2,5 +2,5 @@
"strict_mode": false,
"vaultDir": "D:\\iLanix\\Obsidian\nD:\\github\\ObsidianZY",
"git_repo": "https://github.com/zigholding/ObsidianZ/tree/master\nhttps://gitee.com/zigholding/ObsidianZ/tree/master",
"wxmp_config": ""
"wxmp_config": "h1: ob 公众号标题 h1 样式\nh2: ob 公众号标题 h2 样式\nh3: ob 公众号标题 hx 样式\np code: ob 公众号行内代码样式\nli code: ob 公众号行内代码样式"
}

View file

@ -221,13 +221,25 @@ const cmd_export_wxmp = (plugin:NoteSyncPlugin) => ({
hotkeys: [{ modifiers: ['Alt', 'Shift'], key: 'P' }],
callback: async () => {
if(!plugin.easyapi.cfile){return}
let htmls = [];
let ctx = plugin.easyapi.ceditor.getSelection();
if(!ctx){
ctx = await plugin.app.vault.read(plugin.easyapi.cfile);
for(let section of plugin.easyapi.cmeta?.sections || []){
if(section.type=='yaml'){
continue
}
let sec = plugin.easyapi.editor.slice_by_position(ctx,section.position);
let html = plugin.wxmp.marked.marked(sec);
let rhtml = await plugin.wxmp.html_to_wxmp(html);
htmls.push(rhtml);
}
}else{
let html = plugin.wxmp.marked.marked(ctx);
let rhtml = await plugin.wxmp.html_to_wxmp(html);
htmls.push(rhtml);
}
let html = plugin.wxmp.marked.marked(ctx);
let rhtml = await plugin.wxmp.html_to_wxmp(html);
plugin.wxmp.copy_as_html(rhtml);
plugin.wxmp.copy_as_html(htmls);
new Notice(`${plugin.strings.cmd_export_wxmp}: OK`,5000)
}
});

View file

@ -21,6 +21,9 @@ export class Wxmp {
for(let line of this.plugin.settings.wxmp_config.split('\n')){
let [key, value] = line.split(':');
if(!key || !value){continue}
key = key.trim();
value = value.trim();
if(!key || !value){continue}
config[key] = value;
}
if(!config['h1']){
@ -156,7 +159,6 @@ export class Wxmp {
// 模板渲染传入content
let rendered = await this.plugin.easyapi.tpl.parse_templater(tpl, true, content);
if (rendered.length > 0) {
// 只替换内容,不替换标签和属性
item.innerHTML = rendered[0];
}
}