opmltotext
v1.0.0
Published
Parses OPML and returns text.
Downloads
171
Readme
opmltotext
This is a node.js library that parses OPML and returns text. It generates output using specified indentation and comment prefix strings.
Installation
$ npm install opmltotextRequires Node.js 20 or newer.
Example
const fs = require('node:fs');
const OpmlToText = require('opmltotext');
const opml = fs.readFileSync('example.opml', 'utf8');
const text = OpmlToText.getText(opml);See example/ for a complete OPML input and the Markdown it produces.
API
OpmlToText.getText(opmlText, [commentPrefix], [indentation])
opmlTextString— the OPML documentcommentPrefixString— default'//'indentationString— default' '(two spaces)
Each <outline> under <body> becomes a line, indented once per level of nesting.
The text attribute supplies the line content; an outline without one produces an
empty line.
Throws if the document is not well-formed XML or has no <body> element.
Comments
An outline carrying isComment="true" is prefixed with commentPrefix, and so is
everything nested beneath it. The prefix sits at the depth where the comment began,
so deeper nesting is indented after the prefix:
<outline text="Notes">
<outline text="draft" isComment="true">
<outline text="detail"/>
</outline>
</outline>Notes
//draft
// detailA descendant can opt back out with isComment="false".
License
MIT
