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