whateverforever / zettelcon Goto Github PK
View Code? Open in Web Editor NEWAutomatic markdown backlinks. Designed with Zettlr in mind.
License: MIT License
Automatic markdown backlinks. Designed with Zettlr in mind.
License: MIT License
I'm interested in using this for a bunch of inter-linked markdown files which don't use wiki-links and instead use more vanilla markdown syntax, like this:
[filename](./filename.md)
If I wanted to modify this to work with such links, do I just need to edit the regex in line 17?
Or is there other code I'd need to change as well?
I have tried to run this script on my files, but I got UnicodeDecodeError. I added to the open(...) functions the option encoding="utf8"
, and added a try statement here:
def get_file_outlinks(path):
with open(path, "r", encoding='utf8') as fh:
try:
contents = fh.read()
print(path)
except UnicodeDecodeError:
print('----', path)
With this I discovered some of my files were ANSI encoded, not utf-8 (?!?). I then converted them and run the altered script again. This time things went smoothly. It just complained many articles didn't have back references, which is actually quite cool, but could perhaps be printed a bit better, it's hard to read.
However, I downloaded the original and ran it, got UnicodeDecodeError again, line 187, function get_file_outlinks. Adding encoding="utf8"
fixed this. What could be causing this? I think that adding some safeguard against encoding errors would be cool.
Full traceback of this last part,:
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\Labore-05-Rosangela\Anaconda3\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "C:\Users\Labore-05-Rosangela\Anaconda3\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "C:\Users\Labore-05-Rosangela\Dropbox\Zettelkasten - Copy\zettelcon.py", line 185, in get_file_outlinks
contents = fh.read()
File "C:\Users\Labore-05-Rosangela\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 5445: character maps to <undefined>
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".\zettelcon.py", line 230, in <module>
main()
File ".\zettelcon.py", line 49, in main
process_directory(**params)
File ".\zettelcon.py", line 58, in process_directory
res = pool.map(get_file_outlinks, files)
File "C:\Users\Labore-05-Rosangela\Anaconda3\lib\multiprocessing\pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Users\Labore-05-Rosangela\Anaconda3\lib\multiprocessing\pool.py", line 657, in get
raise self._value
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 5445: character maps to <undefined>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.