From da81b67dc8b74fdef6691d79ba06b28712c8b046 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 30 Mar 2026 17:10:58 -0500 Subject: fix(org): improve org-mode rendering support --- HutchTests/ReadmeViewTests.swift | 102 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'HutchTests') diff --git a/HutchTests/ReadmeViewTests.swift b/HutchTests/ReadmeViewTests.swift index 8cced03..f338525 100644 --- a/HutchTests/ReadmeViewTests.swift +++ b/HutchTests/ReadmeViewTests.swift @@ -231,6 +231,108 @@ struct OrgRenderingTests { #expect(html.contains("
  • First line continues here
  • ")) } + + @Test + func orgHeaderKeywordsIgnored() { + let html = orgToHTML(""" + #+OPTIONS: toc:nil + #+PROPERTY: header-args :results output + Body text + """) + + #expect(!html.contains("#+OPTIONS")) + #expect(!html.contains("#+PROPERTY")) + #expect(html.contains("

    Body text

    ")) + } + + @Test + func orgVerseBlock() { + let html = orgToHTML(""" + #+begin_verse + There is a line. + And an indented line. + #+end_verse + """) + + #expect(html.contains(#"
    "#)) + #expect(html.contains("There is a line.")) + #expect(html.contains("And an indented line.")) + #expect(!html.contains("#+begin_verse")) + } + + @Test + func orgNamedBlockRendersCaption() { + let html = orgToHTML(""" + #+CAPTION: Build output + #+NAME: build-log + #+begin_example + hello world + #+end_example + """) + + #expect(html.contains(#"
    "#)) + #expect(html.contains("
    Build output
    ")) + #expect(!html.contains("#+CAPTION")) + #expect(!html.contains("#+NAME")) + } + + @Test + func orgLinkedImageRenders() { + let html = orgToHTML("[[https://example.com][[https://img.cleberg.net/apps/hutch/screenshots/ipad/01_patch.jpg]]]") + + #expect(html.contains(#""#)) + #expect(html.contains(#""#)) + } + + @Test + func orgLinkedRelativeImageRenders() { + let html = orgToHTML( + "[[https://example.com/docs][[./images/badge.svg]]]", + imageURLResolver: { source in + source == "./images/badge.svg" ? "https://git.sr.ht/~ccleberg/Hutch/blob/HEAD/images/badge.svg" : nil + } + ) + + #expect(html.contains(#""#)) + #expect(html.contains(#""#)) + } + + @Test + func orgNestedBulletListRendersNestedMarkup() { + let html = orgToHTML(""" + * Lists + ** Unordered + - First bullet + - Second bullet + - Third bullet with /italic/ and *bold* + - Bullet with wrapped + continuation line + - Bullet with nested list + - Nested child one + - Nested child two + - Bullet with inline code ~let x = 1~ + """) + + #expect(html.contains("
      ")) + #expect(html.contains("
    • Bullet with nested list\n
        ")) + #expect(html.contains("
      • Nested child one
      • ")) + #expect(html.contains("
      • Nested child two
      • ")) + #expect(html.contains("
      • Bullet with wrapped continuation line
      • ")) + } + + @Test + func orgTableAlignmentRendersStyles() { + let html = orgToHTML(""" + | Left | Center | Right | + |:-----+:-----:+------:| + | a | b | c | + | 1 | 2 | 3 | + """) + + #expect(html.contains("text-align: left;")) + #expect(html.contains("text-align: center;")) + #expect(html.contains("text-align: right;")) + } } struct RepositoryAssetURLTests { -- cgit v1.2.3