| @@ -26,10 +26,17 @@ public struct OrgRenderOptions { |
| 26 | public var owner: String? |
26 | public var owner: String? |
| 27 | /// Repository name. Nil disables relative-link resolution. |
27 | /// Repository name. Nil disables relative-link resolution. |
| 28 | public var repositoryName: String? |
28 | public var repositoryName: String? |
| 29 | /// Git ref used in the `blob/<ref>` path segment. |
29 | /// Git ref used in the `<segment>/<ref>` path segment. |
| 30 | public var ref: String |
30 | public var ref: String |
| 31 | /// Path of the README being rendered, used to resolve paths relative to it. |
31 | /// Path of the README being rendered, used to resolve paths relative to it. |
| 32 | public var readmePath: String? |
32 | public var readmePath: String? |
| |
33 | /// Path segment for a resolved relative *image* URL: `<host>/<owner>/<repo>/<segment>/…`. |
| |
34 | /// Defaults to `blob`; forges that serve raw bytes on a different route (gitbay uses |
| |
35 | /// `raw`) set this so an `<img src>` points at the file, not its HTML viewer page. |
| |
36 | public var imagePathSegment: String |
| |
37 | /// Path segment for a resolved relative *link* URL. Defaults to `blob` — a link should |
| |
38 | /// open the file's page, not its raw bytes. |
| |
39 | public var linkPathSegment: String |
| 33 | /// Emit a leading `<div class="org-metadata">` block for `#+TITLE`/`#+AUTHOR`/`#+DATE`. |
40 | /// Emit a leading `<div class="org-metadata">` block for `#+TITLE`/`#+AUTHOR`/`#+DATE`. |
| 34 | /// Apps that show a README title want this; orgo treats those keywords as document |
41 | /// Apps that show a README title want this; orgo treats those keywords as document |
| 35 | /// metadata carried by the page template, not body content, so the conformance corpus |
42 | /// metadata carried by the page template, not body content, so the conformance corpus |
| @@ -47,7 +54,9 @@ public struct OrgRenderOptions { |
| 47 | ref: String = "HEAD", |
54 | ref: String = "HEAD", |
| 48 | readmePath: String? = nil, |
55 | readmePath: String? = nil, |
| 49 | metadataHeader: Bool = true, |
56 | metadataHeader: Bool = true, |
| 50 | headingLevelOffset: Int = 0 |
57 | headingLevelOffset: Int = 0, |
| |
58 | imagePathSegment: String = "blob", |
| |
59 | linkPathSegment: String = "blob" |
| 51 | ) { |
60 | ) { |
| 52 | self.host = host |
61 | self.host = host |
| 53 | self.owner = owner |
62 | self.owner = owner |
| @@ -56,6 +65,8 @@ public struct OrgRenderOptions { |
| 56 | self.readmePath = readmePath |
65 | self.readmePath = readmePath |
| 57 | self.metadataHeader = metadataHeader |
66 | self.metadataHeader = metadataHeader |
| 58 | self.headingLevelOffset = headingLevelOffset |
67 | self.headingLevelOffset = headingLevelOffset |
| |
68 | self.imagePathSegment = imagePathSegment |
| |
69 | self.linkPathSegment = linkPathSegment |
| 59 | } |
70 | } |
| 60 | |
71 | |
| 61 | func imageURLResolver() -> ((String) -> String?)? { |
72 | func imageURLResolver() -> ((String) -> String?)? { |
| @@ -63,6 +74,7 @@ public struct OrgRenderOptions { |
| 63 | let host = host |
74 | let host = host |
| 64 | let ref = ref |
75 | let ref = ref |
| 65 | let readmePath = readmePath |
76 | let readmePath = readmePath |
| |
77 | let segment = imagePathSegment |
| 66 | return { source in |
78 | return { source in |
| 67 | resolveRepositoryAssetURL( |
79 | resolveRepositoryAssetURL( |
| 68 | source, |
80 | source, |
| @@ -70,7 +82,8 @@ public struct OrgRenderOptions { |
| 70 | owner: owner, |
82 | owner: owner, |
| 71 | repositoryName: repositoryName, |
83 | repositoryName: repositoryName, |
| 72 | ref: ref, |
84 | ref: ref, |
| 73 | readmePath: readmePath |
85 | readmePath: readmePath, |
| |
86 | pathSegment: segment |
| 74 | ) |
87 | ) |
| 75 | } |
88 | } |
| 76 | } |
89 | } |
| @@ -80,6 +93,7 @@ public struct OrgRenderOptions { |
| 80 | let host = host |
93 | let host = host |
| 81 | let ref = ref |
94 | let ref = ref |
| 82 | let readmePath = readmePath |
95 | let readmePath = readmePath |
| |
96 | let segment = linkPathSegment |
| 83 | return { source in |
97 | return { source in |
| 84 | resolveRepositoryLinkURL( |
98 | resolveRepositoryLinkURL( |
| 85 | source, |
99 | source, |
| @@ -87,7 +101,8 @@ public struct OrgRenderOptions { |
| 87 | owner: owner, |
101 | owner: owner, |
| 88 | repositoryName: repositoryName, |
102 | repositoryName: repositoryName, |
| 89 | ref: ref, |
103 | ref: ref, |
| 90 | readmePath: readmePath |
104 | readmePath: readmePath, |
| |
105 | pathSegment: segment |
| 91 | ) |
106 | ) |
| 92 | } |
107 | } |
| 93 | } |
108 | } |