Skip to content

Conversation

@Vemahk
Copy link

@Vemahk Vemahk commented Mar 30, 2024

Howdy.

I've been using Obsidian for writing (not just note taking) for a little while before I stumbled upon this plugin. I wanted to go back and fix all my existing quotations to use the "correct" form. At first, I just got really good with the vim motions of replacing them all, but for some of my multi-ten-thousand word docs, that just wasn't viable. So I tinkered and came up with this.

I mainly did this for my own personal use, so I admit I haven't quite got all the kinks of how to retroactively apply topography to the single quotes (since it's difficult to distinguish apostrophes from single quotations for certain scenarios), but I thought I'd leave this here just in case someone else found it useful. Feel free to modify, critique, merge, or completely ignore this.

@Vemahk
Copy link
Author

Vemahk commented Mar 30, 2024

I do believe this would also solve the same problem the fellows in #29 where asking for. At least in part.

@patrickchiang
Copy link

A couple things:

  1. Is there an aversion to using another library? Because if this is only converting smartquotes, there is a smartquotes.js library that handles this in addition to primes and other edge cases.
  2. Would be nice if there was a command to apply this to the entire vault.
    this.addCommand({
      id: "smart-typography-apply-quotations-vault",
      name: "Apply Smart Quotes to Entire Vault",
      callback: () => {
        for (const file of this.app.vault.getMarkdownFiles()) {
          const view = this.app.vault.read(file)
          if (view) {
            view.then((text) => {
              return smartquotes.string(text);
            }).then((text) => {
              this.app.vault.modify(file, text);
            });
          }
        }
      }
    });

That seemed to work for my naive use case. If not comfortable with using another library, can run through it line-by-line through your algo in apply-quotes.ts too.

@Vemahk
Copy link
Author

Vemahk commented May 24, 2024

Honestly it didn't occur to me that someone else may have written some js module for applying these quotations. Oh well.

I didn't add a full-vault command since I didn't need it. I guess you're welcome to open your own PR for that, but I doubt this one will ever get merged as it is, and I'm allergic to scope creep, so... shrug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants