
\ before _ or #Copy and paste below into boostnote
import time
import pytz
import arrow
import datetime
from django.utils import timezone as djtz
from django.utils.dateparse import parse_datetime
# ISO 8601
# https://www.w3.org/TR/NOTE-datetime
# http://crsmithdev.com/arrow/#tokens
TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSSZZ'
def get_current_timestamp():
"""
:return: current timestamp in ms (13 bit)
"""
return int(time.time() * 1000)
@weaming what are your preferences? I can't reproduce the bug.
@ZeroX-DG were you able to reproduce it?
I see the same problem. I was pasting some SQL from Visual Studio Code on Mac. Saw it happening both when pasting into a regular note inside a code block section (three back ticks) and also when posting it into a new snippet note.
I just installed Boostnote an hour ago and was in the process of evaluating it. I think the only settings I changed was to Dracula theme.
I can replicate it with this :
select col_one, col_two
case
when col_three_jan is null then 'no value'
when col_three_jan is not null and col_three_jan = (substr(col_four_jan,2,6)) then 'match'
else 'no match' end as col_three_match
from sometable
what showed up in the editor was:
select col\_one, col\_two
case
when col\_three\_jan is null then 'no value'
when col\_three\_jan is not null and col\_three\_jan = (substr(col\_four\_jan,2,6)) then 'match'
else 'no match' end as col\_three\_match
from sometable
extra backslashes, double spaced, extra spacing in the line (e.g. around the word null). Not sure what mangled it.
If I copy the code from Visual Studio Code and paste into Atom it looks fine.
If I paste the code into Atom and then copy it to the clipboard again and then paste into BoostNote it looks fine, so it seems like it's specific to VS Code.
I have no idea how the clipboard on Mac works, but I know on Windows, you can copy multiple formats onto the clipboard (i.e. one copy to the clipboard action may result in both plain text and RTF versions of the text in the clipboard) and it's up to the consumer of the clipboard to choose a format it supports from the available formats. Maybe VS Code is providing an RTF or other format that preserves color syntax highlighting and you all are just grabbing that instead of plain text... That would be my guess anyway...
Using the wonky old clipboard viewer I found at :
https://developer.apple.com/library/archive/samplecode/ClipboardViewer/Introduction/Intro.html
and tweaking to to build on 64-bit MacOS, when I copy text from VS Code I see 4 formats put on the clipboard:
public.html
Apple HTML pasteboard type
public.utf8-plain-test
NSStringPboardType
The last 2 look like plain text and the first 2 look like HTML.
When I copy text from Atom, only the last 2 formats are put on the clipboard.
Oddly enough if I paste it into a normal note I see the _ in the editing pane but not in the pane where the markdown is rendered. Anyways, not sure what the intent was on the BoostNote side that led to this behavior was but for a programmers note app, you really need to be able to handle pasting from VS Code better, even if you just add a paste without formatting menu item or make that configurable. Since it doesn't actually replicate the HTML formatting in BoostNote when you paste one of those clipboard formats, not sure that it makes sense to use them. From the Electron docs it looks like you can query the clipboard formats available and ask for which you want. At a minimum you might want to change the code so that if you are pasting into a code block or snippet that you take the plain text option. Anyways, like I said I'm not clear on what the intent of the existing code was so something to think about...
That should have been that I see the
\_
in the editing pane but of course the markdown here also ate the backslash.
@reyes-c1 thanks for the tip, now I can reproduce the bug... I just need to paste the code on TextEdit, then copy/paste into Boostnote.
As you said, Boostnote paste it as an HTML text (it isn't) which alters the text.
I think, in a code block, the pasted text should always be text (no HTML pre-processing).
@ZeroX-DG @weaming @reyes-c1 what do you think?
Agree! @daiyam can you reproduce it on Linux? I somehow still can't reproduce it.
@ZeroX-DG I can reproduce it on Linux (Ubuntu 18.10).
Created the following sql in VS Code:
select col_one_one, col_two_two
case when col_three_three is null then "no match"
when col_four_four = substr(col_five_five, 6, 5) then "match"
else "well darn" as match_game_over
from sometable
Save the file as junk.sql. You must save the file to engage color syntax highlighting.
Select all and copy.
In a terminal you can check what formats are on the clipboard like this:
xclip -o -t TARGETS -selection clipboard
and you can see what it has for html and text like:
xclip -o -t text/html -selection clipboard
xclip -o -t text/plain -selection clipboard
Create a new note in Boostnote. Type three back quotes and paste between the beginning and ending back quotes.
What shows up is
select col\_one\_one, col\_two\_two
case when col\_three\_three is null then "no match"
when col\_four\_four = substr(col\_five\_five, 6, 5) then "match"
else "well darn" as match\_game\_over
from sometable
I was copy text from PyCharm IDE.
Previous version of Boostnote was ok, I think revert this part code of paste will solve it. How do you think? @ZeroX-DG
@weaming the issue is that the editor has been improved to generate markdown code when pasting html but it should be disable inside code block... If I have time this week-end, I will propose a PR to fix the current issue.
I've proposed a fix. It would be great if you could test it.
@daiyam I think should add a switch in settings because I don't want rich-text when paste html sometimes.
can you use ctrl + v for normal paste and ctrl + shift + v for special paste?
no need to outsmart the text that way. let the user decide.
@ZeroX-DG what do you think?
It's also a good idea to add a shortcut for special paste. But all the things that pasted in the code blocks should always be text so I guess @daiyam PR is still necessary and it would be nice if we can also implement that special paste shortcut.
OK, I will add both options :smile: maybe tomorrow...
Thank you for your contribution @daiyam :smile:
I've made the update :wink:
I've added the option to enable/disable to paste as HTML

and the shortcut to do it even if it's disabled

Also, the images, as Data URI, can be recognized as image by the smart paste.
@issuehuntfest has funded $40.00 to this issue. See it on IssueHunt
@daiyam has submitted a pull request. See it on IssueHunt
@issuehuntfest has cancelled funding for this issue.(Cancelled amount: $40.00) See it on IssueHunt
I don't know if the option to disable HTML paste was supposed to fix this, but it did not for me. This is a major issue for me and I have to switch to a different tool because of it. I also primarily see this issue occurring with slashes ("\") being added before brackets ("[" and "]"), as well as the issue of any slashes already existent within the code being duplicated, leaving the code with two in a row ("\\").
@IAmMateo can you provide the version used, your os, from where you are coping from, and an example of the code to be copied. Thx
It appears that if you Enable Smart Table Editor unchecking the box doesn't return the behavior to where it pasted without the "\".
Edit: My bad- it appears that since this action takes place in the buffer that I just needed to recopy the text I had selected. Strange behavior but certainly non-lethal.
Most helpful comment
I've made the update :wink:
I've added the option to enable/disable to paste as HTML

and the shortcut to do it even if it's disabled

Also, the images, as Data URI, can be recognized as image by the smart paste.