~, *, +, and _ must be escaped in some cases for asciidoc (and all cases when doubled).  The rules for when they must be escaped is fairly confusing and backslash-escaping is disallowed when either the escaping is non-mandatory or the characters are doubled.

I'm willing to submit a patch, but wanted some thoughts on the approach first

Simple test-case that shows the issue:

---
pandoc -f html -t asciidoctor /dev/stdin <<EOF
<p>*foo*</p>
<p><b>foo</b></p>
EOF

---

Will yield identical asciidoc (with strong tag) for both paragraphs and results in bolded text for both cases.

I have found two ways to escape that work in both asciidoc and asciidoctor (with examples using an asterisk):

1. Define an attribute for each character that needs to be escaped, and use that; the definitions can go anywhere in the document before being used, with the header being typical:

---
:star: *

{star}
---

2. Use a passthrough:

---
pass:specialcharacters[*]
---

#2 lets you escape any arbitrary strings, so escapeString could just render any string with special characters as:

pass:specialcharacters[this is some text that has * special + characters]

I'm leaning towards implementing #2 as it's easier to implement and #1 requires rendering the header correctly.  #1 probably is closer to how I would hand-write these escapes though.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/5c3d5ae9-c427-402e-90bd-41705fdbcb1an%40googlegroups.com.