NetNewsWire/Shared/Exporters/OPMLExporter.swift

41 lines
752 B
Swift
Raw Normal View History

//
// OPMLExporter.swift
2018-08-29 07:18:24 +02:00
// NetNewsWire
//
// Created by Brent Simmons on 12/22/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
import Account
struct OPMLExporter {
2024-05-02 06:50:55 +02:00
@MainActor static func OPMLString(with account: Account, title: String) -> String {
let escapedTitle = title.escapingSpecialXMLCharacters
let openingText =
"""
<?xml version="1.0" encoding="UTF-8"?>
2018-08-29 07:18:24 +02:00
<!-- OPML generated by NetNewsWire -->
<opml version="1.1">
<head>
<title>\(escapedTitle)</title>
</head>
<body>
"""
let middleText = account.OPMLString(indentLevel: 0)
let closingText =
"""
</body>
</opml>
"""
let opml = openingText + middleText + closingText
return opml
}
}