markusstraub / mdsplit Goto Github PK
View Code? Open in Web Editor NEWmdsplit is a python command line tool to split markdown files into chapters at a given heading level
License: MIT License
mdsplit is a python command line tool to split markdown files into chapters at a given heading level
License: MIT License
Hi,
first of all thanks for this really useful script! Unfortunately I got a encoding errors when I ran it for the first time as Python 3.8 under windows assumes the cp1252 encoding on my computer.
File "C:\dev\tmsspec-doc-py\mdsplit.py", line 341, in <module>
main()
File "C:\dev\tmsspec-doc-py\mdsplit.py", line 333, in main
splitter.process()
File "C:\dev\tmsspec-doc-py\mdsplit.py", line 147, in process
self.process_file(self.in_path, self.out_path)
File "C:\dev\tmsspec-doc-py\mdsplit.py", line 166, in process_file
self.process_stream(stream, in_file_path.name, out_path)
File "C:\dev\tmsspec-doc-py\mdsplit.py", line 88, in process_stream
file.write(line)
File "C:\Program Files\Python38\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\ue60f' in position 4: character maps to <undefined>`
Wouldn't make it sense if the script assumed utf-8 encoding by default - maybe overrideable via CLI parameter? Had to monkey-patch the file.open() calls in your script with encoding="utf-8"
to make it work.
Thanks,
Franz
If one heading is very long, the software will fail due to OSError in linux.
Traceback (most recent call last):
File "mdsplit", line 8, in
sys.exit(main())
^^^^^^
File "mdsplit.py", line 342, in main
splitter.process()
File "mdsplit.py", line 148, in process
self.process_file(self.in_path, self.out_path)
File "mdsplit.py", line 167, in process_file
self.process_stream(stream, in_file_path.name, out_path)
File "mdsplit.py", line 75, in process_stream
if not chapter_path.exists():
^^^^^^^^^^^^^^^^^^^^^
File "pathlib.py", line 1235, in exists
self.stat()
File "pathlib.py", line 1013, in stat
return os.stat(self, follow_symlinks=follow_symlinks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long:
Is there some particular limitation to the number of accepted levels to descent into? I have a file with 8 levels, and I would really like to split it for my Obsidian vault. Thanks.
It would be great if mdsplit could also fix markdown cross-references like [text](#target)
(where target is a link to an internal heading) if link and target are no longer in the same file.
Same goes for relative image links in the input markdown that are no longer valid in the split output markdown.
[link](<basename.md>)
does not get the proper MIME type assigned by the server. .md
needs to be removed. Together with above change such links are served correctly: [link](basename)
Assignees: @prismv
Labels:
Milestone:
The CLI interface of mdsplit is really neat, but for some use cases I'd really need a python library version of it:
Thus the library version needs to represent the split markdown documents as objects and offer methods to access their contents as well as some merge logic.
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.