DT2Go can lose formatting of RTF files

(I may have already reported this — if so, forgive the duplication.)

When I edit an RTF doc in DT to Go, it will occasionally lose all formatting (click edit, and the file opens with no formatting). This happens when the file ends on a character other than a line return. When the last line is an empty line return, the file retains its formatting.

This is repeatable:

  • create a new RTF in DT3, and end the doc on a character other than a line return (e.g. so the final position of the cursor is at the end of a word)
  • Save the file and sync DT3
  • open that file in DT2Go, and click edit: formatting will be lost. Close without making a change
  • return to DT3, open the file, and add an empty line return (hit return a couple times)
  • Save the file and sync DT3
  • open that file in DT2Go, and click edit: formatting is retained

If I add an open that file in DT3, add an empty line to the end of the doc, sync it, and

Yes, this is known. RTFs are not mobile-native and the third=party frameworks we employ have some issues. We are investigating better options for DEVONthink To Go 3. Thanks for your patience and understanding.

No problem, I get it. I just need to remind myself to always hit return a couple times at the end of the file!

I was creating a post about the same issue.

This is very annoying because it makes editing in DT2G always a “scary” thing to do, as it often loses its format. And I have to say that my primary use of DT resides into a vast collection of RTFs docs, for everything.

I hope this issue is taken into consideration soon.

Otherwise (not as a solution, but as general knowledge), if RTFs are not mobile-native, what’s the best format to use when you want to alternate between desktop and mobile?

Welcome @gian

It depends, but formatted notes are useful to many (though there is a size restriction of about 10MB due to iOS memory constraints).
Plain text is always a good option, as is Markdown.

Was thinking about a potential workaround. Since RTFs that end with a return character do not lose formatting, we could create a smart rule that triggers before syncing, scans all RTFs modified that day, and if the file does not end in a return character, add one (or two). Like this:

Would there be any potential issues with this?

I don’t see anything of particular concern here.

1 Like

Once is usually enough, a habit I trained myself many years ago to do when editing text files. :slightly_smiling_face:

Without a newline at the end, it implies to me that new text will be appended to the current line at the end and that’s not normally how I want it to behave.

Whoops - the script for my smart rule was wrong — it was just working on the open document, and I need to make it run on each matching document. So here’s the new setup:

Screen Shot 2020-01-19 at 10.11 AM

And the script is:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set alltext to plain text of theRecord
			set lastchar to text -1 of alltext
			if lastchar is not (ASCII character 10) and lastchar is not (ASCII character 13) then
				tell text of theRecord
					make new paragraph at end with data return & return & return & return
				end tell
				set logthis to 1
			end if
		end repeat
	end tell
	if logthis = 1 then
		log message "Log Smart Rule: fix RTFs for iOS" info "triggered at: " & ((current date) as string)
	end if
end performSmartRule

This smart rule will check every recently edited RTF document, and if it doesn’t end in a return or new-line, it adds several returns (several because I like having the extra space) before synchronizing. So when you then edit that file in DT2Go, it does not lose its formatting.

Seems to be working well on my side. Let me know if you find a bug.

1 Like

Strangely, using text of is returning an invalid value. This may be a cached value from the index of the database but @cgrunenberg would have to confirm or deny this.

Change it to plain text of theRecord.

1 Like

OK, changed it in the script above.

All working well still?

You know I hate RTFs (kidding!! :stuck_out_tongue: ) but it seems like it’s doing what is expected.

Yeah, WYSIWYG is soooo overrated. :stuck_out_tongue_winking_eye:

1 Like

I’m sure it will never catch on :roll_eyes:
:wink:

(Edited the script above so that it will add a log item, but only if it modifies a file.)

I’ve added a condition so it doesn’t look at files modified in the last hour. I was typing into an RTF file when the sync ran and the Smart Rule deleted the last few words and added 2 returns.

Ah, good catch! Sorry about that.

I tried using “Before Saving” as the trigger — sounds like it would be the right one to use, no? — but was getting strange results: sometimes it would work, then other times it would lose the last edit I made, and the script would seemingly run multiple times (e.g. adding 15 returns to the end).

Your approach is safer since it avoids messing with any active documents.