def replace_citations_strings_with_ids(text, string_to_id):
"""
Convert citations to their IDs for pandoc.
`text` is markdown source text
`string_to_id` is a dictionary like:
@10.7287/peerj.preprints.3100v1 ? 11cb5HXoY
"""
for old, new in string_to_id.items():
text = re.sub(
pattern=re.escape(old) + r'(?![\w:.#$%&\-+?<>~/]*[a-zA-Z0-9/])',
repl='@' + new,
string=text,
)
return text
评论列表
文章目录