Clean extra newlines from PDF pastes #644
xmacex
started this conversation in
Templates Showcase
Replies: 1 comment
-
@xmacex, is this a showcase or do you need help? If this is just a showcase, ignore this postIf you need help:Here are my comments:
<%*
var sel = tp.file.selection()
sel.replace("\n\n", "")
tR += sel
console.log(sel)
%> From my experience, copied text from pdfs usually have a combination of Here are some scripts I made for you:
<%*
let sel = tp.file.selection()
if (sel) {
sel = sel.replace(/\s*(\n|\r\n)/gm," ").replace(/\r\n/gm," ").replace(/\n/gm," ")
tR += sel
}
%>
<%*
var clip = await tp.system.clipboard();
if (clip) {
clip = clip.replace(/\s*(\n|\r\n)/gm," ").replace(/\r\n/gm," ").replace(/\n/gm," ")
tR += clip
}
%> ^ So that instead of copy from pdf -> goto obsidian -> paste -> Select -> Run script. You can just copy from pdf -> goto obsidian -> run script. Hope this helps ~Welp |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While we wait for PDF to fade away into the mist of history, we all struggle with copy-paste from them.
For instance, here is a paste from PDF of Neil Selwyn's ‘Just playing around with Excel and pivot tables’ - the realities of data-driven schooling (2020, Research Papers in Education)
Same as a screenshot
Note the frequent double newlines. I am hoping to find a syntax for cleaning a selected region.
was not enough; it removes the selected text altogether.
Beta Was this translation helpful? Give feedback.
All reactions