johnxnguyen / Down

Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark.
Other
2.24k stars 319 forks source link

Bulleted list does not indent properly #290

Open ykphuah opened 1 year ago

ykphuah commented 1 year ago

Please help prevent duplicate issues before submitting a new one:

Report

What did you do?

Convert markdown text to attributed string, with bulleted lists spanning multiple lines.

What did you expect to happen?

The bulleted list to be indented properly.

What happened instead?

The bulleted list is not indented properly.

Screenshot 2022-12-03 at 3 41 59 PM
ykphuah commented 1 year ago

I tried looking into the codes, and found out that by commenting this one line, the indent showed up ok.

diff --git a/Sources/Down/AST/Styling/Helpers/ListItemParagraphStyler.swift b/Sources/Down/AST/Styling/Helpers/ListItemParagraphStyler.swift
index 71313bd..ab76f30 100644
--- a/Sources/Down/AST/Styling/Helpers/ListItemParagraphStyler.swift
+++ b/Sources/Down/AST/Styling/Helpers/ListItemParagraphStyler.swift
@@ -70,7 +70,7 @@ public class ListItemParagraphStyler {
         let firstLineContentIndentation = contentIndentation + prefixSpill

         let style = baseStyle
-        style.firstLineHeadIndent = prefixIndentation
+        // style.firstLineHeadIndent = prefixIndentation
         style.tabStops = [tabStop(at: firstLineContentIndentation)]
         style.headIndent = contentIndentation
         return style
Screenshot 2022-12-03 at 3 47 27 PM

It does remove some indent from the starting though, which I am not sure what are they really for.