omnivore-app / obsidian-omnivore

Obsidian plugin to fetch articles and highlights from Omnivore
MIT License
757 stars 41 forks source link

[Feature Request] Wrap title in frontmatter with double quotes #49

Closed SettingDust closed 1 year ago

SettingDust commented 1 year ago

There will be some characters can't be handled by yaml without quotes Should wrap in default template

sywhb commented 1 year ago

Hey @SettingDust , thanks for the advice. I have wrapped the value in frontmatter with double quotes in the default template. You can check the latest release. Next, I will update the document.

jpj625 commented 1 year ago

Problem

Double-quoted titles containing double quotes are broken (and were before too)

Proposal

Change some text field defaults in the template to multiline YAML

title: "Answers to "What is the meaning of life?" - My Blog"  # parsing issue
title_new: >  # works great
  Answers to "What is the meaning of life?" - My Blog

Double-quoted values containing unescaped double quotes are invalid YAML. Double-quoted strings also parse escape sequences (which may be unintended). Single quotes are often a better choice for YAML when unquoted won't work, but the rules for deciding if/which quotes to use are complex. Multiline

A multi-line string as the default template will resolve most simple issues with special characters.

This also may be useful for the author value in some cases.

I'm using this for my template now:

---
id: {{id}}
title: >
  {{{title}}}
{{#author}}
author: >
  {{{author}}}
{{/author}}
…

Idea from https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines/21699210#21699210

jacksonh commented 1 year ago

nice hack @jpj625 seems like we should do this for all attributes that come from the user/content.

sywhb commented 1 year ago

Hey @SettingDust and @jpj625 , the default template is updated to wrap author and title in the multiline string.

Please check it out