David Dykstal

David Dykstal

Testing Ulysses

This is a test. It is only a test. Don’t get so worked up about it. :)

Testing some formatting

  • I’ve not posted from Ulysses yet.
  • Let’s see how this works.

Here is some inline code: cd /home/ddykstal.

Here is some code that I use to reformat text in Drafts.

// Get the full text of the clipping as an array of strings
let a = editor.getText().split("\n");
let b = [];
let knownSources = [
    {suffix: " - The Washington Post", source: "The Washington Post"},
    {suffix: " - The New York Times", source: "The New York Times"},
    {suffix: " : NPR", source: "NPR"},
    {suffix: " - POLITICO", source: "POLITICO"},
    {suffix: " | MPR News", source: "MPR News"},
    {suffix: " | Star Tribune", source: "Star Tribune"},
    {suffix: " - StarTribune.com", source: "Star Tribune"},
    {suffix: " | MinnPost", source: "MinnPost"},
    {suffix: " | The Hill", source: "The Hill"},
    {suffix: " | The New Republic", source: "The New Republic"},
    {suffix: " - Washington Times", source: "Washington Times"},
];
let found = false;
// copy from a to b, adjusting the Title: line and adding a Source: line if necessary
for (let i = 0; i < a.length; i++) {
    let line = a[i];
    found = false;
    if (line.startsWith("Title: ")) {
        for (let j = 0; j < knownSources.length; j++) {
            let s = knownSources[j];
            if (line.endsWith(s.suffix)) {
                found = true;
                b.push(line.slice(0, -s.suffix.length));
                b.push("Source: " + s.source);
                break;
            }
        }
    }
    if (!found) {
        b.push(line)
    }
}
// Set the full text of the clipping
editor.setText(b.join("\n"));