Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导出word时所有嵌入的内容都仅以文字显示呈现 #128

Closed
wwjCMP opened this issue Oct 14, 2023 · 4 comments
Closed

导出word时所有嵌入的内容都仅以文字显示呈现 #128

wwjCMP opened this issue Oct 14, 2023 · 4 comments

Comments

@wwjCMP
Copy link

wwjCMP commented Oct 14, 2023

比如嵌入的文章
![[dfdfs]]

比如嵌入的图片
![[A1-附件/sjfjofpgw.png]]

@mokeyish
Copy link
Owner

不支持 wikilinks,用标准的 markdown 语法

@TimFruit
Copy link

TimFruit commented Nov 4, 2023

主要看这个 #74

下面这个方面一点,但也不是很好,会出现图片路径

image

@TimFruit
Copy link

TimFruit commented Nov 4, 2023

主要看这个 #74

image

通过lua脚本我现在可以了

function Pandoc(doc)
  -- 遍历文档中的所有块元素
  for i, block in pairs(doc.blocks) do
    if block.t == 'Para' then
      -- 在段落文本中进行替换
      doc.blocks[i] = pandoc.Para(replace_wikilinks(block.content))
    end
  end
  return doc
end

function replace_wikilinks(content)
  local new_content = {}
  local text = pandoc.utils.stringify(content)

  -- 使用正则表达式匹配文本中的 Wikilink 格式
  text = text:gsub("!(%[%[[^%]]*%]%])", function(link)
    local img_path = link:match("%[%[([^%]]*)%]%]")
    return "![](" .. img_path .. ")"
  end)

  return pandoc.read(text).blocks[1].content
end

return { { Pandoc = Pandoc } }

@mokeyish
Copy link
Owner

mokeyish commented Feb 2, 2024

#154

@mokeyish mokeyish closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants