Skip to content

Commit

Permalink
fix: broken markdown newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
elyukai committed Mar 6, 2022
1 parent 355daf0 commit c965cb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/ast.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EOL } from "os"
import ts from "typescript"

export namespace JSDoc {
Expand Down Expand Up @@ -59,9 +60,7 @@ export namespace JSDoc {
}

const commentToString = (comment: string | ts.NodeArray<ts.JSDocComment> | undefined) =>
ts.getTextOfJSDocComment(comment)
?.replace(/\r\n(?:\r\n)+/g, "\n\n")
.replace(/\r\n/g, " ")
ts.getTextOfJSDocComment(comment)?.replaceAll(EOL, "\n")

const parseTagComment = <K extends keyof TagValueActualTypes>(name: K, comment: string | undefined): TagValueActualTypes[K] => {
const type = tagValueTypes[name]
Expand Down
5 changes: 4 additions & 1 deletion src/renderers/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ const strictObjectBody = (

return [
title,
config.jsDoc?.comment ?? "",
config.jsDoc?.comment
?.split("\n\n")[0]
?.replaceAll("\n", " ")
?? "",
a("See details", namedLink(propertyPropertyPath))
].join(" | ")
})
Expand Down

0 comments on commit c965cb9

Please sign in to comment.