aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-convert.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 07:54:34 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 07:54:34 -0500
commitf3b583e67ec18345c2b5c988f452388894363d1e (patch)
treed5e95df54cf379b275f422386fcc92036b338734 /tests/test-pearl-convert.el
parentbd2aa5705d94b7d403096c62637e64c479ea0de5 (diff)
downloadpearl-f3b583e67ec18345c2b5c988f452388894363d1e.tar.gz
pearl-f3b583e67ec18345c2b5c988f452388894363d1e.zip
feat: render inline code spans verbatim in the Org buffer
A fetched description with markdown inside backticks — `**bold**`, `[text](url)`, `_italic_` — got its span contents converted along with the surrounding prose, so the Org buffer showed `*bold*` and `[[url][text]]` inside what should read as literal code. Markdown treats a code span as opaque; the converter didn't. Both converters now tokenize code spans first and apply link/bold/italic conversion only to the text between them, keeping span contents literal. The md->org and org->md directions each split into an emphasis-only helper (pearl--md-emphasis-to-org, pearl--org-emphasis-to-md) called on the gaps, with the span passed through untouched. Keeping the split symmetric is what preserves the round-trip identity a fetch + no-edit push depends on. A new test asserts the verbatim rendering for bold, link, and italic inside a span, plus emphasis still converting outside one and between two spans.
Diffstat (limited to 'tests/test-pearl-convert.el')
-rw-r--r--tests/test-pearl-convert.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test-pearl-convert.el b/tests/test-pearl-convert.el
index 1337439..2e278de 100644
--- a/tests/test-pearl-convert.el
+++ b/tests/test-pearl-convert.el
@@ -170,10 +170,10 @@ the conversion-tier docstring) and are excluded here."
(ert-deftest test-pearl-convert-roundtrip-boundary-cases ()
"Round-trip identity holds across markdown boundary cases — the property that
-keeps a fetch + no-edit push from changing the remote. Two of these round-trip
-safely despite an imperfect intermediate Org form: a URL containing parens, and
-inline code whose contents look like markdown (rendered converted in the Org
-view, but reversed exactly on push)."
+keeps a fetch + no-edit push from changing the remote. A URL containing parens
+round-trips despite an imperfect intermediate Org form; inline code whose
+contents look like markdown round-trips because both converters keep code-span
+contents verbatim rather than translating inside them."
(dolist (md '("[a](u1) and [b](u2)" ; multiple links on a line
"see [docs](http://x.com/(p))" ; parens inside the URL
"`**b** and [l](u) and _i_`" ; markdown-looking inline code
@@ -182,5 +182,17 @@ view, but reversed exactly on push)."
"text\n```python\nx = 1\n```\nafter")) ; fence with trailing text
(should (string= md (pearl--org-to-md (pearl--md-to-org md))))))
+(ert-deftest test-pearl-md-line-code-span-verbatim ()
+ "Markdown inside an inline code span renders verbatim, not converted."
+ ;; bold / link / italic inside backticks stay literal in the Org code span
+ (should (string= "~**b**~" (pearl--md-line-to-org "`**b**`")))
+ (should (string= "~[l](u)~" (pearl--md-line-to-org "`[l](u)`")))
+ (should (string= "~_i_~" (pearl--md-line-to-org "`_i_`")))
+ ;; emphasis outside the code span still converts
+ (should (string= "*x* ~**y**~" (pearl--md-line-to-org "**x** `**y**`")))
+ ;; convertible text between two code spans is still converted
+ (should (string= "~**a**~ and [[u][l]]"
+ (pearl--md-line-to-org "`**a**` and [l](u)"))))
+
(provide 'test-pearl-convert)
;;; test-pearl-convert.el ends here