在markdown文本中替换占位符(变量)的最简单方法? [英] Easiest way to replace placeholders (variables) in markdown text?

查看:47
本文介绍了在markdown文本中替换占位符(变量)的最简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种开放格式来以通用方式(带有占位符/变量)编写故事.为了使案例更具针对性,我想设置一个键/值对列表,并在发布时应用它们.我还希望将样式与内容分开,以便可以轻松地发布到Web,pdf等.

I have need for an open format to write stories in a generic way (with placeholder/variables). To make the stories case specific I would like to set a list of key/value pairs and apply them when publishing. I also want to separate styling from content so I can easily publish to web, pdf etc.

示例: @ varname @是个好地方.

我选择Markdown来解决内容/样式分离问题,但是当我使用pandoc之类的工具生成html/pdf输出时,我不知道一种简单的方法来参数化文本的某些部分并填充它们.

I chose Markdown to solve the content/styling separation but I do not know an easy way to parameterize certain parts of the text and have them filled in when I generate the html/pdf outputs with a tool like pandoc.

有什么建议吗?可以使用markdown完成此操作,还是有合适的markdown扩展?

Any suggestions? Can this be done with markdown or is there a suitable markdown extension?

推荐答案

我个人会使用 sed 甚至是 funnelweb 之类的东西,但是您可以做到可以在haskell中使用pandoc过滤器,也可以使用 pandocfilters python库(可能更容易)在此处

Personally, I'd use something like sed, or even funnelweb, but you could do it with a pandoc filter, either in haskell or (probably easier) with the pandocfilters python library available here

这篇关于在markdown文本中替换占位符(变量)的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆