YukiGasai / obsidian-google-calendar

Add Google Calendar inside Obsidian
https://yukigasai.github.io/obsidian-google-calendar/
GNU General Public License v3.0
359 stars 25 forks source link

Troublesome characters in properties of event notes #203

Closed machado-t closed 11 months ago

machado-t commented 11 months ago

I've just stumbled upon this issue. When creating an event note, for which some variables are populated in properties (e.g. "title: <%event?.summary%>"), the character ":" in the summary of the event broke the properties. Maybe other character may have similar problems. Any suggestion on how to fix this? Maybe I should just fix my template. Full template for reference:

<%*
const {getEvent} = this.app.plugins.plugins["google-calendar"].api;  
const event = await getEvent("{{gEvent.id}}", "{{gEvent.parent.id}}");
%><% "---" %>
title: <%event?.summary%>
tags:
related: '[[<% tp.date.now("YYYY-MM-DD-ddd") %>]]'
class: event
event-id: <%event?.id%>
allDay: false
date: <%* tR += event.start.date ? 
window.moment(event.start.date).format("DD-MM-YYYY") : 
window.moment(event.start.dateTime).format("YYYY-MM-DD") %>
startTime: <%* tR += event.start.date ? 
window.moment(event.start.date).format("DD-MM-YYYY") : 
window.moment(event.start.dateTime).format("HH:mm") %>
endTime: <%
event.start.date 
? window.moment(event.end.date).format("DD-MM-YYYY") 
: window.moment(event.end.dateTime).format("HH:mm")
%>
created: <% tp.file.creation_date() %>
<% "---" %>

# {{gEvent.summary}} 

<%
event.start.date 
? window.moment(event.start.date).format("DD-MM-YYYY") 
: window.moment(event.start.dateTime).format("dddd, MMMM Do, YYYY, HH:mm")
%> - <%
event.start.date 
? window.moment(event.end.date).format("DD-MM-YYYY") 
: window.moment(event.end.dateTime).format("HH:mm")
%>
{{gEvent.location}}
[Edit ✏️]({{gEvent.htmlLink}})

{{gEvent.description}}

<%
tr = event?.attachments?.reduce((all,attachment) => `${all}- [${attachment.title}](${attachment.fileUrl})\n`,'') ?? ""
%>

# Notes

<% tp.file.cursor(1) %>
machado-t commented 11 months ago

I think I solved this adding quotation marks:

title: "<%event?.summary%>"